on main help sign in
feat(skills): also load from .config/agents (#1755)
commit6b3cd26f9f78ae7318153922763025bfa8831443 authorAmolith <amolith@secluded.site> dateWed 7 Jan 2026, 03:35 (9 months ago) parent7766ea6
1 file changed+21−15
internal/config/load.go+21−15
internal/config/load.go+21−15
@@ -365,10 +365,11 @@ func (c *Config) setDefaults(workingDir, dataDir string) {
365365 slices.Sort(c.Options.ContextPaths)
366366 c.Options.ContextPaths = slices.Compact(c.Options.ContextPaths)
367367
368− // Add the default skills directory if not already present.
369− defaultSkillsDir := GlobalSkillsDir()
370− if !slices.Contains(c.Options.SkillsPaths, defaultSkillsDir) {
371− c.Options.SkillsPaths = append([]string{defaultSkillsDir}, c.Options.SkillsPaths...)
368+ // Add the default skills directories if not already present.
369+ for _, dir := range GlobalSkillsDirs() {
370+ if !slices.Contains(c.Options.SkillsPaths, dir) {
371+ c.Options.SkillsPaths = append(c.Options.SkillsPaths, dir)
372+ }
372373 }
373374
374375 if str, ok := os.LookupEnv("CRUSH_DISABLE_PROVIDER_AUTO_UPDATE"); ok {
@@ -746,24 +747,29 @@ func isInsideWorktree() bool {
746747 return err == nil && strings.TrimSpace(string(bts)) == "true"
747748}
748749
749−// GlobalSkillsDir returns the default directory for Agent Skills.
750−// Skills in this directory are auto-discovered and their files can be read
750+// GlobalSkillsDirs returns the default directories for Agent Skills.
751+// Skills in these directories are auto-discovered and their files can be read
751752// without permission prompts.
752−func GlobalSkillsDir() string {
753+func GlobalSkillsDirs() []string {
753754 if crushSkills := os.Getenv("CRUSH_SKILLS_DIR"); crushSkills != "" {
754− return crushSkills
755− }
756− if xdgConfigHome := os.Getenv("XDG_CONFIG_HOME"); xdgConfigHome != "" {
757− return filepath.Join(xdgConfigHome, appName, "skills")
755+ return []string{crushSkills}
758756 }
759757
760− if runtime.GOOS == "windows" {
761− localAppData := cmp.Or(
758+ // Determine the base config directory.
759+ var configBase string
760+ if xdgConfigHome := os.Getenv("XDG_CONFIG_HOME"); xdgConfigHome != "" {
761+ configBase = xdgConfigHome
762+ } else if runtime.GOOS == "windows" {
763+ configBase = cmp.Or(
762764 os.Getenv("LOCALAPPDATA"),
763765 filepath.Join(os.Getenv("USERPROFILE"), "AppData", "Local"),
764766 )
765− return filepath.Join(localAppData, appName, "skills")
767+ } else {
768+ configBase = filepath.Join(home.Dir(), ".config")
766769 }
767770
768− return filepath.Join(home.Dir(), ".config", appName, "skills")
771+ return []string{
772+ filepath.Join(configBase, appName, "skills"),
773+ filepath.Join(configBase, "agents", "skills"),
774+ }
769775}