agent-migrate-adapters 0.6.1

Codex, Pi, and Claude Code configuration adapters for agent-migrate
Documentation
use agent_migrate_core::{AgentKind, FileKind, Scope};

use crate::ResourceClass;

#[derive(Debug, Clone, Copy)]
pub(crate) struct Candidate {
    pub path: &'static str,
    pub class: ResourceClass,
    pub kind: Option<FileKind>,
    pub tree: bool,
}

impl Candidate {
    const fn file(path: &'static str, kind: FileKind) -> Self {
        Self {
            path,
            class: ResourceClass::Migratable,
            kind: Some(kind),
            tree: false,
        }
    }

    const fn tree(path: &'static str, kind: FileKind) -> Self {
        Self {
            path,
            class: ResourceClass::Migratable,
            kind: Some(kind),
            tree: true,
        }
    }

    const fn excluded(path: &'static str) -> Self {
        Self {
            path,
            class: ResourceClass::Excluded,
            kind: None,
            tree: false,
        }
    }

    const fn metadata(path: &'static str) -> Self {
        Self {
            path,
            class: ResourceClass::MetadataOnly,
            kind: None,
            tree: false,
        }
    }
}

pub(crate) fn candidates(agent: AgentKind, scope: Scope) -> &'static [Candidate] {
    match (agent, scope) {
        (AgentKind::Codex, Scope::Global) => CODEX_GLOBAL,
        (AgentKind::Codex, Scope::Project) => CODEX_PROJECT,
        (AgentKind::Pi, Scope::Global) => PI_GLOBAL,
        (AgentKind::Pi, Scope::Project) => PI_PROJECT,
        (AgentKind::Claude, Scope::Global) => CLAUDE_GLOBAL,
        (AgentKind::Claude, Scope::Project) => CLAUDE_PROJECT,
    }
}

const CODEX_GLOBAL: &[Candidate] = &[
    Candidate::file(".codex/config.toml", FileKind::Settings),
    Candidate::file(".codex/AGENTS.md", FileKind::Instructions),
    Candidate::tree(".codex/skills", FileKind::Skill),
    Candidate::tree(".codex/agents", FileKind::Agent),
    Candidate::tree(".codex/rules", FileKind::Passthrough),
    Candidate::file(".codex/hooks.json", FileKind::Hook),
    Candidate::metadata(".codex/version.json"),
    Candidate::metadata(".codex/plugins"),
    Candidate::excluded(".codex/auth.json"),
    Candidate::excluded(".codex/history.jsonl"),
    Candidate::excluded(".codex/logs_2.sqlite"),
    Candidate::excluded(".codex/state_5.sqlite"),
    Candidate::excluded(".codex/sessions"),
];

const CODEX_PROJECT: &[Candidate] = &[
    Candidate::file("AGENTS.md", FileKind::Instructions),
    Candidate::file(".codex/config.toml", FileKind::Settings),
    Candidate::tree(".codex/skills", FileKind::Skill),
    Candidate::tree(".agents/skills", FileKind::Skill),
];

const PI_GLOBAL: &[Candidate] = &[
    Candidate::file(".pi/agent/settings.json", FileKind::Settings),
    Candidate::file(".pi/agent/models.json", FileKind::Settings),
    Candidate::file(".pi/agent/AGENTS.md", FileKind::Instructions),
    Candidate::tree(".pi/agent/skills", FileKind::Skill),
    Candidate::tree(".pi/agent/prompts", FileKind::Command),
    Candidate::tree(".pi/agent/extensions", FileKind::Passthrough),
    Candidate::tree(".pi/agent/packages", FileKind::Passthrough),
    Candidate::excluded(".pi/agent/auth.json"),
    Candidate::excluded(".pi/agent/sessions"),
    Candidate::excluded(".pi/agent/pi-subagents-state"),
    Candidate::excluded(".pi/agent/pi-cache-optimizer-stats.json"),
];

const PI_PROJECT: &[Candidate] = &[
    Candidate::file("AGENTS.md", FileKind::Instructions),
    Candidate::file(".pi/settings.json", FileKind::Settings),
    Candidate::tree(".pi/skills", FileKind::Skill),
    Candidate::tree(".pi/prompts", FileKind::Command),
];

const CLAUDE_GLOBAL: &[Candidate] = &[
    Candidate::file(".claude/settings.json", FileKind::Settings),
    Candidate::file(".claude.json", FileKind::Settings),
    Candidate::file(".claude/CLAUDE.md", FileKind::Instructions),
    Candidate::tree(".claude/skills", FileKind::Skill),
    Candidate::tree(".claude/commands", FileKind::Command),
    Candidate::tree(".claude/agents", FileKind::Agent),
    Candidate::metadata(".claude/plugins/known_marketplaces.json"),
    Candidate::excluded(".claude/history.jsonl"),
    Candidate::excluded(".claude/cache"),
    Candidate::excluded(".claude/telemetry"),
    Candidate::excluded(".claude/daemon"),
    Candidate::excluded(".claude/backups"),
];

const CLAUDE_PROJECT: &[Candidate] = &[
    Candidate::file("CLAUDE.md", FileKind::Instructions),
    Candidate::file(".claude/settings.json", FileKind::Settings),
    Candidate::tree(".claude/skills", FileKind::Skill),
    Candidate::tree(".claude/commands", FileKind::Command),
    Candidate::tree(".claude/agents", FileKind::Agent),
    Candidate::file(".mcp.json", FileKind::Mcp),
];