feat: Add GitHub Copilot converter target

Add Copilot as the 6th converter target, transforming Claude Code plugins
into Copilot's native format: custom agents (.agent.md), agent skills
(SKILL.md), and MCP server configuration JSON.

Component mapping:
- Agents → .github/agents/{name}.agent.md (with Copilot frontmatter)
- Commands → .github/skills/{name}/SKILL.md
- Skills → .github/skills/{name}/ (copied as-is)
- MCP servers → .github/copilot-mcp-config.json
- Hooks → skipped with warning

Also adds `compound sync copilot` support and fixes YAML quoting for
the `*` character in frontmatter serialization.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Brayan Jules
2026-02-15 00:14:40 -03:00
parent 134a994c08
commit 4f7c598f27
15 changed files with 1765 additions and 6 deletions

48
src/targets/copilot.ts Normal file
View File

@@ -0,0 +1,48 @@
import path from "path"
import { backupFile, copyDir, ensureDir, writeJson, writeText } from "../utils/files"
import type { CopilotBundle } from "../types/copilot"
export async function writeCopilotBundle(outputRoot: string, bundle: CopilotBundle): Promise<void> {
const paths = resolveCopilotPaths(outputRoot)
await ensureDir(paths.githubDir)
if (bundle.agents.length > 0) {
const agentsDir = path.join(paths.githubDir, "agents")
for (const agent of bundle.agents) {
await writeText(path.join(agentsDir, `${agent.name}.agent.md`), agent.content + "\n")
}
}
if (bundle.generatedSkills.length > 0) {
const skillsDir = path.join(paths.githubDir, "skills")
for (const skill of bundle.generatedSkills) {
await writeText(path.join(skillsDir, skill.name, "SKILL.md"), skill.content + "\n")
}
}
if (bundle.skillDirs.length > 0) {
const skillsDir = path.join(paths.githubDir, "skills")
for (const skill of bundle.skillDirs) {
await copyDir(skill.sourceDir, path.join(skillsDir, skill.name))
}
}
if (bundle.mcpConfig && Object.keys(bundle.mcpConfig).length > 0) {
const mcpPath = path.join(paths.githubDir, "copilot-mcp-config.json")
const backupPath = await backupFile(mcpPath)
if (backupPath) {
console.log(`Backed up existing copilot-mcp-config.json to ${backupPath}`)
}
await writeJson(mcpPath, { mcpServers: bundle.mcpConfig })
}
}
function resolveCopilotPaths(outputRoot: string) {
const base = path.basename(outputRoot)
// If already pointing at .github, write directly into it
if (base === ".github") {
return { githubDir: outputRoot }
}
// Otherwise nest under .github
return { githubDir: path.join(outputRoot, ".github") }
}

View File

@@ -4,16 +4,19 @@ import type { CodexBundle } from "../types/codex"
import type { DroidBundle } from "../types/droid"
import type { CursorBundle } from "../types/cursor"
import type { PiBundle } from "../types/pi"
import type { CopilotBundle } from "../types/copilot"
import { convertClaudeToOpenCode, type ClaudeToOpenCodeOptions } from "../converters/claude-to-opencode"
import { convertClaudeToCodex } from "../converters/claude-to-codex"
import { convertClaudeToDroid } from "../converters/claude-to-droid"
import { convertClaudeToCursor } from "../converters/claude-to-cursor"
import { convertClaudeToPi } from "../converters/claude-to-pi"
import { convertClaudeToCopilot } from "../converters/claude-to-copilot"
import { writeOpenCodeBundle } from "./opencode"
import { writeCodexBundle } from "./codex"
import { writeDroidBundle } from "./droid"
import { writeCursorBundle } from "./cursor"
import { writePiBundle } from "./pi"
import { writeCopilotBundle } from "./copilot"
export type TargetHandler<TBundle = unknown> = {
name: string
@@ -53,4 +56,10 @@ export const targets: Record<string, TargetHandler> = {
convert: convertClaudeToPi as TargetHandler<PiBundle>["convert"],
write: writePiBundle as TargetHandler<PiBundle>["write"],
},
copilot: {
name: "copilot",
implemented: true,
convert: convertClaudeToCopilot as TargetHandler<CopilotBundle>["convert"],
write: writeCopilotBundle as TargetHandler<CopilotBundle>["write"],
},
}