feat: add first-class pi target with mcporter/subagent compatibility
This commit is contained in:
@@ -4,9 +4,10 @@ import path from "path"
|
||||
import { loadClaudeHome } from "../parsers/claude-home"
|
||||
import { syncToOpenCode } from "../sync/opencode"
|
||||
import { syncToCodex } from "../sync/codex"
|
||||
import { syncToPi } from "../sync/pi"
|
||||
|
||||
function isValidTarget(value: string): value is "opencode" | "codex" {
|
||||
return value === "opencode" || value === "codex"
|
||||
function isValidTarget(value: string): value is "opencode" | "codex" | "pi" {
|
||||
return value === "opencode" || value === "codex" || value === "pi"
|
||||
}
|
||||
|
||||
/** Check if any MCP servers have env vars that might contain secrets */
|
||||
@@ -26,13 +27,13 @@ function hasPotentialSecrets(mcpServers: Record<string, unknown>): boolean {
|
||||
export default defineCommand({
|
||||
meta: {
|
||||
name: "sync",
|
||||
description: "Sync Claude Code config (~/.claude/) to OpenCode or Codex",
|
||||
description: "Sync Claude Code config (~/.claude/) to OpenCode, Codex, or Pi",
|
||||
},
|
||||
args: {
|
||||
target: {
|
||||
type: "string",
|
||||
required: true,
|
||||
description: "Target: opencode | codex",
|
||||
description: "Target: opencode | codex | pi",
|
||||
},
|
||||
claudeHome: {
|
||||
type: "string",
|
||||
@@ -42,7 +43,7 @@ export default defineCommand({
|
||||
},
|
||||
async run({ args }) {
|
||||
if (!isValidTarget(args.target)) {
|
||||
throw new Error(`Unknown target: ${args.target}. Use 'opencode' or 'codex'.`)
|
||||
throw new Error(`Unknown target: ${args.target}. Use 'opencode', 'codex', or 'pi'.`)
|
||||
}
|
||||
|
||||
const claudeHome = expandHome(args.claudeHome ?? path.join(os.homedir(), ".claude"))
|
||||
@@ -63,12 +64,16 @@ export default defineCommand({
|
||||
const outputRoot =
|
||||
args.target === "opencode"
|
||||
? path.join(os.homedir(), ".config", "opencode")
|
||||
: path.join(os.homedir(), ".codex")
|
||||
: args.target === "codex"
|
||||
? path.join(os.homedir(), ".codex")
|
||||
: path.join(os.homedir(), ".pi", "agent")
|
||||
|
||||
if (args.target === "opencode") {
|
||||
await syncToOpenCode(config, outputRoot)
|
||||
} else {
|
||||
} else if (args.target === "codex") {
|
||||
await syncToCodex(config, outputRoot)
|
||||
} else {
|
||||
await syncToPi(config, outputRoot)
|
||||
}
|
||||
|
||||
console.log(`✓ Synced to ${args.target}: ${outputRoot}`)
|
||||
|
||||
Reference in New Issue
Block a user