Add Factory Droid as a converter target (#174)

Adds a new 'droid' target to the converter that outputs Claude Code plugins
in Factory Droid's format:

- Commands flattened to ~/.factory/commands/ (strips namespace prefixes)
- Agents converted to droids in ~/.factory/droids/ with proper frontmatter
- Skills copied to ~/.factory/skills/
- Content transforms: Task calls, slash commands, and @agent references
  adapted to Droid conventions

This resolves the manual workaround described in issue #31 by automating
the conversion from Claude Code plugin format to Factory Droid's expected
directory structure.

Includes 13 tests covering converter logic and file writer behavior.

Co-authored-by: adamprime <adamprime@hey.com>
Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
This commit is contained in:
Adam Tervort
2026-02-11 11:48:13 -06:00
committed by GitHub
parent e8f3bbcb35
commit 4ab08dce78
8 changed files with 648 additions and 10 deletions

50
src/targets/droid.ts Normal file
View File

@@ -0,0 +1,50 @@
import path from "path"
import { copyDir, ensureDir, writeText } from "../utils/files"
import type { DroidBundle } from "../types/droid"
export async function writeDroidBundle(outputRoot: string, bundle: DroidBundle): Promise<void> {
const paths = resolveDroidPaths(outputRoot)
await ensureDir(paths.root)
if (bundle.commands.length > 0) {
await ensureDir(paths.commandsDir)
for (const command of bundle.commands) {
await writeText(path.join(paths.commandsDir, `${command.name}.md`), command.content + "\n")
}
}
if (bundle.droids.length > 0) {
await ensureDir(paths.droidsDir)
for (const droid of bundle.droids) {
await writeText(path.join(paths.droidsDir, `${droid.name}.md`), droid.content + "\n")
}
}
if (bundle.skillDirs.length > 0) {
await ensureDir(paths.skillsDir)
for (const skill of bundle.skillDirs) {
await copyDir(skill.sourceDir, path.join(paths.skillsDir, skill.name))
}
}
}
function resolveDroidPaths(outputRoot: string) {
const base = path.basename(outputRoot)
// If pointing directly at ~/.factory or .factory, write into it
if (base === ".factory") {
return {
root: outputRoot,
commandsDir: path.join(outputRoot, "commands"),
droidsDir: path.join(outputRoot, "droids"),
skillsDir: path.join(outputRoot, "skills"),
}
}
// Otherwise nest under .factory
return {
root: outputRoot,
commandsDir: path.join(outputRoot, ".factory", "commands"),
droidsDir: path.join(outputRoot, ".factory", "droids"),
skillsDir: path.join(outputRoot, ".factory", "skills"),
}
}

View File

@@ -1,10 +1,13 @@
import type { ClaudePlugin } from "../types/claude"
import type { OpenCodeBundle } from "../types/opencode"
import type { CodexBundle } from "../types/codex"
import type { DroidBundle } from "../types/droid"
import { convertClaudeToOpenCode, type ClaudeToOpenCodeOptions } from "../converters/claude-to-opencode"
import { convertClaudeToCodex } from "../converters/claude-to-codex"
import { convertClaudeToDroid } from "../converters/claude-to-droid"
import { writeOpenCodeBundle } from "./opencode"
import { writeCodexBundle } from "./codex"
import { writeDroidBundle } from "./droid"
export type TargetHandler<TBundle = unknown> = {
name: string
@@ -26,4 +29,10 @@ export const targets: Record<string, TargetHandler> = {
convert: convertClaudeToCodex as TargetHandler<CodexBundle>["convert"],
write: writeCodexBundle as TargetHandler<CodexBundle>["write"],
},
droid: {
name: "droid",
implemented: true,
convert: convertClaudeToDroid as TargetHandler<DroidBundle>["convert"],
write: writeDroidBundle as TargetHandler<DroidBundle>["write"],
},
}