Documentation
¶
Overview ¶
Package library is lich's own library of skills and MCP servers: what lich holds in <config>/lich/library, what each provider has installed in its own config that is not there yet (found.go), moving one in, turning each item on or off per provider and per profile, and handing the ones on to a session (deliver.go).
The library is shared by every profile; the switches live in lich.db, one settings key per item, provider and profile. A switch never stored is off: an item reaches only the providers it was moved in from until someone turns it on elsewhere.
Index ¶
- func CardMCPID(name string) string
- func CardPluginID(id string) string
- type Delivery
- type Server
- type Service
- func (s *Service) CardItems(provider string) []api.SubagentCardItem
- func (s *Service) Deliver(provider, profile, profileDir string) Delivery
- func (s *Service) List(_ context.Context, opts api.LibraryListOptions) (api.Library, error)
- func (s *Service) MoveIn(_ context.Context, opts api.LibraryItemOptions) (api.None, error)
- func (s *Service) On(kind, name, provider, profile string) bool
- func (s *Service) Seen(_ context.Context, opts api.LibrarySeenOptions) (api.None, error)
- func (s *Service) Set(_ context.Context, opts api.LibrarySwitchOptions) (api.None, error)
- func (s *Service) Watch(ctx context.Context)
- type Settings
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CardMCPID ¶
CardMCPID and CardPluginID are the api.SubagentCardItem IDs of an MCP server and of a plugin by its name@marketplace.
func CardPluginID ¶
Types ¶
type Delivery ¶
type Delivery struct {
// PluginDir is a Claude Code plugin holding the skills, for --plugin-dir.
PluginDir string
// SkillsDir is the folder of skills, for opencode's skills.paths.
SkillsDir string
// OMPConfig is an omp --config overlay naming SkillsDir.
OMPConfig string
// CrushSkills is the folder for CRUSH_SKILLS_DIR: Crush's own global
// skills and the library's, since the variable replaces Crush's search.
CrushSkills string
// MCP are the servers for the providers that take them at spawn.
MCP map[string]Server
}
Delivery is what one spawn hands its provider.
type Server ¶
type Server struct {
Type string `json:"type,omitempty"`
Command string `json:"command,omitempty"`
Args []string `json:"args,omitempty"`
Env map[string]string `json:"env,omitempty"`
URL string `json:"url,omitempty"`
}
Server is one MCP server as the library keeps it.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service is the library over one config directory.
func New ¶
func New(settings Settings, emit func(name string, data any), profiles func(string) []api.Profile, pluginDir func() string) *Service
New returns the library, reporting changes through emit.
func (*Service) CardItems ¶
func (s *Service) CardItems(provider string) []api.SubagentCardItem
CardItems are the MCP servers and plugins a session of provider loads from the user's own setup, which a subagent card may leave out one by one (api.SubagentCards): the servers its config holds, the library's switched on for it in any profile, and its plugins switched on in any profile. lich's own are never among them. Their On is the caller's.
func (*Service) Deliver ¶
Deliver works out provider's items for a session in profile (its slug, "" for Personal), whose own config directory is profileDir ("" for Personal's), and writes what the provider can only read from its config. A failure costs the session those items, never its spawn.
func (*Service) List ¶
List answers the library, what the providers hold beside it, lich's own plugin and theirs, in opts.Project's scope, over RPC.
func (*Service) MoveIn ¶
MoveIn copies a found item into the library, turns it off in every provider it was found in, and turns it on in lich for those providers, over RPC.
func (*Service) On ¶
On is whether item reaches provider's sessions in profile ("" for the provider as a whole): the profile's own switch once it was set, else the provider's, which a move in sets for every profile at once.
type Settings ¶
type Settings interface {
GetSetting(ctx context.Context, opts api.GetSettingOptions) (string, error)
SetSetting(ctx context.Context, opts api.SetSettingOptions) (api.None, error)
ProviderBin(providerID, projectID string) string
}
Settings is where the switches are kept, the store's global settings, and the binary the person set for each provider ("" for its default name).