Add droid and cursor sync targets, extract shared path helpers

- Add sync --target droid (skills to ~/.factory/skills/)
- Add sync --target cursor (skills + MCP to .cursor/)
- Extract expandHome/resolveTargetHome to src/utils/resolve-home.ts
- Remove duplicated path helpers from convert.ts and install.ts
- Bump version to 0.6.0

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Kieran Klaassen
2026-02-12 20:37:15 -08:00
parent 84af459c79
commit e41904a569
10 changed files with 322 additions and 95 deletions

92
tests/sync-cursor.test.ts Normal file
View File

@@ -0,0 +1,92 @@
import { describe, expect, test } from "bun:test"
import { promises as fs } from "fs"
import path from "path"
import os from "os"
import { syncToCursor } from "../src/sync/cursor"
import type { ClaudeHomeConfig } from "../src/parsers/claude-home"
describe("syncToCursor", () => {
test("symlinks skills and writes mcp.json", async () => {
const tempRoot = await fs.mkdtemp(path.join(os.tmpdir(), "sync-cursor-"))
const fixtureSkillDir = path.join(import.meta.dir, "fixtures", "sample-plugin", "skills", "skill-one")
const config: ClaudeHomeConfig = {
skills: [
{
name: "skill-one",
sourceDir: fixtureSkillDir,
skillPath: path.join(fixtureSkillDir, "SKILL.md"),
},
],
mcpServers: {
context7: { url: "https://mcp.context7.com/mcp" },
local: { command: "echo", args: ["hello"], env: { FOO: "bar" } },
},
}
await syncToCursor(config, tempRoot)
// Check skill symlink
const linkedSkillPath = path.join(tempRoot, "skills", "skill-one")
const linkedStat = await fs.lstat(linkedSkillPath)
expect(linkedStat.isSymbolicLink()).toBe(true)
// Check mcp.json
const mcpPath = path.join(tempRoot, "mcp.json")
const mcpConfig = JSON.parse(await fs.readFile(mcpPath, "utf8")) as {
mcpServers: Record<string, { url?: string; command?: string; args?: string[]; env?: Record<string, string> }>
}
expect(mcpConfig.mcpServers.context7?.url).toBe("https://mcp.context7.com/mcp")
expect(mcpConfig.mcpServers.local?.command).toBe("echo")
expect(mcpConfig.mcpServers.local?.args).toEqual(["hello"])
expect(mcpConfig.mcpServers.local?.env).toEqual({ FOO: "bar" })
})
test("merges existing mcp.json", async () => {
const tempRoot = await fs.mkdtemp(path.join(os.tmpdir(), "sync-cursor-merge-"))
const mcpPath = path.join(tempRoot, "mcp.json")
await fs.writeFile(
mcpPath,
JSON.stringify({ mcpServers: { existing: { command: "node", args: ["server.js"] } } }, null, 2),
)
const config: ClaudeHomeConfig = {
skills: [],
mcpServers: {
context7: { url: "https://mcp.context7.com/mcp" },
},
}
await syncToCursor(config, tempRoot)
const merged = JSON.parse(await fs.readFile(mcpPath, "utf8")) as {
mcpServers: Record<string, { command?: string; url?: string }>
}
expect(merged.mcpServers.existing?.command).toBe("node")
expect(merged.mcpServers.context7?.url).toBe("https://mcp.context7.com/mcp")
})
test("does not write mcp.json when no MCP servers", async () => {
const tempRoot = await fs.mkdtemp(path.join(os.tmpdir(), "sync-cursor-nomcp-"))
const fixtureSkillDir = path.join(import.meta.dir, "fixtures", "sample-plugin", "skills", "skill-one")
const config: ClaudeHomeConfig = {
skills: [
{
name: "skill-one",
sourceDir: fixtureSkillDir,
skillPath: path.join(fixtureSkillDir, "SKILL.md"),
},
],
mcpServers: {},
}
await syncToCursor(config, tempRoot)
const mcpExists = await fs.access(path.join(tempRoot, "mcp.json")).then(() => true).catch(() => false)
expect(mcpExists).toBe(false)
})
})

57
tests/sync-droid.test.ts Normal file
View File

@@ -0,0 +1,57 @@
import { describe, expect, test } from "bun:test"
import { promises as fs } from "fs"
import path from "path"
import os from "os"
import { syncToDroid } from "../src/sync/droid"
import type { ClaudeHomeConfig } from "../src/parsers/claude-home"
describe("syncToDroid", () => {
test("symlinks skills to factory skills dir", async () => {
const tempRoot = await fs.mkdtemp(path.join(os.tmpdir(), "sync-droid-"))
const fixtureSkillDir = path.join(import.meta.dir, "fixtures", "sample-plugin", "skills", "skill-one")
const config: ClaudeHomeConfig = {
skills: [
{
name: "skill-one",
sourceDir: fixtureSkillDir,
skillPath: path.join(fixtureSkillDir, "SKILL.md"),
},
],
mcpServers: {
context7: { url: "https://mcp.context7.com/mcp" },
},
}
await syncToDroid(config, tempRoot)
const linkedSkillPath = path.join(tempRoot, "skills", "skill-one")
const linkedStat = await fs.lstat(linkedSkillPath)
expect(linkedStat.isSymbolicLink()).toBe(true)
// Droid does not write MCP config
const mcpExists = await fs.access(path.join(tempRoot, "mcp.json")).then(() => true).catch(() => false)
expect(mcpExists).toBe(false)
})
test("skips skills with invalid names", async () => {
const tempRoot = await fs.mkdtemp(path.join(os.tmpdir(), "sync-droid-invalid-"))
const fixtureSkillDir = path.join(import.meta.dir, "fixtures", "sample-plugin", "skills", "skill-one")
const config: ClaudeHomeConfig = {
skills: [
{
name: "../escape",
sourceDir: fixtureSkillDir,
skillPath: path.join(fixtureSkillDir, "SKILL.md"),
},
],
mcpServers: {},
}
await syncToDroid(config, tempRoot)
const entries = await fs.readdir(path.join(tempRoot, "skills"))
expect(entries).toHaveLength(0)
})
})