@skillkit/core 1.6.3 → 1.6.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/dist/index.js CHANGED
@@ -65,6 +65,203 @@ var SkillkitConfig = z.object({
65
65
  defaultTimeout: z.number().optional()
66
66
  });
67
67
 
68
+ // src/agent-config.ts
69
+ var AGENT_CONFIG = {
70
+ // Claude Code - all Claude products use the same format
71
+ "claude-code": {
72
+ skillsDir: ".claude/skills",
73
+ configFile: "CLAUDE.md",
74
+ globalSkillsDir: "~/.claude/skills",
75
+ configFormat: "xml",
76
+ usesFrontmatter: true,
77
+ frontmatterFields: [
78
+ "name",
79
+ "description",
80
+ "allowed-tools",
81
+ "model",
82
+ "context",
83
+ "agent",
84
+ "disable-model-invocation",
85
+ "user-invocable",
86
+ "argument-hint"
87
+ ],
88
+ supportsAutoDiscovery: true
89
+ },
90
+ // Cursor - uses MDC format in .cursor/rules/
91
+ cursor: {
92
+ skillsDir: ".cursor/skills",
93
+ configFile: ".cursor/rules/skills.mdc",
94
+ altSkillsDirs: [".cursor/commands"],
95
+ globalSkillsDir: "~/.cursor/skills",
96
+ configFormat: "mdc",
97
+ usesFrontmatter: true,
98
+ frontmatterFields: ["description", "globs", "alwaysApply"],
99
+ supportsAutoDiscovery: true
100
+ },
101
+ // Codex (OpenAI)
102
+ codex: {
103
+ skillsDir: ".codex/skills",
104
+ configFile: "AGENTS.md",
105
+ globalSkillsDir: "~/.codex/skills",
106
+ configFormat: "markdown-table",
107
+ usesFrontmatter: true,
108
+ supportsAutoDiscovery: true
109
+ },
110
+ // Gemini CLI
111
+ "gemini-cli": {
112
+ skillsDir: ".gemini/skills",
113
+ configFile: "GEMINI.md",
114
+ globalSkillsDir: "~/.gemini/skills",
115
+ configFormat: "json",
116
+ usesFrontmatter: true,
117
+ supportsAutoDiscovery: true
118
+ },
119
+ // OpenCode
120
+ opencode: {
121
+ skillsDir: ".opencode/skills",
122
+ configFile: "AGENTS.md",
123
+ altSkillsDirs: [".opencode/agent"],
124
+ globalSkillsDir: "~/.config/opencode/skills",
125
+ configFormat: "xml",
126
+ usesFrontmatter: true,
127
+ supportsAutoDiscovery: true
128
+ },
129
+ // Antigravity
130
+ antigravity: {
131
+ skillsDir: ".antigravity/skills",
132
+ configFile: "AGENTS.md",
133
+ configFormat: "xml",
134
+ usesFrontmatter: true,
135
+ supportsAutoDiscovery: true
136
+ },
137
+ // Amp - uses .amp/ directory
138
+ amp: {
139
+ skillsDir: ".amp/skills",
140
+ configFile: "AGENTS.md",
141
+ configFormat: "xml",
142
+ usesFrontmatter: true,
143
+ supportsAutoDiscovery: true
144
+ },
145
+ // Clawdbot
146
+ clawdbot: {
147
+ skillsDir: ".clawdbot/skills",
148
+ configFile: "AGENTS.md",
149
+ altSkillsDirs: ["skills"],
150
+ configFormat: "xml",
151
+ usesFrontmatter: true,
152
+ supportsAutoDiscovery: true
153
+ },
154
+ // Droid (Factory)
155
+ droid: {
156
+ skillsDir: ".factory/skills",
157
+ configFile: "AGENTS.md",
158
+ configFormat: "xml",
159
+ usesFrontmatter: true,
160
+ supportsAutoDiscovery: true
161
+ },
162
+ // GitHub Copilot
163
+ "github-copilot": {
164
+ skillsDir: ".github/skills",
165
+ configFile: ".github/copilot-instructions.md",
166
+ altSkillsDirs: [".github/instructions"],
167
+ configFormat: "markdown",
168
+ usesFrontmatter: true,
169
+ supportsAutoDiscovery: true
170
+ },
171
+ // Goose
172
+ goose: {
173
+ skillsDir: ".goose/skills",
174
+ configFile: "AGENTS.md",
175
+ globalSkillsDir: "~/.goose/skills",
176
+ configFormat: "xml",
177
+ usesFrontmatter: true,
178
+ supportsAutoDiscovery: true
179
+ },
180
+ // Kilo
181
+ kilo: {
182
+ skillsDir: ".kilocode/skills",
183
+ configFile: "AGENTS.md",
184
+ altSkillsDirs: [".kilocode/modes"],
185
+ globalSkillsDir: "~/.kilocode/skills",
186
+ configFormat: "xml",
187
+ usesFrontmatter: true,
188
+ supportsAutoDiscovery: true
189
+ },
190
+ // Kiro CLI
191
+ "kiro-cli": {
192
+ skillsDir: ".kiro/skills",
193
+ configFile: "AGENTS.md",
194
+ globalSkillsDir: "~/.kiro/skills",
195
+ configFormat: "xml",
196
+ usesFrontmatter: true,
197
+ supportsAutoDiscovery: true
198
+ },
199
+ // Roo Code
200
+ roo: {
201
+ skillsDir: ".roo/skills",
202
+ configFile: "AGENTS.md",
203
+ altSkillsDirs: [".roo/modes"],
204
+ globalSkillsDir: "~/.roo/skills",
205
+ configFormat: "xml",
206
+ usesFrontmatter: true,
207
+ supportsAutoDiscovery: true
208
+ },
209
+ // Trae
210
+ trae: {
211
+ skillsDir: ".trae/skills",
212
+ configFile: ".trae/rules/project_rules.md",
213
+ altSkillsDirs: [".trae/agent"],
214
+ configFormat: "markdown",
215
+ usesFrontmatter: true,
216
+ supportsAutoDiscovery: true
217
+ },
218
+ // Windsurf
219
+ windsurf: {
220
+ skillsDir: ".windsurf/skills",
221
+ configFile: ".windsurf/rules/skills.md",
222
+ altSkillsDirs: [".windsurf/workflows"],
223
+ globalSkillsDir: "~/.codeium/windsurf/skills",
224
+ configFormat: "markdown",
225
+ usesFrontmatter: true,
226
+ supportsAutoDiscovery: true
227
+ },
228
+ // Universal - works with any agent
229
+ universal: {
230
+ skillsDir: "skills",
231
+ configFile: "AGENTS.md",
232
+ altSkillsDirs: [".agent/skills", ".agents/skills"],
233
+ configFormat: "xml",
234
+ usesFrontmatter: true,
235
+ supportsAutoDiscovery: true
236
+ }
237
+ };
238
+ function getAgentDirectoryConfig(agent) {
239
+ return AGENT_CONFIG[agent];
240
+ }
241
+ function getSkillsDir(agent) {
242
+ return AGENT_CONFIG[agent].skillsDir;
243
+ }
244
+ function getConfigFile(agent) {
245
+ return AGENT_CONFIG[agent].configFile;
246
+ }
247
+ function getAllSkillsDirs(agent) {
248
+ const config = AGENT_CONFIG[agent];
249
+ const dirs = [config.skillsDir];
250
+ if (config.altSkillsDirs) {
251
+ dirs.push(...config.altSkillsDirs);
252
+ }
253
+ return dirs;
254
+ }
255
+ function getGlobalSkillsDir(agent) {
256
+ return AGENT_CONFIG[agent].globalSkillsDir;
257
+ }
258
+ function supportsAutoDiscovery(agent) {
259
+ return AGENT_CONFIG[agent].supportsAutoDiscovery;
260
+ }
261
+ function getConfigFormat(agent) {
262
+ return AGENT_CONFIG[agent].configFormat;
263
+ }
264
+
68
265
  // src/skills.ts
69
266
  import { existsSync, readdirSync, readFileSync } from "fs";
70
267
  import { join, basename } from "path";
@@ -324,8 +521,8 @@ function validateSkill(skillPath) {
324
521
  return { valid: errors.length === 0, errors, warnings };
325
522
  }
326
523
  function isPathInside(child, parent) {
327
- const relative3 = child.replace(parent, "");
328
- return !relative3.startsWith("..") && !relative3.includes("/..");
524
+ const relative4 = child.replace(parent, "");
525
+ return !relative4.startsWith("..") && !relative4.includes("/..");
329
526
  }
330
527
 
331
528
  // src/config.ts
@@ -2770,25 +2967,6 @@ function initContext(projectPath, options) {
2770
2967
  // src/context/sync.ts
2771
2968
  import { existsSync as existsSync10, writeFileSync as writeFileSync4, mkdirSync as mkdirSync4, copyFileSync, readdirSync as readdirSync3 } from "fs";
2772
2969
  import { join as join9 } from "path";
2773
- var AGENT_DIRS = {
2774
- "claude-code": { skillsDir: ".claude/skills", configFile: "AGENTS.md" },
2775
- "cursor": { skillsDir: ".cursor/skills", configFile: ".cursorrules" },
2776
- "codex": { skillsDir: ".codex/skills", configFile: "AGENTS.md" },
2777
- "gemini-cli": { skillsDir: ".gemini/skills", configFile: "GEMINI.md" },
2778
- "opencode": { skillsDir: ".opencode/skills", configFile: "AGENTS.md" },
2779
- "antigravity": { skillsDir: ".antigravity/skills", configFile: "AGENTS.md" },
2780
- "amp": { skillsDir: ".agents/skills", configFile: "AGENTS.md" },
2781
- "clawdbot": { skillsDir: "skills", configFile: "AGENTS.md" },
2782
- "droid": { skillsDir: ".factory/skills", configFile: "AGENTS.md" },
2783
- "github-copilot": { skillsDir: ".github/skills", configFile: "AGENTS.md" },
2784
- "goose": { skillsDir: ".goose/skills", configFile: "AGENTS.md" },
2785
- "kilo": { skillsDir: ".kilocode/skills", configFile: "AGENTS.md" },
2786
- "kiro-cli": { skillsDir: ".kiro/skills", configFile: "AGENTS.md" },
2787
- "roo": { skillsDir: ".roo/skills", configFile: "AGENTS.md" },
2788
- "trae": { skillsDir: ".trae/skills", configFile: "AGENTS.md" },
2789
- "windsurf": { skillsDir: ".windsurf/skills", configFile: "AGENTS.md" },
2790
- "universal": { skillsDir: ".agent/skills", configFile: "AGENTS.md" }
2791
- };
2792
2970
  var ContextSync = class {
2793
2971
  projectPath;
2794
2972
  contextManager;
@@ -2801,7 +2979,7 @@ var ContextSync = class {
2801
2979
  */
2802
2980
  detectAgents() {
2803
2981
  const detected = [];
2804
- for (const [agent, config] of Object.entries(AGENT_DIRS)) {
2982
+ for (const [agent, config] of Object.entries(AGENT_CONFIG)) {
2805
2983
  const skillsPath = join9(this.projectPath, config.skillsDir);
2806
2984
  const configPath = join9(this.projectPath, config.configFile);
2807
2985
  if (existsSync10(skillsPath) || existsSync10(configPath)) {
@@ -2870,7 +3048,7 @@ var ContextSync = class {
2870
3048
  files: []
2871
3049
  };
2872
3050
  const sourceSkills = skills || this.getSourceSkills();
2873
- const agentConfig = AGENT_DIRS[agent];
3051
+ const agentConfig = AGENT_CONFIG[agent];
2874
3052
  if (!agentConfig) {
2875
3053
  result.success = false;
2876
3054
  result.errors.push(`Unknown agent: ${agent}`);
@@ -2961,8 +3139,8 @@ var ContextSync = class {
2961
3139
  const context = this.contextManager.get();
2962
3140
  const primaryAgent = context?.agents?.primary;
2963
3141
  const searchDirs = [];
2964
- if (primaryAgent && AGENT_DIRS[primaryAgent]) {
2965
- searchDirs.push(join9(this.projectPath, AGENT_DIRS[primaryAgent].skillsDir));
3142
+ if (primaryAgent && AGENT_CONFIG[primaryAgent]) {
3143
+ searchDirs.push(join9(this.projectPath, AGENT_CONFIG[primaryAgent].skillsDir));
2966
3144
  }
2967
3145
  const commonDirs = [
2968
3146
  ".claude/skills",
@@ -2984,7 +3162,7 @@ var ContextSync = class {
2984
3162
  */
2985
3163
  checkStatus() {
2986
3164
  const status = {};
2987
- for (const [agent, config] of Object.entries(AGENT_DIRS)) {
3165
+ for (const [agent, config] of Object.entries(AGENT_CONFIG)) {
2988
3166
  const skillsPath = join9(this.projectPath, config.skillsDir);
2989
3167
  const skills = [];
2990
3168
  if (existsSync10(skillsPath)) {
@@ -4914,7 +5092,7 @@ var SkillExecutionEngine = class {
4914
5092
  const startTime = /* @__PURE__ */ new Date();
4915
5093
  const taskId = task.id || randomUUID6();
4916
5094
  try {
4917
- await new Promise((resolve3) => setTimeout(resolve3, 100));
5095
+ await new Promise((resolve4) => setTimeout(resolve4, 100));
4918
5096
  const endTime = /* @__PURE__ */ new Date();
4919
5097
  return {
4920
5098
  taskId,
@@ -5251,7 +5429,7 @@ async function executeWithAgent(agentType, prompt, options = {}) {
5251
5429
  });
5252
5430
  }
5253
5431
  async function executeCommand(command, args, options = {}) {
5254
- return new Promise((resolve3) => {
5432
+ return new Promise((resolve4) => {
5255
5433
  const startTime = Date.now();
5256
5434
  let stdout = "";
5257
5435
  let stderr = "";
@@ -5274,7 +5452,7 @@ async function executeCommand(command, args, options = {}) {
5274
5452
  });
5275
5453
  child.on("error", (error) => {
5276
5454
  if (timeoutId) clearTimeout(timeoutId);
5277
- resolve3({
5455
+ resolve4({
5278
5456
  success: false,
5279
5457
  output: stdout,
5280
5458
  error: error.message,
@@ -5284,7 +5462,7 @@ async function executeCommand(command, args, options = {}) {
5284
5462
  });
5285
5463
  child.on("close", (code) => {
5286
5464
  if (timeoutId) clearTimeout(timeoutId);
5287
- resolve3({
5465
+ resolve4({
5288
5466
  success: code === 0 && !timedOut,
5289
5467
  output: stdout,
5290
5468
  error: timedOut ? "Execution timed out" : stderr || void 0,
@@ -5479,7 +5657,7 @@ function createSimulatedSkillExecutor(options = {}) {
5479
5657
  const { delay = 100, shouldFail, onExecute } = options;
5480
5658
  return async (skillName, _config) => {
5481
5659
  onExecute?.(skillName);
5482
- await new Promise((resolve3) => setTimeout(resolve3, delay));
5660
+ await new Promise((resolve4) => setTimeout(resolve4, delay));
5483
5661
  const failed = shouldFail?.(skillName) ?? false;
5484
5662
  return {
5485
5663
  success: !failed,
@@ -5928,12 +6106,12 @@ function assertEnvVarSet(assertion, startTime) {
5928
6106
  };
5929
6107
  }
5930
6108
  async function checkPortAvailable(port) {
5931
- return new Promise((resolve3) => {
6109
+ return new Promise((resolve4) => {
5932
6110
  const server = createServer();
5933
- server.once("error", () => resolve3(false));
6111
+ server.once("error", () => resolve4(false));
5934
6112
  server.once("listening", () => {
5935
6113
  server.close();
5936
- resolve3(true);
6114
+ resolve4(true);
5937
6115
  });
5938
6116
  server.listen(port, "127.0.0.1");
5939
6117
  });
@@ -6455,9 +6633,9 @@ var MarketplaceAggregator = class {
6455
6633
  const context = readme.slice(contextStart, contextEnd);
6456
6634
  const descMatch = context.match(/[-*]\s*\[.*?\]\(.*?\)\s*[-:]\s*(.+?)(?:\n|$)/);
6457
6635
  const description = descMatch ? descMatch[1].trim() : "";
6458
- const isAbsolute2 = this.isAbsoluteUrl(path2);
6459
- const normalizedPath = isAbsolute2 ? path2 : path2.startsWith("/") ? path2 : `/${path2}`;
6460
- const rawUrl = isAbsolute2 ? this.toRawUrl(path2) : `https://raw.githubusercontent.com/${source.owner}/${source.repo}/${branch}/${path2}`;
6636
+ const isAbsolute3 = this.isAbsoluteUrl(path2);
6637
+ const normalizedPath = isAbsolute3 ? path2 : path2.startsWith("/") ? path2 : `/${path2}`;
6638
+ const rawUrl = isAbsolute3 ? this.toRawUrl(path2) : `https://raw.githubusercontent.com/${source.owner}/${source.repo}/${branch}/${path2}`;
6461
6639
  skills.push({
6462
6640
  id: `${source.owner}/${source.repo}/${path2}`,
6463
6641
  name,
@@ -14332,8 +14510,8 @@ var PlanExecutor = class {
14332
14510
  pause() {
14333
14511
  if (!this.isPaused) {
14334
14512
  this.isPaused = true;
14335
- this.resumePromise = new Promise((resolve3) => {
14336
- this.resumeResolve = resolve3;
14513
+ this.resumePromise = new Promise((resolve4) => {
14514
+ this.resumeResolve = resolve4;
14337
14515
  });
14338
14516
  this.emit("plan:paused", {});
14339
14517
  }
@@ -15865,21 +16043,21 @@ var AgentMetadata = z5.object({
15865
16043
  });
15866
16044
  var AGENT_DISCOVERY_PATHS = {
15867
16045
  "claude-code": [".claude/agents"],
15868
- "cursor": [".cursor/agents"],
16046
+ "cursor": [".cursor/agents", ".cursor/commands"],
15869
16047
  "codex": [".codex/agents"],
15870
16048
  "gemini-cli": [".gemini/agents"],
15871
- "opencode": [".opencode/agents"],
16049
+ "opencode": [".opencode/agents", ".opencode/agent"],
15872
16050
  "antigravity": [".antigravity/agents"],
15873
16051
  "amp": [".amp/agents"],
15874
16052
  "clawdbot": [".clawdbot/agents", "agents"],
15875
16053
  "droid": [".factory/agents"],
15876
- "github-copilot": [".github/agents", ".github/copilot/agents"],
16054
+ "github-copilot": [".github/agents", ".github/instructions", ".github/custom-agents"],
15877
16055
  "goose": [".goose/agents"],
15878
- "kilo": [".kilocode/agents"],
16056
+ "kilo": [".kilocode/agents", ".kilocode/modes"],
15879
16057
  "kiro-cli": [".kiro/agents"],
15880
- "roo": [".roo/agents"],
15881
- "trae": [".trae/agents"],
15882
- "windsurf": [".windsurf/agents"],
16058
+ "roo": [".roo/agents", ".roo/modes"],
16059
+ "trae": [".trae/agents", ".trae/agent"],
16060
+ "windsurf": [".windsurf/agents", ".windsurf/workflows"],
15883
16061
  "universal": ["agents", ".agents"]
15884
16062
  };
15885
16063
  var ALL_AGENT_DISCOVERY_PATHS = [
@@ -15887,21 +16065,28 @@ var ALL_AGENT_DISCOVERY_PATHS = [
15887
16065
  ".agents",
15888
16066
  ".claude/agents",
15889
16067
  ".cursor/agents",
16068
+ ".cursor/commands",
15890
16069
  ".codex/agents",
15891
16070
  ".gemini/agents",
15892
16071
  ".opencode/agents",
16072
+ ".opencode/agent",
15893
16073
  ".antigravity/agents",
15894
16074
  ".amp/agents",
15895
16075
  ".clawdbot/agents",
15896
16076
  ".factory/agents",
15897
16077
  ".github/agents",
15898
- ".github/copilot/agents",
16078
+ ".github/instructions",
16079
+ ".github/custom-agents",
15899
16080
  ".goose/agents",
15900
16081
  ".kilocode/agents",
16082
+ ".kilocode/modes",
15901
16083
  ".kiro/agents",
15902
16084
  ".roo/agents",
16085
+ ".roo/modes",
15903
16086
  ".trae/agents",
15904
- ".windsurf/agents"
16087
+ ".trae/agent",
16088
+ ".windsurf/agents",
16089
+ ".windsurf/workflows"
15905
16090
  ];
15906
16091
  var CUSTOM_AGENT_FORMAT_MAP = {
15907
16092
  "claude-code": "claude-agent",
@@ -16701,10 +16886,457 @@ function isAgentCompatible(sourceFormat, targetFormat) {
16701
16886
  }
16702
16887
  return { compatible: true, warnings };
16703
16888
  }
16889
+
16890
+ // src/skill-translator.ts
16891
+ import { readFileSync as readFileSync24, existsSync as existsSync32, writeFileSync as writeFileSync17, mkdirSync as mkdirSync18 } from "fs";
16892
+ import { join as join33, basename as basename11, dirname as dirname11, resolve as resolve3, relative as relative3, isAbsolute as isAbsolute2 } from "path";
16893
+ import { parse as parseYaml11, stringify as stringifyYaml8 } from "yaml";
16894
+ var AGENT_SKILL_FORMATS = Object.fromEntries(
16895
+ Object.entries(AGENT_CONFIG).map(([agent, config]) => [
16896
+ agent,
16897
+ { ...config, invokeCommand: "skillkit read" }
16898
+ ])
16899
+ );
16900
+ function parseSkillToCanonical(skillPath, sourceAgent) {
16901
+ const skillMdPath = skillPath.endsWith("SKILL.md") ? skillPath : join33(skillPath, "SKILL.md");
16902
+ if (!existsSync32(skillMdPath)) {
16903
+ return null;
16904
+ }
16905
+ try {
16906
+ const content = readFileSync24(skillMdPath, "utf-8");
16907
+ return parseSkillContentToCanonical(content, skillPath, sourceAgent);
16908
+ } catch {
16909
+ return null;
16910
+ }
16911
+ }
16912
+ function parseSkillContentToCanonical(content, sourcePath, sourceAgent) {
16913
+ const frontmatterMatch = content.match(/^---\s*\n([\s\S]*?)\n---/);
16914
+ let frontmatter = {};
16915
+ let bodyContent = content;
16916
+ if (frontmatterMatch) {
16917
+ try {
16918
+ frontmatter = parseYaml11(frontmatterMatch[1]);
16919
+ bodyContent = content.slice(frontmatterMatch[0].length).trim();
16920
+ } catch {
16921
+ }
16922
+ }
16923
+ const name = frontmatter.name || basename11(sourcePath.endsWith(".md") ? dirname11(sourcePath) : sourcePath);
16924
+ const description = frontmatter.description || extractDescriptionFromContent(bodyContent);
16925
+ return {
16926
+ name,
16927
+ description,
16928
+ content: bodyContent,
16929
+ frontmatter,
16930
+ sourcePath,
16931
+ sourceAgent,
16932
+ version: frontmatter.version,
16933
+ author: frontmatter.author,
16934
+ tags: frontmatter.tags,
16935
+ allowedTools: parseAllowedTools(frontmatter["allowed-tools"]),
16936
+ agentFields: extractAgentSpecificFields(frontmatter, sourceAgent)
16937
+ };
16938
+ }
16939
+ function extractDescriptionFromContent(content) {
16940
+ const lines = content.split("\n").filter((line) => line.trim());
16941
+ for (const line of lines) {
16942
+ const trimmed = line.trim();
16943
+ if (trimmed.startsWith("#")) continue;
16944
+ if (trimmed.startsWith("```")) continue;
16945
+ if (trimmed.length > 10) {
16946
+ return trimmed.slice(0, 200) + (trimmed.length > 200 ? "..." : "");
16947
+ }
16948
+ }
16949
+ return "No description available";
16950
+ }
16951
+ function parseAllowedTools(value) {
16952
+ if (!value) return void 0;
16953
+ if (Array.isArray(value)) return value;
16954
+ if (typeof value === "string") {
16955
+ return value.split(",").map((t) => t.trim()).filter(Boolean);
16956
+ }
16957
+ return void 0;
16958
+ }
16959
+ function extractAgentSpecificFields(frontmatter, _sourceAgent) {
16960
+ const agentFields = {};
16961
+ const specialFields = [
16962
+ "disable-model-invocation",
16963
+ "user-invocable",
16964
+ "argument-hint",
16965
+ "model",
16966
+ "context",
16967
+ "agent",
16968
+ "globs",
16969
+ "alwaysApply",
16970
+ "applyTo",
16971
+ "mode",
16972
+ "hooks",
16973
+ "permissionMode"
16974
+ ];
16975
+ for (const field of specialFields) {
16976
+ if (field in frontmatter) {
16977
+ agentFields[field] = frontmatter[field];
16978
+ }
16979
+ }
16980
+ return agentFields;
16981
+ }
16982
+ function translateSkillToAgent(canonical, targetAgent, options) {
16983
+ const format = AGENT_SKILL_FORMATS[targetAgent];
16984
+ const warnings = [];
16985
+ const incompatible = [];
16986
+ if (canonical.agentFields?.["hooks"] && targetAgent !== "claude-code") {
16987
+ incompatible.push("hooks (only supported in Claude Code)");
16988
+ }
16989
+ if (canonical.agentFields?.["permissionMode"] && !["claude-code", "roo"].includes(targetAgent)) {
16990
+ warnings.push("permissionMode may not be fully supported");
16991
+ }
16992
+ const content = generateSkillContent(canonical, targetAgent, format, options);
16993
+ const filename = options?.outputFilename || "SKILL.md";
16994
+ const targetDir = options?.outputDir || join33(format.skillsDir, canonical.name);
16995
+ return {
16996
+ success: true,
16997
+ content,
16998
+ filename,
16999
+ targetDir,
17000
+ warnings,
17001
+ incompatible,
17002
+ targetAgent
17003
+ };
17004
+ }
17005
+ function generateSkillContent(canonical, targetAgent, format, options) {
17006
+ const lines = [];
17007
+ const frontmatter = {
17008
+ name: canonical.name,
17009
+ description: canonical.description
17010
+ };
17011
+ if (canonical.version) {
17012
+ frontmatter.version = canonical.version;
17013
+ }
17014
+ if (canonical.author) {
17015
+ frontmatter.author = canonical.author;
17016
+ }
17017
+ if (canonical.tags && canonical.tags.length > 0) {
17018
+ frontmatter.tags = canonical.tags;
17019
+ }
17020
+ if (canonical.allowedTools && canonical.allowedTools.length > 0) {
17021
+ frontmatter["allowed-tools"] = canonical.allowedTools.join(", ");
17022
+ }
17023
+ addAgentSpecificFields(frontmatter, canonical, targetAgent, format);
17024
+ if (options?.addMetadata && canonical.sourceAgent) {
17025
+ frontmatter["_translated-from"] = canonical.sourceAgent;
17026
+ frontmatter["_translated-at"] = (/* @__PURE__ */ new Date()).toISOString();
17027
+ }
17028
+ lines.push("---");
17029
+ lines.push(stringifyYaml8(frontmatter).trim());
17030
+ lines.push("---");
17031
+ lines.push("");
17032
+ lines.push(canonical.content);
17033
+ return lines.join("\n");
17034
+ }
17035
+ function addAgentSpecificFields(frontmatter, canonical, targetAgent, _format) {
17036
+ if (targetAgent === "claude-code") {
17037
+ if ("model" in (canonical.agentFields ?? {})) {
17038
+ frontmatter.model = canonical.agentFields["model"];
17039
+ }
17040
+ if ("context" in (canonical.agentFields ?? {})) {
17041
+ frontmatter.context = canonical.agentFields["context"];
17042
+ }
17043
+ if ("agent" in (canonical.agentFields ?? {})) {
17044
+ frontmatter.agent = canonical.agentFields["agent"];
17045
+ }
17046
+ if ("disable-model-invocation" in (canonical.agentFields ?? {})) {
17047
+ frontmatter["disable-model-invocation"] = canonical.agentFields["disable-model-invocation"];
17048
+ }
17049
+ if ("user-invocable" in (canonical.agentFields ?? {})) {
17050
+ frontmatter["user-invocable"] = canonical.agentFields["user-invocable"];
17051
+ }
17052
+ if ("argument-hint" in (canonical.agentFields ?? {})) {
17053
+ frontmatter["argument-hint"] = canonical.agentFields["argument-hint"];
17054
+ }
17055
+ if ("hooks" in (canonical.agentFields ?? {})) {
17056
+ frontmatter.hooks = canonical.agentFields["hooks"];
17057
+ }
17058
+ if ("permissionMode" in (canonical.agentFields ?? {})) {
17059
+ frontmatter.permissionMode = canonical.agentFields["permissionMode"];
17060
+ }
17061
+ }
17062
+ if (["cursor", "trae", "windsurf"].includes(targetAgent)) {
17063
+ if ("globs" in (canonical.agentFields ?? {})) {
17064
+ frontmatter.globs = canonical.agentFields["globs"];
17065
+ }
17066
+ if ("alwaysApply" in (canonical.agentFields ?? {})) {
17067
+ frontmatter.alwaysApply = canonical.agentFields["alwaysApply"];
17068
+ }
17069
+ if (targetAgent === "windsurf" && "mode" in (canonical.agentFields ?? {})) {
17070
+ frontmatter.mode = canonical.agentFields["mode"];
17071
+ }
17072
+ }
17073
+ if (targetAgent === "github-copilot") {
17074
+ if ("applyTo" in (canonical.agentFields ?? {})) {
17075
+ frontmatter.applyTo = canonical.agentFields["applyTo"];
17076
+ }
17077
+ }
17078
+ if (targetAgent === "roo") {
17079
+ if ("disable-model-invocation" in (canonical.agentFields ?? {})) {
17080
+ frontmatter["disable-model-invocation"] = canonical.agentFields["disable-model-invocation"];
17081
+ }
17082
+ if ("user-invocable" in (canonical.agentFields ?? {})) {
17083
+ frontmatter["user-invocable"] = canonical.agentFields["user-invocable"];
17084
+ }
17085
+ if ("permissionMode" in (canonical.agentFields ?? {})) {
17086
+ frontmatter.permissionMode = canonical.agentFields["permissionMode"];
17087
+ }
17088
+ }
17089
+ }
17090
+ function translateSkillToAll(skillPath, sourceAgent, options) {
17091
+ const canonical = parseSkillToCanonical(skillPath, sourceAgent);
17092
+ if (!canonical) {
17093
+ return /* @__PURE__ */ new Map();
17094
+ }
17095
+ const results = /* @__PURE__ */ new Map();
17096
+ const agents = [
17097
+ "claude-code",
17098
+ "cursor",
17099
+ "codex",
17100
+ "gemini-cli",
17101
+ "opencode",
17102
+ "antigravity",
17103
+ "amp",
17104
+ "clawdbot",
17105
+ "droid",
17106
+ "github-copilot",
17107
+ "goose",
17108
+ "kilo",
17109
+ "kiro-cli",
17110
+ "roo",
17111
+ "trae",
17112
+ "windsurf",
17113
+ "universal"
17114
+ ];
17115
+ for (const agent of agents) {
17116
+ if (agent !== sourceAgent) {
17117
+ results.set(agent, translateSkillToAgent(canonical, agent, options));
17118
+ }
17119
+ }
17120
+ return results;
17121
+ }
17122
+ function writeTranslatedSkill(result, rootDir, options) {
17123
+ if (!result.success) {
17124
+ return {
17125
+ success: false,
17126
+ path: "",
17127
+ error: "Translation failed"
17128
+ };
17129
+ }
17130
+ try {
17131
+ const rootPath = resolve3(rootDir);
17132
+ const filePath = resolve3(rootDir, result.targetDir, result.filename);
17133
+ const targetPath = dirname11(filePath);
17134
+ const relPath = relative3(rootPath, filePath);
17135
+ if (relPath.startsWith("..") || isAbsolute2(relPath)) {
17136
+ return {
17137
+ success: false,
17138
+ path: filePath,
17139
+ error: "Resolved output path escapes rootDir"
17140
+ };
17141
+ }
17142
+ if (existsSync32(filePath) && options?.overwrite === false) {
17143
+ return {
17144
+ success: false,
17145
+ path: filePath,
17146
+ error: "File exists and overwrite=false",
17147
+ skipped: true
17148
+ };
17149
+ }
17150
+ if (!existsSync32(targetPath)) {
17151
+ mkdirSync18(targetPath, { recursive: true });
17152
+ }
17153
+ writeFileSync17(filePath, result.content, "utf-8");
17154
+ return { success: true, path: filePath };
17155
+ } catch (error) {
17156
+ return {
17157
+ success: false,
17158
+ path: "",
17159
+ error: error instanceof Error ? error.message : String(error)
17160
+ };
17161
+ }
17162
+ }
17163
+ function generateSkillsConfig(skills, targetAgent) {
17164
+ const format = AGENT_SKILL_FORMATS[targetAgent];
17165
+ const enabledSkills = skills.filter((s) => s.enabled);
17166
+ if (enabledSkills.length === 0) {
17167
+ return "";
17168
+ }
17169
+ switch (format.configFormat) {
17170
+ case "xml":
17171
+ return generateXmlConfig(enabledSkills, format);
17172
+ case "mdc":
17173
+ return generateMdcConfig(enabledSkills, format);
17174
+ case "markdown-table":
17175
+ return generateMarkdownTableConfig(enabledSkills, format);
17176
+ case "json":
17177
+ return generateJsonConfig(enabledSkills, format);
17178
+ case "markdown":
17179
+ return generateMarkdownConfig(enabledSkills, format);
17180
+ default:
17181
+ return generateMarkdownConfig(enabledSkills, format);
17182
+ }
17183
+ }
17184
+ function generateXmlConfig(skills, format) {
17185
+ const skillsXml = skills.map((s) => `<skill>
17186
+ <name>${escapeXml(s.name)}</name>
17187
+ <description>${escapeXml(s.description)}</description>
17188
+ <location>${escapeXml(s.path)}</location>
17189
+ </skill>`).join("\n\n");
17190
+ return `<skills_system priority="1">
17191
+
17192
+ ## Available Skills
17193
+
17194
+ <!-- SKILLS_TABLE_START -->
17195
+ <usage>
17196
+ 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.
17197
+
17198
+ How to use skills:
17199
+ - Invoke: \`${format.invokeCommand} <skill-name>\` or \`npx ${format.invokeCommand} <skill-name>\`
17200
+ - The skill content will load with detailed instructions on how to complete the task
17201
+ - Base directory provided in output for resolving bundled resources (references/, scripts/, assets/)
17202
+
17203
+ Usage notes:
17204
+ - Only use skills listed in <available_skills> below
17205
+ - Do not invoke a skill that is already loaded in your context
17206
+ - Each skill invocation is stateless
17207
+ </usage>
17208
+
17209
+ <available_skills>
17210
+
17211
+ ${skillsXml}
17212
+
17213
+ </available_skills>
17214
+ <!-- SKILLS_TABLE_END -->
17215
+
17216
+ </skills_system>`;
17217
+ }
17218
+ function generateMdcConfig(skills, format) {
17219
+ const skillsList = skills.map((s) => `- **${s.name}**: ${s.description}`).join("\n");
17220
+ const skillsXml = skills.map((s) => `<skill>
17221
+ <name>${escapeXml(s.name)}</name>
17222
+ <description>${escapeXml(s.description)}</description>
17223
+ <location>${escapeXml(s.path)}</location>
17224
+ </skill>`).join("\n\n");
17225
+ return `---
17226
+ description: SkillKit skills integration - provides specialized capabilities and domain knowledge
17227
+ globs: "**/*"
17228
+ alwaysApply: true
17229
+ ---
17230
+ # Skills System
17231
+
17232
+ You have access to specialized skills that can help complete tasks. Use the skillkit CLI to load skill instructions when needed.
17233
+
17234
+ ## Available Skills
17235
+
17236
+ ${skillsList}
17237
+
17238
+ ## How to Use Skills
17239
+
17240
+ When a task matches a skill's description, load it with:
17241
+ \`\`\`bash
17242
+ ${format.invokeCommand} <skill-name>
17243
+ \`\`\`
17244
+
17245
+ The skill will provide detailed instructions for completing the task.
17246
+
17247
+ <!-- SKILLS_DATA_START -->
17248
+ ${skillsXml}
17249
+ <!-- SKILLS_DATA_END -->
17250
+ `;
17251
+ }
17252
+ function generateMarkdownTableConfig(skills, format) {
17253
+ const skillsList = skills.map((s) => `| ${s.name} | ${s.description} | \`${format.invokeCommand} ${s.name}\` |`).join("\n");
17254
+ return `# Skills
17255
+
17256
+ You have access to specialized skills for completing complex tasks.
17257
+
17258
+ | Skill | Description | Command |
17259
+ |-------|-------------|---------|
17260
+ ${skillsList}
17261
+
17262
+ ## Usage
17263
+
17264
+ When a task matches a skill's capability, run the command to load detailed instructions:
17265
+
17266
+ \`\`\`bash
17267
+ ${format.invokeCommand} <skill-name>
17268
+ \`\`\`
17269
+
17270
+ Skills are loaded on-demand to keep context clean. Only load skills when relevant to the current task.
17271
+ `;
17272
+ }
17273
+ function generateJsonConfig(skills, format) {
17274
+ const skillsJson = skills.map((s) => ({
17275
+ name: s.name,
17276
+ description: s.description,
17277
+ invoke: `${format.invokeCommand} ${s.name}`,
17278
+ location: s.path
17279
+ }));
17280
+ return `# Skills Configuration
17281
+
17282
+ You have access to specialized skills that extend your capabilities.
17283
+
17284
+ ## Available Skills
17285
+
17286
+ ${skills.map((s) => `### ${s.name}
17287
+ ${s.description}
17288
+
17289
+ Invoke: \`${format.invokeCommand} ${s.name}\``).join("\n\n")}
17290
+
17291
+ ## Skills Data
17292
+
17293
+ \`\`\`json
17294
+ ${JSON.stringify(skillsJson, null, 2)}
17295
+ \`\`\`
17296
+
17297
+ ## Usage Instructions
17298
+
17299
+ 1. When a task matches a skill's description, load it using the invoke command
17300
+ 2. Skills provide step-by-step instructions for complex tasks
17301
+ 3. Each skill is self-contained with its own resources
17302
+ `;
17303
+ }
17304
+ function generateMarkdownConfig(skills, format) {
17305
+ const skillsList = skills.map((s) => `### ${s.name}
17306
+
17307
+ ${s.description}
17308
+
17309
+ **Invoke:** \`${format.invokeCommand} ${s.name}\``).join("\n\n");
17310
+ return `# Skills System
17311
+
17312
+ You have access to specialized skills that can help complete tasks.
17313
+
17314
+ ## Available Skills
17315
+
17316
+ ${skillsList}
17317
+
17318
+ ## How to Use Skills
17319
+
17320
+ When a task matches a skill's description, load it:
17321
+
17322
+ \`\`\`bash
17323
+ ${format.invokeCommand} <skill-name>
17324
+ \`\`\`
17325
+
17326
+ Skills provide detailed instructions for completing complex tasks.
17327
+ `;
17328
+ }
17329
+ function escapeXml(text) {
17330
+ return text.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&apos;");
17331
+ }
17332
+ var getAgentSkillsDir = getSkillsDir;
17333
+ var getAgentConfigFile = getConfigFile;
16704
17334
  export {
16705
17335
  AGENT_CLI_CONFIGS,
17336
+ AGENT_CONFIG,
16706
17337
  AGENT_DISCOVERY_PATHS,
16707
17338
  AGENT_FORMAT_MAP,
17339
+ AGENT_SKILL_FORMATS,
16708
17340
  AIManager,
16709
17341
  AISearch,
16710
17342
  AISkillGenerator,
@@ -16858,19 +17490,27 @@ export {
16858
17490
  findSkill,
16859
17491
  formatSkillAsPrompt,
16860
17492
  fromCanonicalAgent,
17493
+ generateSkillsConfig,
16861
17494
  getAgentCLIConfig,
17495
+ getAgentConfigFile,
16862
17496
  getAgentConfigPath,
17497
+ getAgentDirectoryConfig,
16863
17498
  getAgentFilename,
16864
17499
  getAgentFormat,
17500
+ getAgentSkillsDir,
16865
17501
  getAgentStats,
16866
17502
  getAgentTargetDirectory,
16867
17503
  getAgentsDirectory,
16868
17504
  getAllProviders,
17505
+ getAllSkillsDirs,
16869
17506
  getAvailableCLIAgents,
16870
17507
  getBuiltinPacksDir,
16871
17508
  getCICDTemplate,
17509
+ getConfigFile,
17510
+ getConfigFormat,
16872
17511
  getExecutionStrategy,
16873
17512
  getGlobalConfigPath,
17513
+ getGlobalSkillsDir,
16874
17514
  getIndexStatus,
16875
17515
  getInstallDir,
16876
17516
  getManualExecutionInstructions,
@@ -16879,6 +17519,7 @@ export {
16879
17519
  getProjectConfigPath,
16880
17520
  getProvider,
16881
17521
  getSearchDirs,
17522
+ getSkillsDir,
16882
17523
  getStackTags,
16883
17524
  getSupportedTranslationAgents,
16884
17525
  getTechTags,
@@ -16911,6 +17552,8 @@ export {
16911
17552
  parseShorthand,
16912
17553
  parseSkill,
16913
17554
  parseSkillContent,
17555
+ parseSkillContentToCanonical,
17556
+ parseSkillToCanonical,
16914
17557
  parseSource,
16915
17558
  parseWorkflow,
16916
17559
  readAgentContent,
@@ -16924,6 +17567,7 @@ export {
16924
17567
  setSkillEnabled,
16925
17568
  shellExecutor,
16926
17569
  skillMdTranslator,
17570
+ supportsAutoDiscovery,
16927
17571
  supportsSlashCommands,
16928
17572
  syncToAgent,
16929
17573
  syncToAllAgents,
@@ -16934,6 +17578,8 @@ export {
16934
17578
  translateCanonicalAgent,
16935
17579
  translateSkill,
16936
17580
  translateSkillFile,
17581
+ translateSkillToAgent,
17582
+ translateSkillToAll,
16937
17583
  translatorRegistry,
16938
17584
  validateAgent,
16939
17585
  validateBuiltinPacks,
@@ -16944,6 +17590,7 @@ export {
16944
17590
  validateSkillContent,
16945
17591
  validateWorkflow,
16946
17592
  windsurfTranslator,
16947
- wrapProgressCallbackWithMemory
17593
+ wrapProgressCallbackWithMemory,
17594
+ writeTranslatedSkill
16948
17595
  };
16949
17596
  //# sourceMappingURL=index.js.map