@cannbot-ai/install-helper 1.1.6-beta.0 → 1.1.6-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -864,7 +864,12 @@ var init_zh_CN = __esm({
864
864
  uninstall_plugin_batch_skip_restore: "\u6279\u91CF\u5378\u8F7D\u6A21\u5F0F\uFF1A\u8DF3\u8FC7\u5907\u4EFD\u6062\u590D",
865
865
  uninstall_confirm_prompt: "\u5373\u5C06\u5378\u8F7D {count} \u9879\uFF0C\u786E\u8BA4\uFF1F",
866
866
  uninstall_select_items: "\u7BA1\u7406\u5DF2\u5B89\u88C5\u7684 Skills\uFF08\u7A7A\u683C\u5207\u6362\uFF0C\u56DE\u8F66\u786E\u8BA4\uFF09",
867
- uninstall_select_plugins: "\u7BA1\u7406\u5DF2\u5B89\u88C5\u7684 Plugins\uFF08\u7A7A\u683C\u5207\u6362\uFF0C\u56DE\u8F66\u786E\u8BA4\uFF09"
867
+ uninstall_select_plugins: "\u7BA1\u7406\u5DF2\u5B89\u88C5\u7684 Plugins\uFF08\u7A7A\u683C\u5207\u6362\uFF0C\u56DE\u8F66\u786E\u8BA4\uFF09",
868
+ uninstall_select_category: "\u9009\u62E9\u8981\u7BA1\u7406\u7684 Skill \u7C7B\u522B",
869
+ uninstall_uncheck_all_category: "\u5168\u4E0D\u9009\u5F53\u524D\u7C7B\u522B\uFF08\u6807\u8BB0\u5168\u90E8\u5378\u8F7D\uFF09",
870
+ uninstall_continue_or_confirm: "\u5DF2\u6807\u8BB0 {count} \u4E2A\u5F85\u5378\u8F7D\uFF0C\u8BF7\u9009\u62E9\u64CD\u4F5C",
871
+ uninstall_marked_count: "\u5DF2\u6807\u8BB0 {count} \u4E2A\u5F85\u5378\u8F7D",
872
+ uninstall_uncategorized: "\u672A\u5206\u7C7B"
868
873
  };
869
874
  }
870
875
  });
@@ -1081,7 +1086,12 @@ var init_en_US = __esm({
1081
1086
  uninstall_plugin_batch_skip_restore: "Batch mode: skipping backup restore",
1082
1087
  uninstall_confirm_prompt: "About to uninstall {count} items, confirm?",
1083
1088
  uninstall_select_items: "Manage installed Skills (space to toggle, enter to confirm)",
1084
- uninstall_select_plugins: "Manage installed Plugins (space to toggle, enter to confirm)"
1089
+ uninstall_select_plugins: "Manage installed Plugins (space to toggle, enter to confirm)",
1090
+ uninstall_select_category: "Select Skill category to manage",
1091
+ uninstall_uncheck_all_category: "Uncheck all in this category (mark for uninstall)",
1092
+ uninstall_continue_or_confirm: "{count} marked for uninstall, choose an action",
1093
+ uninstall_marked_count: "{count} marked for uninstall",
1094
+ uninstall_uncategorized: "Uncategorized"
1085
1095
  };
1086
1096
  }
1087
1097
  });
@@ -3816,60 +3826,177 @@ async function interactiveSkillUnselect(tool, level) {
3816
3826
  logger.warn(t("uninstall_no_installed_skills"));
3817
3827
  return "back";
3818
3828
  }
3819
- const categories = getAllCategories();
3829
+ const allCategories = getAllCategories();
3820
3830
  const installedSet = new Set(installedSkills);
3821
- const skillChoices = [
3822
- {
3823
- name: `>> ${t("uninstall_uncheck_all")}`,
3824
- value: UNSELECT_ALL,
3825
- checked: false,
3826
- description: t("uninstall_uncheck_all")
3827
- },
3828
- new Separator2("\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"),
3829
- ...installedSkills.map((skillId) => {
3830
- const skill = findSkill(skillId);
3831
- const cat = categories.find((c) => c.skills.some((s) => s.id === skillId));
3832
- const catName = cat ? cat.name : "";
3833
- const desc = skill?.description || "";
3834
- return {
3835
- name: `${chalk5.cyan(skillId)}${catName ? chalk5.dim(` [${catName}]`) : ""}`,
3836
- value: skillId,
3837
- checked: true,
3838
- description: desc
3839
- };
3840
- })
3841
- ];
3842
- printBoxTitle(t("uninstall_interactive_title"));
3843
- logger.info(chalk5.dim(` ${t("uninstall_checkbox_hint")}`));
3844
- logger.blank();
3845
- showOperationHints(true);
3846
- const selected = await checkbox({
3847
- message: t("uninstall_select_items"),
3848
- choices: skillChoices,
3849
- loop: false,
3850
- instructions: false,
3851
- theme: checkboxTheme,
3852
- pageSize: 20
3853
- });
3854
- let toKeep;
3855
- if (selected.includes(UNSELECT_ALL)) {
3856
- toKeep = [];
3857
- } else {
3858
- toKeep = selected.filter((id) => id !== UNSELECT_ALL);
3859
- }
3860
- const toUninstall = installedSkills.filter((id) => !toKeep.includes(id));
3861
- if (toUninstall.length === 0) {
3862
- logger.info(t("uninstall_nothing_to_uninstall"));
3863
- return "back";
3831
+ const categoriesWithInstalled = allCategories.map((cat) => ({
3832
+ ...cat,
3833
+ skills: cat.skills.filter((s) => installedSet.has(s.id))
3834
+ })).filter((cat) => cat.skills.length > 0);
3835
+ const uncategorized = installedSkills.filter(
3836
+ (id) => !allCategories.some((cat) => cat.skills.some((s) => s.id === id))
3837
+ );
3838
+ if (uncategorized.length > 0) {
3839
+ categoriesWithInstalled.push({
3840
+ id: "__uncategorized__",
3841
+ name: t("uninstall_uncategorized"),
3842
+ skills: uncategorized.map((id) => ({ id, description: "", source: "", filePath: "" }))
3843
+ });
3864
3844
  }
3865
- const confirmed = await confirm({
3866
- message: t("uninstall_confirm_count").replace("{count}", chalk5.bold(String(toUninstall.length))),
3867
- default: false
3868
- });
3869
- if (!confirmed) {
3870
- return "cancel";
3845
+ let keptSet = new Set(installedSkills);
3846
+ let step = 0;
3847
+ let selectedCategoryId = "";
3848
+ while (true) {
3849
+ switch (step) {
3850
+ case 0: {
3851
+ const toUninstallCount = installedSkills.length - keptSet.size;
3852
+ const titleSuffix = toUninstallCount > 0 ? `${t("wizard_step_3_skill_title")}\uFF08${t("uninstall_marked_count").replace("{count}", String(toUninstallCount))}\uFF09` : t("wizard_step_3_skill_title");
3853
+ printBoxTitle(titleSuffix);
3854
+ const categoryChoices = [
3855
+ {
3856
+ name: `>> ${t("uninstall_uncheck_all")}`,
3857
+ value: UNSELECT_ALL
3858
+ },
3859
+ new Separator2("\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"),
3860
+ ...categoriesWithInstalled.map((cat) => {
3861
+ const catKeptCount = cat.skills.filter((s) => keptSet.has(s.id)).length;
3862
+ const catUninstallCount = cat.skills.length - catKeptCount;
3863
+ const suffix = catUninstallCount > 0 ? chalk5.yellow(` (${catUninstallCount} to uninstall)`) : "";
3864
+ return {
3865
+ name: `> ${cat.name} (${cat.skills.length} skills)${suffix}`,
3866
+ value: cat.id
3867
+ };
3868
+ }),
3869
+ new Separator2("\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"),
3870
+ ...toUninstallCount > 0 ? [{ name: `>> ${t("uninstall_confirm_count").replace("{count}", String(toUninstallCount))}`, value: "uninstall" }] : [],
3871
+ { name: "<- " + t("wizard_back"), value: BACK },
3872
+ { name: "x " + t("wizard_cancel"), value: CANCEL }
3873
+ ];
3874
+ showOperationHints();
3875
+ selectedCategoryId = await select3({
3876
+ message: t("uninstall_select_category"),
3877
+ choices: categoryChoices,
3878
+ loop: false,
3879
+ theme: selectTheme,
3880
+ pageSize: 15
3881
+ });
3882
+ if (selectedCategoryId === BACK) return "back";
3883
+ if (selectedCategoryId === CANCEL) return "cancel";
3884
+ if (selectedCategoryId === UNSELECT_ALL) {
3885
+ keptSet = /* @__PURE__ */ new Set();
3886
+ const toUninstall = [...installedSkills];
3887
+ const confirmed = await confirm({
3888
+ message: t("uninstall_confirm_prompt").replace("{count}", chalk5.bold(String(toUninstall.length))),
3889
+ default: false
3890
+ });
3891
+ if (!confirmed) return "cancel";
3892
+ return { toUninstall, toKeep: [] };
3893
+ }
3894
+ if (selectedCategoryId === "uninstall") {
3895
+ const toUninstall = installedSkills.filter((id) => !keptSet.has(id));
3896
+ if (toUninstall.length === 0) {
3897
+ logger.info(t("uninstall_nothing_to_uninstall"));
3898
+ return "back";
3899
+ }
3900
+ const confirmed = await confirm({
3901
+ message: t("uninstall_confirm_prompt").replace("{count}", chalk5.bold(String(toUninstall.length))),
3902
+ default: false
3903
+ });
3904
+ if (!confirmed) return "cancel";
3905
+ return { toUninstall, toKeep: [...keptSet] };
3906
+ }
3907
+ step = 1;
3908
+ break;
3909
+ }
3910
+ case 1: {
3911
+ const category = categoriesWithInstalled.find((c) => c.id === selectedCategoryId);
3912
+ if (!category) return "back";
3913
+ printBoxTitle(t("wizard_step_4_skill_title").replace("{category}", category.name));
3914
+ const categorySkillIds = new Set(category.skills.map((s) => s.id));
3915
+ const keptInCategory = new Set([...keptSet].filter((id) => categorySkillIds.has(id)));
3916
+ const skillChoices = [
3917
+ {
3918
+ name: `>> ${t("uninstall_uncheck_all_category")}`,
3919
+ value: SELECT_ALL_CATEGORY,
3920
+ checked: keptInCategory.size === 0,
3921
+ description: t("uninstall_uncheck_all_category")
3922
+ },
3923
+ new Separator2("\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"),
3924
+ ...category.skills.map((skill) => {
3925
+ const isKept = keptInCategory.has(skill.id);
3926
+ return {
3927
+ name: `${chalk5.cyan(skill.id)}`,
3928
+ value: skill.id,
3929
+ checked: isKept,
3930
+ description: skill.description || ""
3931
+ };
3932
+ })
3933
+ ];
3934
+ logger.info(chalk5.dim(` ${t("uninstall_checkbox_hint")}`));
3935
+ logger.blank();
3936
+ showOperationHints(true);
3937
+ const selectedSkills = await checkbox({
3938
+ message: t("uninstall_select_items"),
3939
+ choices: skillChoices,
3940
+ loop: false,
3941
+ instructions: false,
3942
+ theme: checkboxTheme,
3943
+ pageSize: 15
3944
+ });
3945
+ let keptInCat;
3946
+ if (selectedSkills.includes(SELECT_ALL_CATEGORY)) {
3947
+ keptInCat = [];
3948
+ } else {
3949
+ keptInCat = selectedSkills.filter((id) => id !== SELECT_ALL_CATEGORY);
3950
+ }
3951
+ for (const id of categorySkillIds) {
3952
+ if (keptInCat.includes(id)) {
3953
+ keptSet.add(id);
3954
+ } else {
3955
+ keptSet.delete(id);
3956
+ }
3957
+ }
3958
+ const toUninstallCount = installedSkills.length - keptSet.size;
3959
+ const action = await select3({
3960
+ message: toUninstallCount > 0 ? t("uninstall_continue_or_confirm").replace("{count}", String(toUninstallCount)) : t("wizard_no_selection"),
3961
+ choices: toUninstallCount > 0 ? [
3962
+ { name: ">> " + t("uninstall_confirm_count").replace("{count}", String(toUninstallCount)), value: "uninstall" },
3963
+ { name: "> " + t("skill_continue_select"), value: CONTINUE_SELECT },
3964
+ new Separator2("\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"),
3965
+ { name: "x " + t("wizard_cancel"), value: "cancel" }
3966
+ ] : [
3967
+ new Separator2("\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"),
3968
+ { name: "> " + t("skill_continue_select"), value: CONTINUE_SELECT },
3969
+ { name: "<- " + t("wizard_back_to_reselect"), value: "back" },
3970
+ { name: "x " + t("wizard_cancel"), value: "cancel" }
3971
+ ],
3972
+ loop: false,
3973
+ theme: selectTheme
3974
+ });
3975
+ if (action === "uninstall") {
3976
+ const toUninstall = installedSkills.filter((id) => !keptSet.has(id));
3977
+ if (toUninstall.length === 0) {
3978
+ logger.info(t("uninstall_nothing_to_uninstall"));
3979
+ return "back";
3980
+ }
3981
+ const confirmed = await confirm({
3982
+ message: t("uninstall_confirm_prompt").replace("{count}", chalk5.bold(String(toUninstall.length))),
3983
+ default: false
3984
+ });
3985
+ if (!confirmed) return "cancel";
3986
+ return { toUninstall, toKeep: [...keptSet] };
3987
+ }
3988
+ if (action === CONTINUE_SELECT) {
3989
+ step = 0;
3990
+ break;
3991
+ }
3992
+ if (action === "back") {
3993
+ step = 0;
3994
+ break;
3995
+ }
3996
+ return "cancel";
3997
+ }
3998
+ }
3871
3999
  }
3872
- return { toUninstall, toKeep };
3873
4000
  }
3874
4001
  function listAllSkills() {
3875
4002
  const categories = getAllCategories();
@@ -4909,7 +5036,6 @@ async function uninstallRecent(tool, level, yes) {
4909
5036
  async function uninstallInteractive(defaultTool, defaultLevel) {
4910
5037
  let tool = defaultTool;
4911
5038
  let level = defaultLevel;
4912
- printBoxTitle(t("uninstall_interactive_title"));
4913
5039
  const typeChoices = [
4914
5040
  { name: `> ${t("uninstall_type_skill")}`, value: "skill" },
4915
5041
  { name: `> ${t("uninstall_type_plugin")}`, value: "plugin" },