agent-migrate-adapters 0.6.1

Codex, Pi, and Claude Code configuration adapters for agent-migrate
Documentation
use std::path::{Path, PathBuf};

use agent_migrate_core::{ManifestIdentity, Scope};

#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ScanContext {
    home: PathBuf,
    scope: Scope,
    workspace: Option<PathBuf>,
}

impl ScanContext {
    #[must_use]
    pub fn new(home: PathBuf, scope: Scope, workspace: Option<PathBuf>) -> Self {
        Self {
            home,
            scope,
            workspace,
        }
    }

    #[must_use]
    pub fn global(home: &Path) -> Self {
        Self::new(home.to_path_buf(), Scope::Global, None)
    }

    #[must_use]
    pub fn project(home: &Path, workspace: &Path) -> Self {
        Self::new(
            home.to_path_buf(),
            Scope::Project,
            Some(workspace.to_path_buf()),
        )
    }

    #[must_use]
    pub fn home(&self) -> &Path {
        &self.home
    }

    #[must_use]
    pub const fn scope(&self) -> Scope {
        self.scope
    }

    #[must_use]
    pub fn workspace(&self) -> Option<&Path> {
        self.workspace.as_deref()
    }
}

#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ExportContext {
    scan: ScanContext,
    agent_version: String,
    identity: ManifestIdentity,
}

impl ExportContext {
    #[must_use]
    pub fn new(
        scan: ScanContext,
        agent_version: impl Into<String>,
        identity: ManifestIdentity,
    ) -> Self {
        Self {
            scan,
            agent_version: agent_version.into(),
            identity,
        }
    }

    #[must_use]
    pub const fn scan(&self) -> &ScanContext {
        &self.scan
    }

    #[must_use]
    pub fn agent_version(&self) -> &str {
        &self.agent_version
    }

    #[must_use]
    pub const fn identity(&self) -> ManifestIdentity {
        self.identity
    }
}