Prefer manages source preferences for skills with name conflicts. Usage: /skill prefer → list all preferences /skill prefer frontend-design → show current preference /skill prefer frontend-design skills.sh → prefer the skills.sh version /skill prefer
(args []string)
| 874 | // /skill prefer frontend-design local → prefer the local version |
| 875 | // /skill prefer frontend-design --reset → remove preference (use default order) |
| 876 | func (sh *SkillHandler) Prefer(args []string) { |
| 877 | prefs := registry.LoadPreferences() |
| 878 | |
| 879 | // No args: list all preferences |
| 880 | if len(args) == 0 { |
| 881 | all := prefs.ListPreferences() |
| 882 | if len(all) == 0 { |
| 883 | fmt.Printf("\n %s\n", i18n.T("skill.prefer.none")) |
| 884 | fmt.Printf(" %s\n\n", i18n.T("skill.prefer.hint", |
| 885 | colorize("/skill prefer <name> <source>", ColorCyan))) |
| 886 | return |
| 887 | } |
| 888 | |
| 889 | fmt.Printf("\n %s:\n\n", colorize(i18n.T("skill.prefer.header"), ColorCyan)) |
| 890 | for baseName, source := range all { |
| 891 | fmt.Printf(" %s → %s\n", |
| 892 | colorize(baseName, ColorCyan), |
| 893 | colorize(source, ColorGreen)) |
| 894 | } |
| 895 | fmt.Println() |
| 896 | return |
| 897 | } |
| 898 | |
| 899 | baseName := args[0] |
| 900 | |
| 901 | // Single arg: show current preference and available sources |
| 902 | if len(args) == 1 { |
| 903 | current := prefs.GetPreference(baseName) |
| 904 | matches := sh.registryMgr.GetAllInstalledInfo(baseName) |
| 905 | |
| 906 | if len(matches) == 0 { |
| 907 | fmt.Printf("\n %s\n\n", i18n.T("skill.prefer.not_installed", baseName)) |
| 908 | return |
| 909 | } |
| 910 | |
| 911 | fmt.Println() |
| 912 | if current != "" { |
| 913 | fmt.Printf(" %s %s → %s\n", |
| 914 | colorize(i18n.T("skill.prefer.current")+":", ColorCyan), |
| 915 | colorize(baseName, ColorCyan), |
| 916 | colorize(current, ColorGreen)) |
| 917 | } else { |
| 918 | fmt.Printf(" %s %s (%s)\n", |
| 919 | colorize(i18n.T("skill.prefer.current")+":", ColorCyan), |
| 920 | colorize(baseName, ColorCyan), |
| 921 | i18n.T("skill.prefer.default_order")) |
| 922 | } |
| 923 | |
| 924 | fmt.Printf("\n %s:\n", i18n.T("skill.prefer.available")) |
| 925 | for _, m := range matches { |
| 926 | marker := "" |
| 927 | if m.Source == current { |
| 928 | marker = " " + colorize("← "+i18n.T("skill.prefer.active"), ColorGreen) |
| 929 | } |
| 930 | fmt.Printf(" %s %s%s\n", |
| 931 | colorize(m.Name, ColorCyan), |
| 932 | colorize(fmt.Sprintf("[%s]", m.Source), ColorGray), |
| 933 | marker) |
no test coverage detected