Skip to main content

AgentSurface

Trait AgentSurface 

Source
pub trait AgentSurface: Send + Sync {
    // Required methods
    fn agent_id(&self) -> &'static str;
    fn detect(&self, repo_root: &Path) -> bool;
    fn install(
        &self,
        ctx: &InstallContext,
    ) -> Result<InstallReport, InstallError>;
    fn uninstall(
        &self,
        repo_root: &Path,
        dry_run: bool,
    ) -> Result<Vec<PathBuf>, InstallError>;
    fn render_hook_script(&self, ctx: &InstallContext) -> String;
    fn hook_path(&self, repo_root: &Path) -> PathBuf;
    fn settings_path(&self, repo_root: &Path) -> PathBuf;
}
Expand description

Object-safe trait. The surface registry stores impls as Box<dyn AgentSurface>; built-in surfaces (Claude in v0.1, Codex in v0.2, etc.) are registered statically, and v0.3 subprocess plugins add dynamic registrations at startup.

Required Methods§

Source

fn agent_id(&self) -> &'static str

Stable agent identifier (e.g. "claude_code", "codex").

Source

fn detect(&self, repo_root: &Path) -> bool

Auto-detect whether this surface is relevant to the given repo (e.g. presence of .claude/ for Claude Code, AGENTS.md for Codex). klasp install --force overrides a false here.

Source

fn install(&self, ctx: &InstallContext) -> Result<InstallReport, InstallError>

Perform the install. Must be idempotent: running twice with the same input yields the same on-disk state and returns already_installed = true on the second run.

Source

fn uninstall( &self, repo_root: &Path, dry_run: bool, ) -> Result<Vec<PathBuf>, InstallError>

Remove klasp’s managed entries. Returns the list of paths that were (or would be, in dry_run) modified. Sibling hooks must be preserved.

Source

fn render_hook_script(&self, ctx: &InstallContext) -> String

Render the hook-script content this surface would write. Pure — no filesystem access. Used by install and by --dry-run.

Source

fn hook_path(&self, repo_root: &Path) -> PathBuf

Path to the hook-script file this surface owns.

Source

fn settings_path(&self, repo_root: &Path) -> PathBuf

Path to the agent’s settings/config file this surface mutates.

Implementors§