Documentation
¶
Overview ¶
Package subcommand provides the infrastructure for defining and executing smart home commands. Each command is composed of one or more actions.
Index ¶
- Constants
- type ActionSpec
- type Arg
- type Commands
- type Config
- type Definition
- func NewChangePlaylistCmdDefinition() Definition
- func NewDisplayOutputsCmdDefinition() Definition
- func NewDisplayPlaylistCmdDefinition() Definition
- func NewDisplayTemperatureDefinition() Definition
- func NewHealthDefinition() Definition
- func NewHelpDefinition() Definition
- func NewPlayRandomArtistCmdDefinition() Definition
- func NewPlayRandomGenreCmdDefinition() Definition
- func NewPlayRandomPlaylistCmdDefinition() Definition
- func NewSearchAndPlayMusicCmdDefinition() Definition
- func NewSearchMusicCmdDefinition() Definition
- func NewStartMusicCmdDefinition() Definition
- func NewStopMusicDefinition() Definition
- func NewSwitchBotDeviceListDefinition() Definition
- func NewSwitchBotSceneListDefinition() Definition
- func NewTokenizeIpaDefinition() Definition
- func NewTokenizeNeologdDefinition() Definition
- func NewTokenizeUniDefinition() Definition
- func NewUpdateLibraryCmdDefinition() Definition
- type MacroConfig
- type ResolverConfig
- type Subcommand
- func NewChangePlaylistSubcommand(definition Definition, config Config) Subcommand
- func NewDisplayOutputsSubcommand(definition Definition, config Config) Subcommand
- func NewDisplayPlaylistsSubcommand(definition Definition, config Config) Subcommand
- func NewDisplayTemperatureSubcommand(definition Definition, config Config) Subcommand
- func NewHealthSubcommand(definition Definition, config Config) Subcommand
- func NewHelpSubcommand(definition Definition, config Config) Subcommand
- func NewPlayRandomArtistSubcommand(definition Definition, config Config) Subcommand
- func NewPlayRandomGenreSubcommand(definition Definition, config Config) Subcommand
- func NewPlayRandomPlaylistSubcommand(definition Definition, config Config) Subcommand
- func NewSearchAndPlayMusicSubcommand(definition Definition, config Config) Subcommand
- func NewSearchMusicSubcommand(definition Definition, config Config) Subcommand
- func NewStartMusicSubcommand(definition Definition, config Config) Subcommand
- func NewStopMusicSubcommand(definition Definition, config Config) Subcommand
- func NewSwitchBotDeviceListSubcommand(definition Definition, config Config) Subcommand
- func NewSwitchBotSceneListSubcommand(definition Definition, config Config) Subcommand
- func NewTokenizeIpaCommand(definition Definition, _ Config) Subcommand
- func NewTokenizeNeologdCommand(definition Definition, _ Config) Subcommand
- func NewTokenizeUniCommand(definition Definition, _ Config) Subcommand
- func NewUpdateLibrarySubcommand(definition Definition, config Config) Subcommand
Constants ¶
const ( // ResolverModeLegacy uses the current built-in resolution flow. ResolverModeLegacy = "legacy" // ResolverModeDSPy uses an external DSPy-based resolver flow. ResolverModeDSPy = "dspy" )
const ChangePlaylistCmd = "change playlist"
ChangePlaylistCmd is the command name for changing the music playlist.
const ConfigDirName = "./config"
ConfigDirName is the default path to the configuration directory.
const ConfigFileName = "./config/config.json"
ConfigFileName is the default path to the configuration file. For backward compatibility with the -config flag.
const DeviceListCmd = "device list"
DeviceListCmd is a short name for the SwitchBot device list command.
const DispOutputsCmd = "disp outputs"
DispOutputsCmd is a short name for the display outputs command.
const DispPlaylistsCmd = "disp playlists"
DispPlaylistsCmd is a short name for the display playlists command.
const DispTempCmd = "disp temp"
DispTempCmd is a short name for the display temperature command.
const DisplayOutputsCmd = "display outputs"
DisplayOutputsCmd is the command name for displaying audio outputs.
const DisplayPlaylistsCmd = "display playlist"
DisplayPlaylistsCmd is the command name for displaying playlists.
const DisplayTemperatureCmd = "display temperature"
DisplayTemperatureCmd is the command name for displaying temperature and humidity.
const HealthCmd = "health"
HealthCmd is the command name for checking the health of the system.
const HelpCmd = "help"
HelpCmd is the command name for displaying help.
const PlayRandomArtistCmd = "play random artist"
PlayRandomArtistCmd is the command name for playing random artist music.
const PlayRandomGenreCmd = "play random genre"
PlayRandomGenreCmd is the command name for playing random genre music.
const PlayRandomPlaylistCmd = "play random playlist"
PlayRandomPlaylistCmd is the command name for playing random playlist music.
const SceneListCmd = "scene list"
SceneListCmd is a short name for the SwitchBot scene list command.
const SearchAndPlayMusicCmd = "search and play"
SearchAndPlayMusicCmd is the command name for searching and playing music.
const SearchMusicCmd = "search music"
SearchMusicCmd is the command name for searching music.
const SearchPlayCmd = "search play"
SearchPlayCmd is a short name for the search and play music command.
const StartMusicCmd = "start music"
StartMusicCmd is the command name for starting music playback.
const StopMusicCmd = "stop music"
StopMusicCmd is the command name for stopping music playback.
const SwitchBotDeviceListCmd = "switchbot device list"
SwitchBotDeviceListCmd is the command name for listing SwitchBot devices.
const SwitchBotSceneListCmd = "switchbot scene list"
SwitchBotSceneListCmd is the command name for listing SwitchBot scenes.
const TokenizeIpaCmd = "tokenize ipa"
TokenizeIpaCmd is the command name for tokenizing with IPA dictionary.
const (
// #nosec G101
TokenizeNeologdCmd = "tokenize neologd"
)
TokenizeNeologdCmd is the command name for tokenizing with Neologd dictionary.
const (
// #nosec G101
TokenizeUniCmd = "tokenize uni"
)
TokenizeUniCmd is the command name for tokenizing with Uni dictionary.
const UpdateLibraryCmd = "update library"
UpdateLibraryCmd is the command name for updating the music library.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ActionSpec ¶
ActionSpec defines a single action step in a macro.
type Commands ¶
type Commands struct {
Definitions []Definition
}
Commands represents a collection of subcommand definitions.
func NewCommands ¶
func NewCommands(macros ...MacroConfig) Commands
NewCommands creates a new collection of all available subcommand definitions. Optionally pass MacroConfig values to register user-defined macros.
type Config ¶
type Config struct {
Owntone owntone.Config `json:"Owntone"`
Switchbot switchbot.Config `json:"Switchbot"`
Yamaha yamaha.Config `json:"Yamaha"`
LLM llm.Config `json:"LLM"`
Resolver ResolverConfig `json:"Resolver"`
Influxdb influxdb.Config `json:"Influxdb"`
Commands Commands
}
Config represents the application configuration.
func LoadConfig ¶
LoadConfig loads the configuration from the default directory.
func LoadConfigFromDir ¶
LoadConfigFromDir loads configuration from a directory. It reads config.json (required) and macros.json (optional) from the directory. Unknown files in the directory are logged as warnings.
func LoadConfigWithPath ¶
LoadConfigWithPath loads the configuration from the specified file path. For backward compatibility with the -config flag.
type Definition ¶
type Definition struct {
Name string
Description string
Factory func(Definition, Config) Subcommand
Args []Arg
// contains filtered or unexported fields
}
Definition defines the metadata and factory for a subcommand.
func NewChangePlaylistCmdDefinition ¶
func NewChangePlaylistCmdDefinition() Definition
NewChangePlaylistCmdDefinition creates the definition for the change playlist command.
func NewDisplayOutputsCmdDefinition ¶
func NewDisplayOutputsCmdDefinition() Definition
NewDisplayOutputsCmdDefinition creates the definition for the display outputs command.
func NewDisplayPlaylistCmdDefinition ¶
func NewDisplayPlaylistCmdDefinition() Definition
NewDisplayPlaylistCmdDefinition creates the definition for the display playlists command.
func NewDisplayTemperatureDefinition ¶
func NewDisplayTemperatureDefinition() Definition
NewDisplayTemperatureDefinition creates the definition for the display temperature command.
func NewHealthDefinition ¶
func NewHealthDefinition() Definition
NewHealthDefinition creates the definition for the health check command.
func NewHelpDefinition ¶
func NewHelpDefinition() Definition
NewHelpDefinition creates the definition for the help command.
func NewPlayRandomArtistCmdDefinition ¶
func NewPlayRandomArtistCmdDefinition() Definition
NewPlayRandomArtistCmdDefinition creates the definition for the random artist command.
func NewPlayRandomGenreCmdDefinition ¶
func NewPlayRandomGenreCmdDefinition() Definition
NewPlayRandomGenreCmdDefinition creates the definition for the random genre command.
func NewPlayRandomPlaylistCmdDefinition ¶
func NewPlayRandomPlaylistCmdDefinition() Definition
NewPlayRandomPlaylistCmdDefinition creates the definition for the random playlist command.
func NewSearchAndPlayMusicCmdDefinition ¶
func NewSearchAndPlayMusicCmdDefinition() Definition
NewSearchAndPlayMusicCmdDefinition creates the definition for the search and play music command.
func NewSearchMusicCmdDefinition ¶
func NewSearchMusicCmdDefinition() Definition
NewSearchMusicCmdDefinition creates the definition for the search music command.
func NewStartMusicCmdDefinition ¶
func NewStartMusicCmdDefinition() Definition
NewStartMusicCmdDefinition creates the definition for the start music command.
func NewStopMusicDefinition ¶
func NewStopMusicDefinition() Definition
NewStopMusicDefinition creates the definition for the stop music command.
func NewSwitchBotDeviceListDefinition ¶
func NewSwitchBotDeviceListDefinition() Definition
NewSwitchBotDeviceListDefinition creates the definition for the SwitchBot device list command.
func NewSwitchBotSceneListDefinition ¶
func NewSwitchBotSceneListDefinition() Definition
NewSwitchBotSceneListDefinition creates the definition for the SwitchBot scene list command.
func NewTokenizeIpaDefinition ¶
func NewTokenizeIpaDefinition() Definition
NewTokenizeIpaDefinition creates the definition for the tokenize ipa command.
func NewTokenizeNeologdDefinition ¶
func NewTokenizeNeologdDefinition() Definition
NewTokenizeNeologdDefinition creates the definition for the tokenize neologd command.
func NewTokenizeUniDefinition ¶
func NewTokenizeUniDefinition() Definition
NewTokenizeUniDefinition creates the definition for the tokenize uni command.
func NewUpdateLibraryCmdDefinition ¶
func NewUpdateLibraryCmdDefinition() Definition
NewUpdateLibraryCmdDefinition creates the definition for the update library command.
func (Definition) Distance ¶
func (d Definition) Distance(input string) (int, string)
Distance calculates the Levenshtein distance between the input and the command names.
func (Definition) Help ¶
func (d Definition) Help() string
Help returns a help string for the subcommand.
func (Definition) Init ¶
func (d Definition) Init(config Config) Subcommand
Init initializes a subcommand from its definition and configuration.
type MacroConfig ¶
type MacroConfig struct {
Name string `json:"name"`
Description string `json:"description"`
Shortnames []string `json:"shortnames"`
IgnoreError bool `json:"ignore_error"`
Actions []ActionSpec `json:"actions"`
}
MacroConfig defines a user-configurable macro (sequence of actions).
type ResolverConfig ¶
type ResolverConfig struct {
Mode string `json:"mode"`
FeedbackEnabled bool `json:"feedback_enabled"`
PromptVersion string `json:"prompt_version"`
DSPyEndpoint string `json:"dspy_endpoint"`
DSPyTimeoutSeconds int `json:"dspy_timeout_seconds"`
}
ResolverConfig controls resolver behavior and observability options.
func (ResolverConfig) Validate ¶
func (c ResolverConfig) Validate() error
Validate validates ResolverConfig.
type Subcommand ¶
type Subcommand struct {
Definition
// contains filtered or unexported fields
}
Subcommand represents a executable command consisting of one or more actions.
func NewChangePlaylistSubcommand ¶
func NewChangePlaylistSubcommand(definition Definition, config Config) Subcommand
NewChangePlaylistSubcommand creates a new Subcommand for the change playlist command.
func NewDisplayOutputsSubcommand ¶
func NewDisplayOutputsSubcommand(definition Definition, config Config) Subcommand
NewDisplayOutputsSubcommand creates a new Subcommand for the display outputs command.
func NewDisplayPlaylistsSubcommand ¶
func NewDisplayPlaylistsSubcommand(definition Definition, config Config) Subcommand
NewDisplayPlaylistsSubcommand creates a new Subcommand for the display playlists command.
func NewDisplayTemperatureSubcommand ¶
func NewDisplayTemperatureSubcommand(definition Definition, config Config) Subcommand
NewDisplayTemperatureSubcommand creates a new Subcommand for the display temperature command.
func NewHealthSubcommand ¶
func NewHealthSubcommand(definition Definition, config Config) Subcommand
NewHealthSubcommand creates a new Subcommand for the health check command.
func NewHelpSubcommand ¶
func NewHelpSubcommand(definition Definition, config Config) Subcommand
NewHelpSubcommand creates a new Subcommand for the help command.
func NewPlayRandomArtistSubcommand ¶
func NewPlayRandomArtistSubcommand(definition Definition, config Config) Subcommand
NewPlayRandomArtistSubcommand creates a new Subcommand for random artist playback.
func NewPlayRandomGenreSubcommand ¶
func NewPlayRandomGenreSubcommand(definition Definition, config Config) Subcommand
NewPlayRandomGenreSubcommand creates a new Subcommand for random genre playback.
func NewPlayRandomPlaylistSubcommand ¶
func NewPlayRandomPlaylistSubcommand(definition Definition, config Config) Subcommand
NewPlayRandomPlaylistSubcommand creates a new Subcommand for random playlist playback.
func NewSearchAndPlayMusicSubcommand ¶
func NewSearchAndPlayMusicSubcommand(definition Definition, config Config) Subcommand
NewSearchAndPlayMusicSubcommand creates a new Subcommand for the search and play music command.
func NewSearchMusicSubcommand ¶
func NewSearchMusicSubcommand(definition Definition, config Config) Subcommand
NewSearchMusicSubcommand creates a new Subcommand for the search music command.
func NewStartMusicSubcommand ¶
func NewStartMusicSubcommand(definition Definition, config Config) Subcommand
NewStartMusicSubcommand creates a new Subcommand for the start music command.
func NewStopMusicSubcommand ¶
func NewStopMusicSubcommand(definition Definition, config Config) Subcommand
NewStopMusicSubcommand creates a new Subcommand for the stop music command.
func NewSwitchBotDeviceListSubcommand ¶
func NewSwitchBotDeviceListSubcommand(definition Definition, config Config) Subcommand
NewSwitchBotDeviceListSubcommand creates a new Subcommand for the SwitchBot device list command.
func NewSwitchBotSceneListSubcommand ¶
func NewSwitchBotSceneListSubcommand(definition Definition, config Config) Subcommand
NewSwitchBotSceneListSubcommand creates a new Subcommand for the SwitchBot scene list command.
func NewTokenizeIpaCommand ¶
func NewTokenizeIpaCommand(definition Definition, _ Config) Subcommand
NewTokenizeIpaCommand creates a new Subcommand for the tokenize ipa command.
func NewTokenizeNeologdCommand ¶
func NewTokenizeNeologdCommand(definition Definition, _ Config) Subcommand
NewTokenizeNeologdCommand creates a new Subcommand for the tokenize neologd command.
func NewTokenizeUniCommand ¶
func NewTokenizeUniCommand(definition Definition, _ Config) Subcommand
NewTokenizeUniCommand creates a new Subcommand for the tokenize uni command.
func NewUpdateLibrarySubcommand ¶
func NewUpdateLibrarySubcommand(definition Definition, config Config) Subcommand
NewUpdateLibrarySubcommand creates a new Subcommand for the update library command.
Source Files
¶
- buildinfo.go
- change-playlist.go
- config.go
- display-outputs.go
- display-palylists.go
- display-temperature.go
- health.go
- help.go
- macro.go
- play-random-music.go
- resolver_strategy.go
- search-and-play.go
- search-music.go
- start-music.go
- stop-music.go
- subcommand.go
- switchbot-device-list.go
- switchbot-scene-list.go
- tokenize.go
- update-library.go
Directories
¶
| Path | Synopsis |
|---|---|
|
Package action defines the interface for smart home actions.
|
Package action defines the interface for smart home actions. |
|
healthcheck
Package healthcheck provides actions for checking the health of various services.
|
Package healthcheck provides actions for checking the health of various services. |
|
internal
Package internal provides internal helper functions for action implementations.
|
Package internal provides internal helper functions for action implementations. |
|
kagome
Package kagome provides an action to tokenize Japanese text using the Kagome tokenizer.
|
Package kagome provides an action to tokenize Japanese text using the Kagome tokenizer. |
|
llm
Package llm provides a client for resolving natural language to subcommands using LLMs.
|
Package llm provides a client for resolving natural language to subcommands using LLMs. |
|
owntone
Package owntone provides actions and a client for controlling Owntone (formerly forked-daapd) servers.
|
Package owntone provides actions and a client for controlling Owntone (formerly forked-daapd) servers. |
|
switchbot
Package switchbot provides actions and a client for controlling SwitchBot devices.
|
Package switchbot provides actions and a client for controlling SwitchBot devices. |
|
yamaha
Package yamaha provides actions and a client for controlling Yamaha MusicCast devices.
|
Package yamaha provides actions and a client for controlling Yamaha MusicCast devices. |