FrameworkAdapter

Trait FrameworkAdapter 

Source
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§

Source

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

Framework identifier (e.g., “claude”, “cursor”, “gemini”, “opencode”).

Source

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

Human-readable display name for the framework.

Source

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.

Source

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.

Source

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 for
  • mi6_bin - Path to the mi6 binary (or “mi6” if in PATH)
  • otel_enabled - Whether OpenTelemetry is enabled
  • otel_port - Port for OTel server
§Returns

JSON value representing the hooks configuration for this framework.

Source

fn merge_config(&self, generated: Value, existing: Option<Value>) -> Value

Merge generated hooks into existing settings.

§Arguments
  • generated - The generated hooks configuration
  • existing - The existing settings file content (if any)
§Returns

The merged settings JSON.

Source

fn parse_hook_input( &self, event_type: &str, stdin_json: &Value, ) -> ParsedHookInput

Parse hook input JSON from stdin into canonical fields.

§Arguments
  • event_type - The framework-specific event type string
  • stdin_json - Raw JSON from stdin
§Returns

Parsed hook data with normalized fields.

Source

fn map_event_type(&self, framework_event: &str) -> EventType

Map a framework-specific event type to a canonical EventType.

§Arguments
  • framework_event - The event type string from the framework
§Returns

The corresponding canonical EventType.

Source

fn supported_events(&self) -> Vec<&'static str>

List of hook event types supported by this framework.

Source

fn detection_env_vars(&self) -> &[&'static str]

Environment variables that indicate this framework is the caller.

Source

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.

Source

fn remove_hooks(&self, existing: Value) -> Option<Value>

Remove mi6 hooks from the framework’s settings.

Returns the modified settings with mi6 hooks removed, or None if there are no mi6 hooks to remove.

§Arguments
  • existing - The existing settings file content
§Returns

Some(modified settings) if hooks were removed, None if no mi6 hooks found.

Source

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§

Source

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.

Source

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.

Source

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.

Source

fn otel_support(&self) -> OtelSupport

Check OpenTelemetry support status for this framework.

Returns:

Source

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 .local variant (not committed to git).
Source

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 .local variant.
Source

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.

Source

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.

Source

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 .local variant.
§Returns

An UninstallHooksResult containing whether hooks were removed and any shell commands that were executed, or an error if uninstallation failed.

Source

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.

Implementors§