plugins

package
v0.9.3 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BarChars = []rune{'▁', '▂', '▃', '▄', '▅', '▆', '▇', '█'}

BarChars are the Unicode block elements for bar visualization

Functions

func FormatTimeRemaining added in v0.4.1

func FormatTimeRemaining(d time.Duration, useDays bool, showMinutes bool) string

FormatTimeRemaining formats a duration as days or hours (with optional minutes)

func GetCachedOAuthToken added in v0.4.1

func GetCachedOAuthToken(c cacheInterface) (string, error)

GetCachedOAuthToken retrieves the OAuth token with caching to avoid repeated keychain/filesystem access. Cache TTL is 5 minutes.

func GetOAuthToken added in v0.4.1

func GetOAuthToken() (string, error)

GetOAuthToken retrieves the OAuth access token from the credential store. Tries ~/.claude/.credentials.json first (works on all platforms, avoids macOS Keychain truncation when MCP OAuth data is present), then falls back to the macOS Keychain. Note: This is uncached - prefer GetCachedOAuthToken() for repeated calls

func LevelToBarChar added in v0.4.1

func LevelToBarChar(level int) rune

LevelToBarChar converts a bar level (0-7) to the corresponding Unicode character

func TimeToBarLevel added in v0.4.1

func TimeToBarLevel(d time.Duration, maxDuration time.Duration) int

TimeToBarLevel converts time remaining to a bar level (0-7) For 5-hour window: 5h = 7, 0h = 0 For 7-day window: 7d = 7, 0d = 0

func TimeUntilReset added in v0.4.1

func TimeUntilReset(resetsAt string) (time.Duration, error)

TimeUntilReset calculates the duration until the reset time

func UtilizationToBarLevel added in v0.4.1

func UtilizationToBarLevel(utilization float64) int

UtilizationToBarLevel converts a utilization percentage (0-100) to a bar level (0-7)

Types

type AndroidPlugin

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

AndroidPlugin shows connected Android devices (via adb) Config options:

  • display: what to show for each device (default: "serial") Options: serial, model, version, sdk, manufacturer, device, build, arch Combine with colons: "model:version", "device:sdk:build"
  • packages: array of package names for version lookup (supports wildcards)

func (*AndroidPlugin) Execute

func (p *AndroidPlugin) Execute(ctx context.Context, input plugin.Input) (string, error)

func (*AndroidPlugin) Name

func (p *AndroidPlugin) Name() string

func (*AndroidPlugin) OnHook

func (p *AndroidPlugin) OnHook(ctx context.Context, hookType HookType, hookCtx HookContext) (string, error)

OnHook invalidates cache when Claude becomes idle (fresh data on next render)

func (*AndroidPlugin) SetCache

func (p *AndroidPlugin) SetCache(c *cache.Cache)

type GitPlugin

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

GitPlugin shows git branch and status

func (*GitPlugin) Execute

func (p *GitPlugin) Execute(ctx context.Context, input plugin.Input) (string, error)

func (*GitPlugin) Name

func (p *GitPlugin) Name() string

func (*GitPlugin) OnHook

func (p *GitPlugin) OnHook(ctx context.Context, hookType HookType, hookCtx HookContext) (string, error)

OnHook invalidates git cache when Claude becomes idle (fresh data on next render)

func (*GitPlugin) SetCache

func (p *GitPlugin) SetCache(c *cache.Cache)

type HookContext

type HookContext struct {
	SessionID string
	AgentType string         // Agent type if --agent was specified (e.g., "coder", "researcher")
	Config    map[string]any // Plugin configuration
}

HookContext provides context for hook handlers

type HookType

type HookType string

HookType represents the type of hook event

const (
	// Session lifecycle hooks
	HookSessionStart HookType = "session_start" // SessionStart - Session started/resumed
	HookSessionEnd   HookType = "session_end"   // SessionEnd - Session ending

	// User interaction hooks
	HookBusy              HookType = "busy"               // UserPromptSubmit - User submitted prompt
	HookIdle              HookType = "idle"               // Stop - Claude finished responding
	HookNotification      HookType = "notification"       // Notification - Claude Code sends a notification
	HookPermissionRequest HookType = "permission_request" // PermissionRequest - Permission dialog shown

	// Tool hooks
	HookPreToolUse  HookType = "pre_tool_use"  // PreToolUse - Before tool calls (can block)
	HookPostToolUse HookType = "post_tool_use" // PostToolUse - After tool calls complete

	// Agent hooks
	HookSubagentStop HookType = "subagent_stop" // SubagentStop - Subagent task completed

	// Context management hooks
	HookPreCompact HookType = "pre_compact" // PreCompact - Before context compaction
	HookSetup      HookType = "setup"       // Setup - Repository init/maintenance (--init, --init-only, --maintenance)
)

type Hookable

type Hookable interface {
	// OnHook is called when a hook event occurs
	// Return value is optional output to display (e.g., notifications)
	OnHook(ctx context.Context, hookType HookType, hookCtx HookContext) (string, error)
}

Hookable is an optional interface for plugins that want to respond to state changes

type KeychainCredentials added in v0.4.1

type KeychainCredentials struct {
	ClaudeAIOAuth *OAuthCredentials `json:"claudeAiOauth"`
}

KeychainCredentials represents the structure stored in macOS Keychain

type NativePlugin

type NativePlugin interface {
	Name() string
	Execute(ctx context.Context, input plugin.Input) (string, error)
	SetCache(c *cache.Cache)
}

NativePlugin defines the interface for built-in Go plugins

type OAuthCredentials added in v0.4.1

type OAuthCredentials struct {
	AccessToken  string   `json:"accessToken"`
	RefreshToken string   `json:"refreshToken"`
	ExpiresAt    int64    `json:"expiresAt"`
	Scopes       []string `json:"scopes"`
}

OAuthCredentials holds the OAuth token data

type Registry

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

Registry holds all available native plugins

func NewRegistry

func NewRegistry() *Registry

NewRegistry creates a new plugin registry with all native plugins

func (*Registry) Get

func (r *Registry) Get(name string) NativePlugin

Get returns a native plugin by name, or nil if not found

func (*Registry) GetHookablePlugins

func (r *Registry) GetHookablePlugins() []Hookable

GetHookablePlugins returns all plugins implementing Hookable

func (*Registry) Has

func (r *Registry) Has(name string) bool

Has returns true if a native plugin exists for the given name

func (*Registry) List

func (r *Registry) List() []string

List returns all native plugin names

func (*Registry) Register

func (r *Registry) Register(p NativePlugin)

Register adds a plugin to the registry

func (*Registry) RunHooks

func (r *Registry) RunHooks(ctx context.Context, hookType HookType, hookCtx HookContext) []string

RunHooks executes hooks on all hookable plugins sequentially

type SpotifyPlugin added in v0.7.0

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

SpotifyPlugin displays the currently playing Spotify track

func (*SpotifyPlugin) Execute added in v0.7.0

func (p *SpotifyPlugin) Execute(ctx context.Context, input plugin.Input) (string, error)

func (*SpotifyPlugin) Name added in v0.7.0

func (p *SpotifyPlugin) Name() string

func (*SpotifyPlugin) OnHook added in v0.7.0

func (p *SpotifyPlugin) OnHook(ctx context.Context, hookType HookType, hookCtx HookContext) (string, error)

OnHook invalidates Spotify cache when Claude becomes idle

func (*SpotifyPlugin) SetCache added in v0.7.0

func (p *SpotifyPlugin) SetCache(c *cache.Cache)

type TaskQueuePlugin added in v0.6.0

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

TaskQueuePlugin displays task queue status from the tq CLI

func (*TaskQueuePlugin) Execute added in v0.6.0

func (p *TaskQueuePlugin) Execute(ctx context.Context, input plugin.Input) (string, error)

func (*TaskQueuePlugin) Name added in v0.6.0

func (p *TaskQueuePlugin) Name() string

func (*TaskQueuePlugin) OnHook added in v0.6.0

func (p *TaskQueuePlugin) OnHook(ctx context.Context, hookType HookType, hookCtx HookContext) (string, error)

OnHook invalidates task queue cache when Claude becomes idle

func (*TaskQueuePlugin) SetCache added in v0.6.0

func (p *TaskQueuePlugin) SetCache(c *cache.Cache)

type UpdatePlugin

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

UpdatePlugin shows indicator when Prism update is available

func (*UpdatePlugin) Execute

func (p *UpdatePlugin) Execute(ctx context.Context, input plugin.Input) (string, error)

func (*UpdatePlugin) Name

func (p *UpdatePlugin) Name() string

func (*UpdatePlugin) OnHook

func (p *UpdatePlugin) OnHook(ctx context.Context, hookType HookType, hookCtx HookContext) (string, error)

OnHook implements Hookable interface for auto-update and notifications

func (*UpdatePlugin) SetCache

func (p *UpdatePlugin) SetCache(c *cache.Cache)

type UsageBarsPlugin added in v0.4.1

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

UsageBarsPlugin displays usage limits as compact bar visualization

func (*UsageBarsPlugin) Execute added in v0.4.1

func (p *UsageBarsPlugin) Execute(ctx context.Context, input plugin.Input) (string, error)

func (*UsageBarsPlugin) Name added in v0.4.1

func (p *UsageBarsPlugin) Name() string

func (*UsageBarsPlugin) SetCache added in v0.4.1

func (p *UsageBarsPlugin) SetCache(c *cache.Cache)

type UsageLimit added in v0.4.1

type UsageLimit struct {
	Utilization float64 `json:"utilization"`
	ResetsAt    string  `json:"resets_at"`
}

UsageLimit represents a single usage limit with utilization and reset time

type UsagePlugin added in v0.4.1

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

UsagePlugin is a unified plugin that auto-detects billing type and renders the appropriate information: - For Max/Pro users (OAuth): shows usage limits (text or bars format) - For API billing users: shows cost

func (*UsagePlugin) Execute added in v0.4.1

func (p *UsagePlugin) Execute(ctx context.Context, input plugin.Input) (string, error)

func (*UsagePlugin) Name added in v0.4.1

func (p *UsagePlugin) Name() string

func (*UsagePlugin) SetCache added in v0.4.1

func (p *UsagePlugin) SetCache(c *cache.Cache)

type UsageResponse added in v0.4.1

type UsageResponse struct {
	FiveHour     *UsageLimit `json:"five_hour"`
	SevenDay     *UsageLimit `json:"seven_day"`
	SevenDayOpus *UsageLimit `json:"seven_day_opus"`
}

UsageResponse represents the API response from the usage endpoint

func FetchUsage added in v0.4.1

func FetchUsage(ctx context.Context, token string) (*UsageResponse, error)

FetchUsage calls the usage API and returns the current usage data

type UsageTextPlugin added in v0.4.1

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

UsageTextPlugin displays usage limits as text with countdown labels

func (*UsageTextPlugin) Execute added in v0.4.1

func (p *UsageTextPlugin) Execute(ctx context.Context, input plugin.Input) (string, error)

func (*UsageTextPlugin) Name added in v0.4.1

func (p *UsageTextPlugin) Name() string

func (*UsageTextPlugin) SetCache added in v0.4.1

func (p *UsageTextPlugin) SetCache(c *cache.Cache)

Jump to

Keyboard shortcuts

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