sync

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 12, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const ManagedMarker = "_managedBy"

ManagedMarker is the key used to mark entries managed by agentctl

View Source
const ManagedValue = "agentctl"

ManagedValue is the value used to identify agentctl-managed entries

Variables

This section is empty.

Functions

func FilterStdioServers

func FilterStdioServers(servers []*mcp.Server) []*mcp.Server

FilterStdioServers returns only servers that use stdio transport Use this for tools that don't support HTTP/SSE remote MCP servers

func Register

func Register(adapter Adapter)

Register registers an adapter

func SupportsWorkspace

func SupportsWorkspace(a Adapter) bool

SupportsWorkspace checks if an adapter implements WorkspaceAdapter

Types

type Adapter

type Adapter interface {
	// Name returns the adapter name (e.g., "claude", "cursor")
	Name() string

	// Detect checks if this tool is installed on the system
	Detect() (bool, error)

	// ConfigPath returns the path to the tool's config file
	ConfigPath() string

	// SupportedResources returns the resource types this adapter supports
	SupportedResources() []ResourceType

	// ReadServers reads MCP server configurations from the tool
	ReadServers() ([]*mcp.Server, error)

	// WriteServers writes MCP server configurations to the tool
	WriteServers(servers []*mcp.Server) error

	// ReadCommands reads command configurations from the tool (if supported)
	ReadCommands() ([]*command.Command, error)

	// WriteCommands writes command configurations to the tool (if supported)
	WriteCommands(commands []*command.Command) error

	// ReadRules reads rule configurations from the tool (if supported)
	ReadRules() ([]*rule.Rule, error)

	// WriteRules writes rule configurations to the tool (if supported)
	WriteRules(rules []*rule.Rule) error
}

Adapter is the interface that tool-specific adapters must implement

func All

func All() []Adapter

All returns all registered adapters

func Detected

func Detected() []Adapter

Detected returns all adapters for installed tools

func Get

func Get(name string) (Adapter, bool)

Get returns an adapter by name

type ClaudeAdapter

type ClaudeAdapter struct{}

ClaudeAdapter syncs configuration to Claude Code CLI (~/.claude/) This is the default "claude" adapter as Claude Code is the primary developer tool

func (*ClaudeAdapter) ConfigPath

func (a *ClaudeAdapter) ConfigPath() string

func (*ClaudeAdapter) Detect

func (a *ClaudeAdapter) Detect() (bool, error)

func (*ClaudeAdapter) Name

func (a *ClaudeAdapter) Name() string

func (*ClaudeAdapter) ReadCommands

func (a *ClaudeAdapter) ReadCommands() ([]*command.Command, error)

func (*ClaudeAdapter) ReadRules

func (a *ClaudeAdapter) ReadRules() ([]*rule.Rule, error)

func (*ClaudeAdapter) ReadServers

func (a *ClaudeAdapter) ReadServers() ([]*mcp.Server, error)

func (*ClaudeAdapter) ReadSkills

func (a *ClaudeAdapter) ReadSkills() ([]*skill.Skill, error)

ReadSkills reads installed plugins as skills

func (*ClaudeAdapter) ReadWorkspaceServers

func (a *ClaudeAdapter) ReadWorkspaceServers(projectDir string) ([]*mcp.Server, error)

ReadWorkspaceServers reads MCP servers from the project's .mcp.json file

func (*ClaudeAdapter) SupportedResources

func (a *ClaudeAdapter) SupportedResources() []ResourceType

func (*ClaudeAdapter) SupportsWorkspace

func (a *ClaudeAdapter) SupportsWorkspace() bool

SupportsWorkspace returns true - Claude Code supports .mcp.json in project root

func (*ClaudeAdapter) WorkspaceConfigPath

func (a *ClaudeAdapter) WorkspaceConfigPath(projectDir string) string

WorkspaceConfigPath returns the path to .mcp.json in the project directory

func (*ClaudeAdapter) WriteCommands

func (a *ClaudeAdapter) WriteCommands(commands []*command.Command) error

func (*ClaudeAdapter) WriteRules

func (a *ClaudeAdapter) WriteRules(rules []*rule.Rule) error

func (*ClaudeAdapter) WriteServers

func (a *ClaudeAdapter) WriteServers(servers []*mcp.Server) error

func (*ClaudeAdapter) WriteWorkspaceServers

func (a *ClaudeAdapter) WriteWorkspaceServers(projectDir string, servers []*mcp.Server) error

WriteWorkspaceServers writes MCP servers to the project's .mcp.json file

type ClaudeCodePlugin

type ClaudeCodePlugin struct {
	Scope        string `json:"scope"`
	InstallPath  string `json:"installPath"`
	Version      string `json:"version"`
	InstalledAt  string `json:"installedAt"`
	LastUpdated  string `json:"lastUpdated"`
	GitCommitSha string `json:"gitCommitSha,omitempty"`
	IsLocal      bool   `json:"isLocal"`
}

ClaudeCodePlugin represents an installed plugin

type ClaudeCodePluginsFile

type ClaudeCodePluginsFile struct {
	Version int                           `json:"version"`
	Plugins map[string][]ClaudeCodePlugin `json:"plugins"`
}

ClaudeCodePluginsFile represents the installed_plugins.json structure

type ClaudeCodeSettings

type ClaudeCodeSettings struct {
	MCPServers     map[string]ClaudeServerConfig `json:"mcpServers,omitempty"`
	EnabledPlugins map[string]bool               `json:"enabledPlugins,omitempty"`
	Hooks          map[string]interface{}        `json:"hooks,omitempty"`
	// Preserve other fields
	Other map[string]interface{} `json:"-"`
}

ClaudeCodeSettings represents Claude Code's settings.json structure

type ClaudeConfig

type ClaudeConfig struct {
	MCPServers map[string]ClaudeServerConfig `json:"mcpServers,omitempty"`
}

ClaudeConfig represents Claude's configuration file structure

type ClaudeDesktopAdapter

type ClaudeDesktopAdapter struct{}

ClaudeDesktopAdapter syncs configuration to Claude Desktop (the Electron app)

func (*ClaudeDesktopAdapter) ConfigPath

func (a *ClaudeDesktopAdapter) ConfigPath() string

func (*ClaudeDesktopAdapter) Detect

func (a *ClaudeDesktopAdapter) Detect() (bool, error)

func (*ClaudeDesktopAdapter) Name

func (a *ClaudeDesktopAdapter) Name() string

func (*ClaudeDesktopAdapter) ReadCommands

func (a *ClaudeDesktopAdapter) ReadCommands() ([]*command.Command, error)

func (*ClaudeDesktopAdapter) ReadRules

func (a *ClaudeDesktopAdapter) ReadRules() ([]*rule.Rule, error)

func (*ClaudeDesktopAdapter) ReadServers

func (a *ClaudeDesktopAdapter) ReadServers() ([]*mcp.Server, error)

func (*ClaudeDesktopAdapter) SupportedResources

func (a *ClaudeDesktopAdapter) SupportedResources() []ResourceType

func (*ClaudeDesktopAdapter) WriteCommands

func (a *ClaudeDesktopAdapter) WriteCommands(commands []*command.Command) error

func (*ClaudeDesktopAdapter) WriteRules

func (a *ClaudeDesktopAdapter) WriteRules(rules []*rule.Rule) error

func (*ClaudeDesktopAdapter) WriteServers

func (a *ClaudeDesktopAdapter) WriteServers(servers []*mcp.Server) error

type ClaudeServerConfig

type ClaudeServerConfig struct {
	// For local (stdio) servers
	Command string   `json:"command,omitempty"`
	Args    []string `json:"args,omitempty"`

	// For remote (http/sse) servers
	Transport string `json:"transport,omitempty"` // "http" or "sse"
	URL       string `json:"url,omitempty"`       // Remote server URL

	// Common fields
	Env       map[string]string `json:"env,omitempty"`
	ManagedBy string            `json:"_managedBy,omitempty"`
}

ClaudeServerConfig represents a server in Claude's config format

type ClineAdapter

type ClineAdapter struct{}

ClineAdapter syncs configuration to Cline

func (*ClineAdapter) ConfigPath

func (a *ClineAdapter) ConfigPath() string

func (*ClineAdapter) Detect

func (a *ClineAdapter) Detect() (bool, error)

func (*ClineAdapter) Name

func (a *ClineAdapter) Name() string

func (*ClineAdapter) ReadCommands

func (a *ClineAdapter) ReadCommands() ([]*command.Command, error)

func (*ClineAdapter) ReadRules

func (a *ClineAdapter) ReadRules() ([]*rule.Rule, error)

func (*ClineAdapter) ReadServers

func (a *ClineAdapter) ReadServers() ([]*mcp.Server, error)

func (*ClineAdapter) SupportedResources

func (a *ClineAdapter) SupportedResources() []ResourceType

func (*ClineAdapter) WriteCommands

func (a *ClineAdapter) WriteCommands(commands []*command.Command) error

func (*ClineAdapter) WriteRules

func (a *ClineAdapter) WriteRules(rules []*rule.Rule) error

func (*ClineAdapter) WriteServers

func (a *ClineAdapter) WriteServers(servers []*mcp.Server) error

type ClineServerConfig

type ClineServerConfig struct {
	Command   string            `json:"command"`
	Args      []string          `json:"args,omitempty"`
	Env       map[string]string `json:"env,omitempty"`
	ManagedBy string            `json:"_managedBy,omitempty"`
}

ClineServerConfig represents a server in Cline's config format

type CodexAdapter

type CodexAdapter struct{}

CodexAdapter syncs configuration to OpenAI Codex CLI

func (*CodexAdapter) ConfigPath

func (a *CodexAdapter) ConfigPath() string

func (*CodexAdapter) Detect

func (a *CodexAdapter) Detect() (bool, error)

func (*CodexAdapter) Name

func (a *CodexAdapter) Name() string

func (*CodexAdapter) ReadCommands

func (a *CodexAdapter) ReadCommands() ([]*command.Command, error)

func (*CodexAdapter) ReadRules

func (a *CodexAdapter) ReadRules() ([]*rule.Rule, error)

func (*CodexAdapter) ReadServers

func (a *CodexAdapter) ReadServers() ([]*mcp.Server, error)

func (*CodexAdapter) SupportedResources

func (a *CodexAdapter) SupportedResources() []ResourceType

func (*CodexAdapter) WriteCommands

func (a *CodexAdapter) WriteCommands(commands []*command.Command) error

func (*CodexAdapter) WriteRules

func (a *CodexAdapter) WriteRules(rules []*rule.Rule) error

func (*CodexAdapter) WriteServers

func (a *CodexAdapter) WriteServers(servers []*mcp.Server) error

type CodexConfig

type CodexConfig struct {
	MCPServers map[string]CodexServerConfig `json:"mcpServers,omitempty"`
}

CodexConfig represents Codex's configuration

type CodexServerConfig

type CodexServerConfig struct {
	Command   string            `json:"command"`
	Args      []string          `json:"args,omitempty"`
	Env       map[string]string `json:"env,omitempty"`
	ManagedBy string            `json:"_managedBy,omitempty"`
}

CodexServerConfig represents a server in Codex's config format

type ContinueAdapter

type ContinueAdapter struct{}

ContinueAdapter syncs configuration to Continue.dev

func (*ContinueAdapter) ConfigPath

func (a *ContinueAdapter) ConfigPath() string

func (*ContinueAdapter) Detect

func (a *ContinueAdapter) Detect() (bool, error)

func (*ContinueAdapter) Name

func (a *ContinueAdapter) Name() string

func (*ContinueAdapter) ReadCommands

func (a *ContinueAdapter) ReadCommands() ([]*command.Command, error)

func (*ContinueAdapter) ReadRules

func (a *ContinueAdapter) ReadRules() ([]*rule.Rule, error)

func (*ContinueAdapter) ReadServers

func (a *ContinueAdapter) ReadServers() ([]*mcp.Server, error)

func (*ContinueAdapter) SupportedResources

func (a *ContinueAdapter) SupportedResources() []ResourceType

func (*ContinueAdapter) WriteCommands

func (a *ContinueAdapter) WriteCommands(commands []*command.Command) error

func (*ContinueAdapter) WriteRules

func (a *ContinueAdapter) WriteRules(rules []*rule.Rule) error

func (*ContinueAdapter) WriteServers

func (a *ContinueAdapter) WriteServers(servers []*mcp.Server) error

type ContinueServerConfig

type ContinueServerConfig struct {
	Command   string            `json:"command"`
	Args      []string          `json:"args,omitempty"`
	Env       map[string]string `json:"env,omitempty"`
	ManagedBy string            `json:"_managedBy,omitempty"`
}

ContinueServerConfig represents a server in Continue's config format

type CursorAdapter

type CursorAdapter struct{}

CursorAdapter syncs configuration to Cursor

func (*CursorAdapter) ConfigPath

func (a *CursorAdapter) ConfigPath() string

func (*CursorAdapter) Detect

func (a *CursorAdapter) Detect() (bool, error)

func (*CursorAdapter) Name

func (a *CursorAdapter) Name() string

func (*CursorAdapter) ReadCommands

func (a *CursorAdapter) ReadCommands() ([]*command.Command, error)

func (*CursorAdapter) ReadRules

func (a *CursorAdapter) ReadRules() ([]*rule.Rule, error)

func (*CursorAdapter) ReadServers

func (a *CursorAdapter) ReadServers() ([]*mcp.Server, error)

func (*CursorAdapter) ReadWorkspaceServers

func (a *CursorAdapter) ReadWorkspaceServers(projectDir string) ([]*mcp.Server, error)

ReadWorkspaceServers reads MCP servers from the project's .cursor/mcp.json file

func (*CursorAdapter) SupportedResources

func (a *CursorAdapter) SupportedResources() []ResourceType

func (*CursorAdapter) SupportsWorkspace

func (a *CursorAdapter) SupportsWorkspace() bool

SupportsWorkspace returns true - Cursor supports .cursor/mcp.json in project root

func (*CursorAdapter) WorkspaceConfigPath

func (a *CursorAdapter) WorkspaceConfigPath(projectDir string) string

WorkspaceConfigPath returns the path to .cursor/mcp.json in the project directory

func (*CursorAdapter) WriteCommands

func (a *CursorAdapter) WriteCommands(commands []*command.Command) error

func (*CursorAdapter) WriteRules

func (a *CursorAdapter) WriteRules(rules []*rule.Rule) error

func (*CursorAdapter) WriteServers

func (a *CursorAdapter) WriteServers(servers []*mcp.Server) error

func (*CursorAdapter) WriteWorkspaceServers

func (a *CursorAdapter) WriteWorkspaceServers(projectDir string, servers []*mcp.Server) error

WriteWorkspaceServers writes MCP servers to the project's .cursor/mcp.json file

type CursorServerConfig

type CursorServerConfig struct {
	Command   string            `json:"command"`
	Args      []string          `json:"args,omitempty"`
	Env       map[string]string `json:"env,omitempty"`
	ManagedBy string            `json:"_managedBy,omitempty"`
}

CursorServerConfig represents a server in Cursor's config format

type GeminiAdapter

type GeminiAdapter struct{}

GeminiAdapter syncs configuration to Google Gemini CLI

func (*GeminiAdapter) ConfigPath

func (a *GeminiAdapter) ConfigPath() string

func (*GeminiAdapter) Detect

func (a *GeminiAdapter) Detect() (bool, error)

func (*GeminiAdapter) Name

func (a *GeminiAdapter) Name() string

func (*GeminiAdapter) ReadCommands

func (a *GeminiAdapter) ReadCommands() ([]*command.Command, error)

func (*GeminiAdapter) ReadRules

func (a *GeminiAdapter) ReadRules() ([]*rule.Rule, error)

func (*GeminiAdapter) ReadServers

func (a *GeminiAdapter) ReadServers() ([]*mcp.Server, error)

func (*GeminiAdapter) SupportedResources

func (a *GeminiAdapter) SupportedResources() []ResourceType

func (*GeminiAdapter) WriteCommands

func (a *GeminiAdapter) WriteCommands(commands []*command.Command) error

func (*GeminiAdapter) WriteRules

func (a *GeminiAdapter) WriteRules(rules []*rule.Rule) error

func (*GeminiAdapter) WriteServers

func (a *GeminiAdapter) WriteServers(servers []*mcp.Server) error

type GeminiConfig

type GeminiConfig struct {
	MCPServers map[string]GeminiServerConfig `json:"mcpServers,omitempty"`
	// Preserve other fields
	Other map[string]interface{} `json:"-"`
}

GeminiConfig represents Gemini's configuration

type GeminiServerConfig

type GeminiServerConfig struct {
	Command   string            `json:"command,omitempty"`
	Args      []string          `json:"args,omitempty"`
	Env       map[string]string `json:"env,omitempty"`
	URL       string            `json:"url,omitempty"`
	Transport string            `json:"transport,omitempty"`
	ManagedBy string            `json:"_managedBy,omitempty"`
}

GeminiServerConfig represents a server in Gemini's config format

type OpenCodeAdapter

type OpenCodeAdapter struct{}

OpenCodeAdapter syncs configuration to OpenCode (opencode.ai)

func (*OpenCodeAdapter) ConfigPath

func (a *OpenCodeAdapter) ConfigPath() string

func (*OpenCodeAdapter) Detect

func (a *OpenCodeAdapter) Detect() (bool, error)

func (*OpenCodeAdapter) Name

func (a *OpenCodeAdapter) Name() string

func (*OpenCodeAdapter) ReadCommands

func (a *OpenCodeAdapter) ReadCommands() ([]*command.Command, error)

func (*OpenCodeAdapter) ReadRules

func (a *OpenCodeAdapter) ReadRules() ([]*rule.Rule, error)

func (*OpenCodeAdapter) ReadServers

func (a *OpenCodeAdapter) ReadServers() ([]*mcp.Server, error)

func (*OpenCodeAdapter) SupportedResources

func (a *OpenCodeAdapter) SupportedResources() []ResourceType

func (*OpenCodeAdapter) WriteCommands

func (a *OpenCodeAdapter) WriteCommands(commands []*command.Command) error

func (*OpenCodeAdapter) WriteRules

func (a *OpenCodeAdapter) WriteRules(rules []*rule.Rule) error

func (*OpenCodeAdapter) WriteServers

func (a *OpenCodeAdapter) WriteServers(servers []*mcp.Server) error

type OpenCodeServerConfig

type OpenCodeServerConfig struct {
	Type    string            `json:"type"`
	Command []string          `json:"command,omitempty"`
	URL     string            `json:"url,omitempty"`
	Env     map[string]string `json:"env,omitempty"`
	Enabled bool              `json:"enabled"`
}

OpenCodeServerConfig represents a server in OpenCode's config format OpenCode uses a different format than Claude Desktop: - "type": "local" or "remote" - "command": array of strings (command + args combined) - "enabled": boolean - "url": for remote servers Note: OpenCode's schema is strict - no custom fields allowed

type ResourceType

type ResourceType string

ResourceType represents the type of resource being synced

const (
	ResourceMCP      ResourceType = "mcp"
	ResourceCommands ResourceType = "commands"
	ResourceRules    ResourceType = "rules"
	ResourcePrompts  ResourceType = "prompts"
	ResourceSkills   ResourceType = "skills"
)

type SyncResult

type SyncResult struct {
	Tool    string
	Success bool
	Error   error
	Changes int // Number of changes made
}

SyncResult represents the result of syncing to a tool

func SyncAll

func SyncAll(servers []*mcp.Server, commands []*command.Command, rules []*rule.Rule) []SyncResult

SyncAll syncs configuration to all detected tools

type SyncState

type SyncState struct {
	Version int `json:"version"`
	// ManagedServers maps adapter name -> list of server names we manage
	ManagedServers map[string][]string `json:"managedServers"`
}

SyncState tracks which servers are managed by agentctl per adapter This is stored in ~/.config/agentctl/sync-state.json

func LoadState

func LoadState() (*SyncState, error)

LoadState loads the sync state from disk

func (*SyncState) ClearManagedServers

func (s *SyncState) ClearManagedServers(adapterName string)

ClearManagedServers removes all managed servers for an adapter

func (*SyncState) GetManagedServers

func (s *SyncState) GetManagedServers(adapterName string) []string

GetManagedServers returns the list of server names managed for an adapter

func (*SyncState) Save

func (s *SyncState) Save() error

Save saves the sync state to disk

func (*SyncState) SetManagedServers

func (s *SyncState) SetManagedServers(adapterName string, servers []string)

SetManagedServers sets the list of server names managed for an adapter

type WindsurfAdapter

type WindsurfAdapter struct{}

WindsurfAdapter syncs configuration to Windsurf (Codeium)

func (*WindsurfAdapter) ConfigPath

func (a *WindsurfAdapter) ConfigPath() string

func (*WindsurfAdapter) Detect

func (a *WindsurfAdapter) Detect() (bool, error)

func (*WindsurfAdapter) Name

func (a *WindsurfAdapter) Name() string

func (*WindsurfAdapter) ReadCommands

func (a *WindsurfAdapter) ReadCommands() ([]*command.Command, error)

func (*WindsurfAdapter) ReadRules

func (a *WindsurfAdapter) ReadRules() ([]*rule.Rule, error)

func (*WindsurfAdapter) ReadServers

func (a *WindsurfAdapter) ReadServers() ([]*mcp.Server, error)

func (*WindsurfAdapter) SupportedResources

func (a *WindsurfAdapter) SupportedResources() []ResourceType

func (*WindsurfAdapter) WriteCommands

func (a *WindsurfAdapter) WriteCommands(commands []*command.Command) error

func (*WindsurfAdapter) WriteRules

func (a *WindsurfAdapter) WriteRules(rules []*rule.Rule) error

func (*WindsurfAdapter) WriteServers

func (a *WindsurfAdapter) WriteServers(servers []*mcp.Server) error

type WindsurfServerConfig

type WindsurfServerConfig struct {
	Command   string            `json:"command"`
	Args      []string          `json:"args,omitempty"`
	Env       map[string]string `json:"env,omitempty"`
	ManagedBy string            `json:"_managedBy,omitempty"`
}

WindsurfServerConfig represents a server in Windsurf's config format

type WorkspaceAdapter

type WorkspaceAdapter interface {
	Adapter

	// SupportsWorkspace returns true if this tool has workspace-level config support
	SupportsWorkspace() bool

	// WorkspaceConfigPath returns the path to the workspace config file for a given project
	WorkspaceConfigPath(projectDir string) string

	// ReadWorkspaceServers reads MCP servers from the workspace config
	ReadWorkspaceServers(projectDir string) ([]*mcp.Server, error)

	// WriteWorkspaceServers writes MCP servers to the workspace config
	WriteWorkspaceServers(projectDir string, servers []*mcp.Server) error
}

WorkspaceAdapter is an optional interface for adapters that support project-level (workspace) configurations in addition to global configs. Tools like Claude Code (.mcp.json) and Cursor (.cursor/mcp.json) support this.

func AsWorkspaceAdapter

func AsWorkspaceAdapter(a Adapter) (WorkspaceAdapter, bool)

AsWorkspaceAdapter returns the adapter as a WorkspaceAdapter if supported

type ZedAdapter

type ZedAdapter struct{}

ZedAdapter syncs configuration to Zed editor

func (*ZedAdapter) ConfigPath

func (a *ZedAdapter) ConfigPath() string

func (*ZedAdapter) Detect

func (a *ZedAdapter) Detect() (bool, error)

func (*ZedAdapter) Name

func (a *ZedAdapter) Name() string

func (*ZedAdapter) ReadCommands

func (a *ZedAdapter) ReadCommands() ([]*command.Command, error)

func (*ZedAdapter) ReadRules

func (a *ZedAdapter) ReadRules() ([]*rule.Rule, error)

func (*ZedAdapter) ReadServers

func (a *ZedAdapter) ReadServers() ([]*mcp.Server, error)

func (*ZedAdapter) SupportedResources

func (a *ZedAdapter) SupportedResources() []ResourceType

func (*ZedAdapter) WriteCommands

func (a *ZedAdapter) WriteCommands(commands []*command.Command) error

func (*ZedAdapter) WriteRules

func (a *ZedAdapter) WriteRules(rules []*rule.Rule) error

func (*ZedAdapter) WriteServers

func (a *ZedAdapter) WriteServers(servers []*mcp.Server) error

type ZedServerConfig

type ZedServerConfig struct {
	Command   string            `json:"command"`
	Args      []string          `json:"args,omitempty"`
	Env       map[string]string `json:"env,omitempty"`
	ManagedBy string            `json:"_managedBy,omitempty"`
}

ZedServerConfig represents a server in Zed's config format

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL