pub trait FrameworkAdapter: Send + Sync {
Show 23 methods
// Required methods
fn name(&self) -> &'static str;
fn display_name(&self) -> &'static str;
fn project_config_path(&self) -> PathBuf;
fn user_config_path(&self) -> Option<PathBuf>;
fn generate_hooks_config(
&self,
enabled_events: &[EventType],
mi6_bin: &str,
otel_enabled: bool,
otel_port: u16,
) -> Value;
fn merge_config(&self, generated: Value, existing: Option<Value>) -> Value;
fn parse_hook_input(
&self,
event_type: &str,
stdin_json: &Value,
) -> ParsedHookInput;
fn map_event_type(&self, framework_event: &str) -> EventType;
fn supported_events(&self) -> Vec<&'static str>;
fn detection_env_vars(&self) -> &[&'static str];
fn is_installed(&self) -> bool;
fn remove_hooks(&self, existing: Value) -> Option<Value>;
fn resume_command(&self, session_id: &str) -> Option<String>;
// Provided methods
fn framework_specific_events(&self) -> Vec<&'static str> { ... }
fn config_format(&self) -> ConfigFormat { ... }
fn detect(&self) -> bool { ... }
fn otel_support(&self) -> OtelSupport { ... }
fn settings_path(
&self,
local: bool,
settings_local: bool,
) -> Result<PathBuf, InitError> { ... }
fn has_mi6_hooks(&self, local: bool, settings_local: bool) -> bool { ... }
fn install_hooks(
&self,
path: &Path,
hooks: &Value,
otel_env: Option<Value>,
remove_otel: bool,
) -> Result<InstallHooksResult, InitError> { ... }
fn serialize_config(&self, config: &Value) -> Result<String, InitError> { ... }
fn uninstall_hooks(
&self,
local: bool,
settings_local: bool,
) -> Result<UninstallHooksResult, InitError> { ... }
fn hook_response(&self, _event_type: &str) -> Option<&'static str> { ... }
}Expand description
Framework adapter trait for AI coding assistant integrations.
Implementations of this trait handle the platform-specific details of:
- Generating hook configuration files
- Parsing hook input from stdin
- Mapping platform events to canonical event types
Required Methods§
Sourcefn name(&self) -> &'static str
fn name(&self) -> &'static str
Framework identifier (e.g., “claude”, “cursor”, “gemini”, “opencode”).
Sourcefn display_name(&self) -> &'static str
fn display_name(&self) -> &'static str
Human-readable display name for the framework.
Sourcefn project_config_path(&self) -> PathBuf
fn project_config_path(&self) -> PathBuf
Config file path for project-level settings.
Returns the path relative to the project root where hooks should be installed.
Sourcefn user_config_path(&self) -> Option<PathBuf>
fn user_config_path(&self) -> Option<PathBuf>
Config file path for user-level settings.
Returns the absolute path to the user’s global settings file.
Sourcefn generate_hooks_config(
&self,
enabled_events: &[EventType],
mi6_bin: &str,
otel_enabled: bool,
otel_port: u16,
) -> Value
fn generate_hooks_config( &self, enabled_events: &[EventType], mi6_bin: &str, otel_enabled: bool, otel_port: u16, ) -> Value
Generate hook configuration JSON for this framework.
§Arguments
enabled_events- List of event types to enable hooks formi6_bin- Path to the mi6 binary (or “mi6” if in PATH)otel_enabled- Whether OpenTelemetry is enabledotel_port- Port for OTel server
§Returns
JSON value representing the hooks configuration for this framework.
Sourcefn parse_hook_input(
&self,
event_type: &str,
stdin_json: &Value,
) -> ParsedHookInput
fn parse_hook_input( &self, event_type: &str, stdin_json: &Value, ) -> ParsedHookInput
Sourcefn map_event_type(&self, framework_event: &str) -> EventType
fn map_event_type(&self, framework_event: &str) -> EventType
Sourcefn supported_events(&self) -> Vec<&'static str>
fn supported_events(&self) -> Vec<&'static str>
List of hook event types supported by this framework.
Sourcefn detection_env_vars(&self) -> &[&'static str]
fn detection_env_vars(&self) -> &[&'static str]
Environment variables that indicate this framework is the caller.
Sourcefn is_installed(&self) -> bool
fn is_installed(&self) -> bool
Check if this framework is installed on the system.
Returns true if the framework’s config directory exists or the framework’s CLI tool is in PATH.
Sourcefn remove_hooks(&self, existing: Value) -> Option<Value>
fn remove_hooks(&self, existing: Value) -> Option<Value>
Sourcefn resume_command(&self, session_id: &str) -> Option<String>
fn resume_command(&self, session_id: &str) -> Option<String>
Get the command to resume a session.
Returns the shell command to resume a session with the given session ID. This is framework-specific:
- Claude:
claude --resume <session_id> - Codex:
codex resume <session_id>
§Arguments
session_id- The session ID to resume
§Returns
Some(command) if the framework supports resume, None otherwise.
Provided Methods§
Sourcefn framework_specific_events(&self) -> Vec<&'static str>
fn framework_specific_events(&self) -> Vec<&'static str>
Framework-specific events that have no canonical equivalent.
These events are unique to this framework and will be configured
alongside canonical events. They are stored as Custom(name) EventType.
Override this method to add framework-specific events that don’t map to any canonical event type.
Sourcefn config_format(&self) -> ConfigFormat
fn config_format(&self) -> ConfigFormat
Configuration file format used by this framework.
Most frameworks use JSON, but some (like Codex) use TOML. Override this method if the framework uses a non-JSON format.
Sourcefn detect(&self) -> bool
fn detect(&self) -> bool
Detect if this framework is currently calling mi6.
Checks environment variables to determine if a hook from this framework is invoking mi6.
Sourcefn otel_support(&self) -> OtelSupport
fn otel_support(&self) -> OtelSupport
Check OpenTelemetry support status for this framework.
Returns:
OtelSupport::Enabledif OTEL is configured and enabledOtelSupport::Disabledif OTEL is supported but not enabledOtelSupport::Unsupportedif the framework doesn’t support OTEL
Sourcefn settings_path(
&self,
local: bool,
settings_local: bool,
) -> Result<PathBuf, InitError>
fn settings_path( &self, local: bool, settings_local: bool, ) -> Result<PathBuf, InitError>
Resolve the settings path for this framework.
Determines where the hooks configuration should be installed based on the user’s preferences (local vs global, settings_local).
§Arguments
local- If true, use project-level config instead of user-level.settings_local- If true, use a.localvariant (not committed to git).
Sourcefn has_mi6_hooks(&self, local: bool, settings_local: bool) -> bool
fn has_mi6_hooks(&self, local: bool, settings_local: bool) -> bool
Check if this framework has mi6 hooks active in its config file.
§Arguments
local- If true, check project-level config instead of user-level.settings_local- If true, check the.localvariant.
Sourcefn install_hooks(
&self,
path: &Path,
hooks: &Value,
otel_env: Option<Value>,
remove_otel: bool,
) -> Result<InstallHooksResult, InitError>
fn install_hooks( &self, path: &Path, hooks: &Value, otel_env: Option<Value>, remove_otel: bool, ) -> Result<InstallHooksResult, InitError>
Install hooks configuration to a settings file.
This method merges the new hooks configuration with any existing settings and writes the result to the specified path.
§Arguments
path- Path where settings should be written.hooks- The hooks configuration to install.otel_env- Optional OTel environment variables to add.remove_otel- Whether to remove existing OTel configuration.
§Returns
An InstallHooksResult containing any shell commands that were executed.
Sourcefn serialize_config(&self, config: &Value) -> Result<String, InitError>
fn serialize_config(&self, config: &Value) -> Result<String, InitError>
Serialize configuration to string in the appropriate format.
Returns the configuration as a string in either JSON or TOML format, depending on the framework’s configuration format.
Sourcefn uninstall_hooks(
&self,
local: bool,
settings_local: bool,
) -> Result<UninstallHooksResult, InitError>
fn uninstall_hooks( &self, local: bool, settings_local: bool, ) -> Result<UninstallHooksResult, InitError>
Uninstall mi6 hooks from this framework.
This method handles the complete removal of mi6 integration from the framework. For config-based frameworks, it removes mi6 hooks from the settings file. For plugin-based frameworks (like Claude Code), it removes the plugin directory.
§Arguments
local- If true, uninstall from project-level config instead of user-level.settings_local- If true, uninstall from the.localvariant.
§Returns
An UninstallHooksResult containing whether hooks were removed and
any shell commands that were executed, or an error if uninstallation failed.
Sourcefn hook_response(&self, _event_type: &str) -> Option<&'static str>
fn hook_response(&self, _event_type: &str) -> Option<&'static str>
Get the JSON response to write to stdout for blocking hooks.
Some frameworks (like Cursor) have blocking hooks that expect a JSON response to allow/deny the operation. This method returns the appropriate response for the given event type.
§Arguments
event_type- The framework-specific event type string
§Returns
Some(response) if this event expects a response, None for observation-only hooks.
§Example
For Cursor’s beforeShellExecution, returns {"permission":"allow"} to allow
the shell command to proceed.