Skip to content

Adding New Tools

Maciej Mensfeld edited this page Sep 29, 2026 · 2 revisions

Adding New Tools

Coi's tool abstraction makes it straightforward to add new AI coding assistants. Each tool implements the Tool interface:

type Tool interface {
    Name() string
    Binary() string
    ConfigDirName() string
    SessionsDirName() string
    BuildCommand(sessionID string, resume bool, resumeSessionID string) []string
    DiscoverSessionID(stateDir string) string
    GetSandboxSettings() map[string]interface{}
}

Tools that use a config directory (most tools) should also implement ToolWithConfigDirFiles, which tells Coi which files to copy from the host and where to inject sandbox settings:

type ToolWithConfigDirFiles interface {
    Tool
    EssentialConfigFiles() []string       // Files to copy from host config dir
    SandboxSettingsFileName() string      // File to inject sandbox/bypass settings into
    StateConfigFileName() string          // Sibling state file (e.g. ".claude.json"), "" if none
    AlwaysSetupConfig() bool              // Run config setup even when the host config dir is absent
}

Tools that support configurable reasoning effort (like Claude) can implement ToolWithEffortLevel:

type ToolWithEffortLevel interface {
    Tool
    SetEffortLevel(level string)  // "low", "medium", "high", "xhigh", "max", or "auto"
}

Tools that support configurable permission modes can implement ToolWithPermissionMode:

type ToolWithPermissionMode interface {
    Tool
    SetPermissionMode(mode string)  // "bypass" (default) or "interactive"
}

Tools that support auto-loading context from a file (like Claude's ~/.claude/CLAUDE.md) can implement ToolWithAutoContextFile:

type ToolWithAutoContextFile interface {
    Tool
    AutoContextFile() string  // Path relative to home dir (e.g. ".claude/CLAUDE.md")
}

Tools that reference the context file path in their config (like OpenCode's instructions field) can implement ToolWithAutoContextPath:

type ToolWithAutoContextPath interface {
    Tool
    SetAutoContextPath(path string)  // Absolute path to sandbox context file
}

Tools that can be launched non-interactively with an initial prompt (for coi tool spec) can implement ToolWithPrompt and expose model/effort as container env via ToolWithContainerEnv; see Headless Orchestration for how those are used.

See internal/tool/tool.go and internal/tool/opencode.go for complete examples.

See Also

Clone this wiki locally