aicommand

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: MIT Imports: 15 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package aicommand provides AI-powered command interpretation for the command palette.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotConfigured = fmt.Errorf("AI is not configured — add a Claude API key in Settings > App")

ErrNotConfigured is returned when no API key is set.

View Source
var ErrRateLimited = fmt.Errorf("rate limit exceeded, try again in a moment")

ErrRateLimited is returned when the rate limit is exceeded.

Functions

This section is empty.

Types

type ActionType

type ActionType string

ActionType identifies the kind of action the AI determined.

const (
	// Read-only actions (execute immediately).
	ActionNavigate      ActionType = "navigate"
	ActionSearchMovie   ActionType = "search_movie"
	ActionQueryLibrary  ActionType = "query_library"
	ActionSearchRelease ActionType = "search_releases"
	ActionExplain       ActionType = "explain"
	ActionFallback      ActionType = "fallback"

	// State-modifying actions (require confirmation).
	ActionAutoSearch ActionType = "auto_search"
	ActionRunTask    ActionType = "run_task"
)

func (ActionType) RequiresConfirmation

func (a ActionType) RequiresConfirmation() bool

RequiresConfirmation returns true for state-modifying actions.

type CommandResponse

type CommandResponse struct {
	Action              ActionType     `json:"action"`
	Params              map[string]any `json:"params,omitempty"`
	Result              map[string]any `json:"result,omitempty"`
	Explanation         string         `json:"explanation"`
	RequiresConfirm     bool           `json:"requires_confirmation,omitempty"`
	PendingActionID     string         `json:"pending_action_id,omitempty"`
	ConfirmationMessage string         `json:"confirmation_message,omitempty"`
}

CommandResponse is the structured response returned to the frontend.

type PendingAction

type PendingAction struct {
	ID        string
	Action    ActionType
	Params    map[string]any
	CreatedAt time.Time
}

PendingAction is a state-modifying action awaiting user confirmation.

type PendingStore

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

PendingStore holds actions awaiting confirmation. Entries expire after 5 minutes.

func NewPendingStore

func NewPendingStore() *PendingStore

NewPendingStore creates an empty pending action store.

func (*PendingStore) Add

func (s *PendingStore) Add(action ActionType, params map[string]any) string

Add stores a pending action and returns its ID.

func (*PendingStore) Take

func (s *PendingStore) Take(id string) *PendingAction

Take retrieves and removes a pending action. Returns nil if not found or expired.

type Service

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

Service orchestrates AI command processing.

func NewService

func NewService(client *anthropic.Client, movieSvc *movie.Service, statsSvc *stats.Service, autoSvc *autosearch.Service, librarySvc *library.Service, qualitySvc *quality.Service, logger *slog.Logger) *Service

NewService creates a new AI command service. The client may be nil; use SetClient to configure it later (e.g. when the user sets an API key at runtime).

func (*Service) ConfirmAction

func (s *Service) ConfirmAction(ctx context.Context, actionID string) (*CommandResponse, error)

ConfirmAction executes a previously stored pending action.

func (*Service) Enabled

func (s *Service) Enabled() bool

Enabled returns true when a Claude API client is configured.

func (*Service) ProcessCommand

func (s *Service) ProcessCommand(ctx context.Context, text string) (*CommandResponse, error)

ProcessCommand interprets a natural language command and returns a structured action.

func (*Service) SetClient

func (s *Service) SetClient(c *anthropic.Client)

SetClient replaces the Anthropic client at runtime (hot-reload when the user saves an API key via the settings UI).

Jump to

Keyboard shortcuts

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