MCPcopy Create free account
hub / github.com/diillson/chatcli / LoadPreferences

Function LoadPreferences

pkg/registry/skill_preferences.go:47–67  ·  view source on GitHub ↗

LoadPreferences reads skill preferences from disk. Returns an empty preferences object if the file doesn't exist.

()

Source from the content-addressed store, hash-verified

45// LoadPreferences reads skill preferences from disk.
46// Returns an empty preferences object if the file doesn't exist.
47func LoadPreferences() *SkillPreferences {
48 sp := &SkillPreferences{
49 Preferences: make(map[string]string),
50 filePath: PreferencesPath(),
51 }
52
53 data, err := os.ReadFile(sp.filePath)
54 if err != nil {
55 return sp // file doesn't exist yet — return empty prefs
56 }
57
58 if err := yaml.Unmarshal(data, sp); err != nil {
59 return sp // corrupted — return empty prefs
60 }
61
62 if sp.Preferences == nil {
63 sp.Preferences = make(map[string]string)
64 }
65
66 return sp
67}
68
69// Save writes current preferences to disk.
70func (sp *SkillPreferences) Save() error {

Callers 1

PreferMethod · 0.92

Calls 1

PreferencesPathFunction · 0.85

Tested by

no test coverage detected