Skip to main content

OpenCode

Struct OpenCode 

Source
pub struct OpenCode;

Trait Implementations§

Source§

impl AgentAdapter for OpenCode

Source§

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

MCP servers join the policy rules in .opencode/opencode.json, which OpenCode merges over the project’s opencode.json, so the project’s own file is never edited.

Source§

fn mcp_env_reference(&self, var: &str) -> String

OpenCode expands {env:VAR} in its config.

Source§

fn mcp_server_entry(&self, server: &McpServerConfig) -> Value

OpenCode’s mcp.<id> entry: type is local or remote, a local server’s program and arguments are one command array, and its variables sit under environment.

Source§

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

Source§

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

Source§

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

Source§

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

Source§

fn kinds_supported(&self) -> &[CapabilityType]

Source§

fn hook_compatibility(&self) -> &'static CompatibilityMatrix

Source§

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

Source§

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

The native event tuff create registers a scaffolded hook under.
Source§

fn hook_settings_shape(&self) -> HookSettingsShape

How the settings file at hook_settings_relpath lays out its registrations. This is the whole of what differs between harnesses in hook handling; the merge and removal follow from it.
Source§

fn policy_compatibility(&self) -> Vec<PolicyCoverageEntry>

How this harness enforces each kind of policy rule, one row per effect and subject. The default says, for every row, that Tuff does not compile policies for this harness, so a policy is refused for it rather than reported as installed.
Source§

fn permissions_settings_relpath(&self) -> Option<&'static str>

The settings file this harness reads native permission rules from, when it has one a repository can carry.
Source§

fn native_permission_rules( &self, rule: &PolicyRule, ) -> Result<Option<Vec<String>>>

The native permission rules one policy rule compiles to on this harness, or None when the harness has no such rules. The list the rules go in follows the policy rule’s effect.
Source§

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

Whether a project already uses this harness.
Source§

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

Source§

fn hook_file_content(&self, hook_cfg: &HookConfig) -> Result<Vec<u8>, TuffError>

Source§

fn render_standard_hook( &self, context: HookRenderContext<'_>, ) -> Result<HookRenderPlan, TuffError>

Source§

fn command_hook_fragment(&self, native_event: &str, command: &str) -> Value

The hooks-only fragment that registers command under native_event.
Source§

fn merge_hook_fragment( &self, existing: Option<&[u8]>, fragment: &Value, ) -> Result<Vec<u8>, TuffError>

Merge a hooks-only fragment into the settings file’s current bytes.
Source§

fn remove_hook_settings( &self, repo_root: &Path, managed_hooks: &[ManagedHook], ) -> Result<(), TuffError>

Take Tuff’s registrations out of the settings file, leaving the user’s own alone.
Source§

fn permission_relpath_for( &self, _subject: PolicySubjectKind, ) -> Option<&'static str>

The settings file rules of one subject compile into, for a harness that keeps different kinds of rule in different files. The default is permissions_settings_relpath.
Source§

fn policy_rule_gap( &self, _rule: &PolicyRule, ) -> Result<Option<String>, TuffError>

Why this harness cannot enforce one rule that its matrix row covers, such as a pattern its native setting has no form for, or None.
Source§

fn supports(&self, capability_type: CapabilityType) -> bool

Source§

fn native_hook_event(&self, raw_event: &str) -> Result<&'static str, TuffError>

Source§

fn canonical_hook_event( &self, raw_event: &str, ) -> Result<&'static str, TuffError>

Source§

fn ensure_project_dir(&self, repo_root: &Path) -> Result<(), Error>

Source§

fn mcp_http_declares_type(&self) -> bool

Whether this harness wants an explicit "type": "http" on a remote server entry. Claude Code and Codex do; Cursor infers the transport from url and has no type key for remote servers.
Source§

fn mcp_server_entry_checked( &self, server: &McpServerConfig, ) -> Result<Value, TuffError>

mcp_server_entry, for a harness whose config cannot express every declaration. The default expresses everything; an override refuses what its harness would silently get wrong, such as a renamed variable, so the install stops before anything is written.
Source§

fn install_note(&self, _kind: CapabilityType) -> Option<&'static str>

A note tuff add prints after installing a capability of this kind, for a harness that applies the installed files only under a condition the file itself cannot state, such as Codex loading a project’s .codex/ layer only once the project is trusted.
Source§

fn plan( &self, capability: &ResolvedCapability, repo_root: &Path, ) -> Result<Vec<PlannedFile>, TuffError>

Source§

fn remove( &self, primitive_id: &str, repo_root: &Path, managed_hooks: &[ManagedHook], ) -> Result<(), TuffError>

Source§

fn plan_skill( &self, capability: &ResolvedCapability, repo_root: &Path, ) -> Result<Vec<PlannedFile>, TuffError>

Source§

fn plan_tool( &self, capability: &ResolvedCapability, repo_root: &Path, ) -> Result<Vec<PlannedFile>, TuffError>

Source§

fn plan_hook( &self, capability: &ResolvedCapability, repo_root: &Path, ) -> Result<Vec<PlannedFile>, TuffError>

Source§

fn plan_native_hook( &self, capability: &ResolvedCapability, native: &NativeHookConfig, repo_root: &Path, ) -> Result<Vec<PlannedFile>, TuffError>

Source§

fn plan_mcp_server( &self, capability: &ResolvedCapability, repo_root: &Path, ) -> Result<Vec<PlannedFile>, TuffError>

Emit the canonical server.toml record. The JSON entry in the harness’s MCP config is the artifact the harness reads; this file is what gives the capability a tree to hash, so check/diff/delete work exactly as they do for every other kind.
Source§

fn plan_policy( &self, capability: &ResolvedCapability, repo_root: &Path, ) -> Result<Vec<PlannedFile>, TuffError>

Emit the canonical policy.toml record. The rules the harness reads live in its settings file; this record gives the capability a tree to hash, so check, diff, and delete treat it like every other kind, and update can tell when the policy’s rules changed.
Source§

fn remove_dir( &self, repo_root: &Path, base: &str, kind: &str, primitive_id: &str, ) -> Result<(), TuffError>

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more