integrations

package
v0.9.6 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var IntegrationVersion = version.Version

Functions

func Uninstall added in v0.5.3

func Uninstall(def Definition, dirs Dirs) error

Uninstall removes the integration's template file and patches the target tool's config file to unregister the hook/plugin.

Types

type ConfigFormat added in v0.5.3

type ConfigFormat string

ConfigFormat describes the format of the target tool's config file.

const (
	ConfigJSON ConfigFormat = "json"
	ConfigTOML ConfigFormat = "toml"
)

type ConfigPatchFunc added in v0.5.3

type ConfigPatchFunc func(configData []byte, targetFile string, install bool) ([]byte, error)

ConfigPatchFunc patches a tool's config file to register or unregister an integration. When install is true, the hook/plugin entry is added; when false, it is removed. configData is the raw file content, targetFile is the path to the installed hook/plugin file.

type Definition added in v0.5.3

type Definition struct {
	ID          ID
	Name        string
	Description string
	Type        IntegrationType
	Template    string // embedded template content

	// TargetFileFunc returns the absolute path where the rendered template is written.
	TargetFileFunc func(dirs Dirs) string

	// ConfigFileFunc returns the absolute path to the target tool's config file.
	// Implementations must check tool-specific env var overrides internally
	// (e.g., CODEX_CONFIG_DIR, CLAUDE_SETTINGS_FILE).
	ConfigFileFunc func(dirs Dirs) string
	ConfigFormat   ConfigFormat
	ConfigPatcher  ConfigPatchFunc

	Detector DetectFunc

	// MatchProviderIDs lists provider IDs from detect.Result.Accounts that
	// correspond to this integration. This is the stable join key for
	// matching auto-detected accounts to integration definitions.
	MatchProviderIDs []string

	// MatchToolNameHint is a substring to match against detect.DetectedTool.Name
	// for associating a detected tool entry with this integration. Empty means
	// no tool matching (env-key-only providers like OpenCode).
	MatchToolNameHint string

	// TemplateFileMode is the file permission for the rendered template file.
	TemplateFileMode os.FileMode

	// EscapeBin transforms the openusage binary path for template substitution.
	EscapeBin func(string) string
}

Definition is the complete, self-contained description of one built-in integration.

func AllDefinitions added in v0.5.3

func AllDefinitions() []Definition

AllDefinitions returns the built-in integration definitions.

func DefinitionByID added in v0.5.3

func DefinitionByID(id ID) (Definition, bool)

DefinitionByID returns the definition with the given ID, or false if not found.

type DetectFunc added in v0.5.3

type DetectFunc func(dirs Dirs) Status

DetectFunc checks whether the integration is installed and configured.

type Dirs added in v0.5.3

type Dirs struct {
	Home         string
	ConfigRoot   string // XDG_CONFIG_HOME or ~/.config
	HooksDir     string // ~/.config/openusage/hooks
	OpenusageBin string // resolved binary path
}

Dirs holds resolved filesystem paths shared across all integrations.

func NewDefaultDirs added in v0.5.3

func NewDefaultDirs() Dirs

NewDefaultDirs resolves Dirs from environment variables and platform defaults.

type ID

type ID string
const (
	OpenCodeID   ID = "opencode"
	CodexID      ID = "codex"
	ClaudeCodeID ID = "claude_code"
)

type InstallResult added in v0.5.3

type InstallResult struct {
	ID           ID
	Action       string // "installed", "upgraded", "already_current", "uninstalled"
	TemplateFile string
	ConfigFile   string
	PreviousVer  string
	InstalledVer string
}

InstallResult describes the outcome of an Install or Upgrade operation.

func Install added in v0.5.3

func Install(def Definition, dirs Dirs) (InstallResult, error)

Install renders the integration template, writes it to disk, and patches the target tool's config file to register the hook/plugin.

func Upgrade added in v0.5.3

func Upgrade(def Definition, dirs Dirs) (InstallResult, error)

Upgrade re-installs the integration, always reporting the action as "upgraded".

type IntegrationType added in v0.5.3

type IntegrationType string

IntegrationType distinguishes hook scripts from plugins.

const (
	TypeHookScript IntegrationType = "hook_script"
	TypePlugin     IntegrationType = "plugin"
)

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

func NewDefaultManager

func NewDefaultManager() Manager

func (Manager) Install

func (m Manager) Install(id ID) error

func (Manager) ListStatuses

func (m Manager) ListStatuses() []Status

type Match added in v0.5.3

type Match struct {
	Definition Definition
	Tool       *detect.DetectedTool
	Account    *core.AccountConfig
	Status     Status
	Actionable bool // true if tool/account detected AND not installed
}

Match pairs an integration Definition with auto-detection results.

func MatchDetected added in v0.5.3

func MatchDetected(defs []Definition, detected detect.Result, dirs Dirs) []Match

MatchDetected matches integration definitions against auto-detection results. Uses Definition.MatchProviderIDs to find matching accounts (stable join key). Uses Definition.MatchToolNameHint to find the corresponding DetectedTool (display only).

type Status

type Status struct {
	ID               ID
	Name             string
	Installed        bool
	Configured       bool
	InstalledVersion string
	DesiredVersion   string
	NeedsUpgrade     bool
	State            string
	Summary          string
}

Jump to

Keyboard shortcuts

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