Documentation
¶
Index ¶
- func DefaultDir() string
- func MigrateSkillsFromState(cfg *Config, state *SyncState) []string
- func NormalizeEndpoint(endpoint string) string
- func SkillFolder(name string) string
- func WriteConfig(dir string, cfg *Config) error
- func WriteState(dir string, state *SyncState) error
- type Config
- type Placement
- type SkillEntry
- type SyncState
- type SyncedSkill
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultDir ¶
func DefaultDir() string
DefaultDir returns the default configuration directory (~/.skael).
func MigrateSkillsFromState ¶ added in v0.8.0
MigrateSkillsFromState populates cfg.Skills from the given SyncState. Used on first run after upgrading from a legacy config that has no "skills" key. Returns the names of migrated skills (for user messaging).
func NormalizeEndpoint ¶ added in v0.19.1
NormalizeEndpoint strips trailing slashes. Callers append paths that start with "/", and the server's SPA fallback answers "//api/..." with HTML, so "https://host/" would break every API call, link and activation hook.
func SkillFolder ¶ added in v0.22.0
SkillFolder is the folder a skill installs into. Windows refuses ':' in a file name, so a prefixed skill such as payments:refunds installs into payments_refunds there. A registry name never holds '_', so the two cannot collide.
func WriteConfig ¶
WriteConfig creates dir if needed and writes cfg to config.json atomically (temp file + rename) with mode 0600.
func WriteState ¶
WriteState writes state.json atomically (temp file + rename) so a crash or concurrent writer can never leave a torn file behind.
Types ¶
type Config ¶
type Config struct {
Endpoint string `json:"endpoint"`
APIKey string `json:"api_key"`
Scope string `json:"scope,omitempty"`
Skills []SkillEntry `json:"skills"`
}
Config holds the CLI configuration stored in config.json.
func EnsureSkillsKey ¶ added in v0.8.0
EnsureSkillsKey loads config from dir and ensures the skills key exists. If the config is legacy (no skills key), it migrates from state.json, writes the updated config, and returns the migrated skill names. If the config already has a skills key, migrated is nil.
func LoadConfig ¶
LoadConfig resolves configuration with environment variables taking precedence. It checks SKAEL_URL and SKAEL_KEY first, then falls back to ReadConfig(DefaultDir()). If only one of the two env vars is set, it returns an error naming the missing one.
func ReadConfig ¶
ReadConfig reads and parses config.json from dir.
func (*Config) AddSkill ¶ added in v0.8.0
AddSkill adds a skill to the config, or updates its scope if already present.
func (*Config) FindSkill ¶ added in v0.8.0
func (c *Config) FindSkill(name string) (SkillEntry, int)
FindSkill returns the skill-name entry for name, or (-1) if not found.
func (*Config) FindSource ¶ added in v0.21.0
func (c *Config) FindSource(kind, name string) (SkillEntry, int)
FindSource returns the followed source of a kind and name, or (-1).
func (*Config) RemoveSkill ¶ added in v0.8.0
RemoveSkill removes a skill from the config by name. Returns true if found.
func (*Config) RemoveSource ¶ added in v0.21.0
RemoveSource stops following a source. Returns true if it was followed.
type Placement ¶ added in v0.7.0
type Placement struct {
Agent string `json:"agent"`
Path string `json:"path"`
Scope string `json:"scope"`
}
Placement records where a synced skill was extracted.
type SkillEntry ¶ added in v0.8.0
type SkillEntry struct {
Name string `json:"name"`
Kind string `json:"kind,omitempty"`
Scope string `json:"scope,omitempty"`
}
SkillEntry is a followed source: a skill name, a pattern such as "payments:*" (Kind "pattern"), or a set (Kind "set").
type SyncState ¶
type SyncState struct {
LastSync string `json:"last_sync"`
Skills []SyncedSkill `json:"skills"`
}
SyncState records the last sync timestamp and each synced skill.
type SyncedSkill ¶
type SyncedSkill struct {
Name string `json:"name"`
Version int `json:"version"`
Checksum string `json:"checksum"`
Placements []Placement `json:"placements,omitempty"`
// Sources are the followed sources that want this skill.
Sources []string `json:"sources,omitempty"`
}
SyncedSkill records a skill name, version, and content checksum.