From ca682136646843cfbe29db8376cb199c9eb27ba6 Mon Sep 17 00:00:00 2001 From: Viktorplus <36795799+viktorplus@users.noreply.github.com> Date: Sat, 6 Jun 2026 13:50:58 +0200 Subject: [PATCH] feat(02-01): implement Kimi skill converter - Export convertClaudeCommandToKimiSkill from install.js - Emit Kimi-safe SKILL.md frontmatter - Rewrite GSD command references to /skill:gsd-* --- bin/install.js | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/bin/install.js b/bin/install.js index 2cc6a09b2..7e560cae5 100755 --- a/bin/install.js +++ b/bin/install.js @@ -2141,6 +2141,47 @@ function convertClaudeCommandToClaudeSkill(content, skillName, runtime = null, c return `${fm}\n${normalizedBody}`; } +function escapeRegExp(value) { + return String(value).replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); +} + +function normalizeKimiSkillName(skillName) { + let text = String(skillName || '').trim().toLowerCase(); + if (text.startsWith('/')) text = text.slice(1); + if (text.startsWith('$')) text = text.slice(1); + text = text.replace(/^gsd:/, 'gsd-'); + if (!text.startsWith('gsd-')) text = `gsd-${text}`; + text = text.replace(/[^a-z0-9-]+/g, '-').replace(/-+/g, '-').replace(/^-|-$/g, ''); + return text || 'gsd-command'; +} + +function convertGsdCommandReferencesToKimiSkillInvocations(content, cmdNames) { + if (!Array.isArray(cmdNames) || cmdNames.length === 0) return content; + const commands = [...cmdNames].sort((a, b) => b.length - a.length).map(escapeRegExp); + const commandGroup = commands.join('|'); + const colonPattern = new RegExp(`(? `/skill:gsd-${cmd}`) + .replace(hyphenPattern, (_, cmd) => `/skill:gsd-${cmd}`); +} + +function convertClaudeCommandToKimiSkill(content, skillName, _runtime = null, cmdNames = null) { + const { frontmatter, body } = extractFrontmatterAndBody(content); + const kimiSkillName = normalizeKimiSkillName(skillName); + const names = cmdNames || readGsdCommandNames(); + const description = frontmatter + ? extractFrontmatterField(frontmatter, 'description') || `Run GSD workflow ${kimiSkillName}.` + : `Run GSD workflow ${kimiSkillName}.`; + const normalizedBody = convertGsdCommandReferencesToKimiSkillInvocations( + frontmatter ? body : content, + names + ); + + return `---\nname: ${kimiSkillName}\ndescription: ${yamlQuote(toSingleLine(description))}\n---\n${normalizedBody}`; +} + /** * Convert a Claude agent (.md) to a Copilot agent (.agent.md). * Applies tool mapping + deduplication, formats tools as JSON array. @@ -10979,6 +11020,7 @@ module.exports = { installAllRuntimes, uninstall, convertClaudeCommandToCodexSkill, + convertClaudeCommandToKimiSkill, convertClaudeToOpencodeFrontmatter, convertClaudeToKiloFrontmatter, configureOpencodePermissions,