@cannbot-ai/install-helper 1.1.6-beta.9 → 1.1.6

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/README.md CHANGED
@@ -125,13 +125,45 @@ install-helper uninstall --all --tool opencode --level project # 指定范围
125
125
 
126
126
  根据安装记录精确删除所有产物,自动清理空目录。
127
127
 
128
- 交互式卸载:已安装项全部预勾选(✓=保留),取消勾选后确认即可批量卸载。
128
+ **交互式卸载**:
129
+
130
+ ```bash
131
+ install-helper uninstall
132
+ ```
133
+
134
+ - 自动检测已安装内容,跳过只有单一选项的步骤(如仅一个工具/级别有内容时自动选中)
135
+ - 若 Skills 和 Plugins 都已安装,先选择卸载类型
136
+ - ≤15 个已安装 Skill 时显示扁平列表,>15 个时按类别导航
137
+ - **勾选=卸载**(标准 checkbox 语义),勾选后确认即可批量卸载
138
+ - 支持跨类别累积选择
139
+
140
+ **`--all` 一键卸载**:
141
+
142
+ ```bash
143
+ install-helper uninstall --all --yes
144
+ ```
145
+
146
+ 卸载指定范围内全部已安装的 Skills 和 Plugins。通过 `--tool` / `--level` 限定范围,未指定时默认 project 级别。
147
+
148
+ **`--recent` 批次卸载**:
149
+
150
+ ```bash
151
+ install-helper uninstall --recent --yes
152
+ ```
153
+
154
+ 仅卸载最近一次安装批次中的 Skills。每次 `install-helper install` 会自动记录安装批次,`--recent` 精确卸载最后一批,不影响更早安装的内容。
155
+
156
+ **安全机制**:
157
+
158
+ - 仅删除 `install-helper` 安装的 symlink,不影响用户手动创建的目录或文件
159
+ - 无安装记录时自动回退到文件系统扫描(识别 symlink)和 manifest 文件,确保残留内容可清理
160
+ - Plugin 卸载时完整清理 skills、agents、配置文件(AGENTS.md/CLAUDE.md)、manifest、外部仓库链接
129
161
 
130
162
  **选项:**
131
163
 
132
164
  | 选项 | 说明 |
133
165
  |------|------|
134
- | `--tool <tool>` | 指定 AI 工具 |
166
+ | `--tool <tool>` | 指定 AI 工具(opencode, claude, trae, cursor, copilot, codearts) |
135
167
  | `--level <level>` | 安装级别(project, global),默认 project |
136
168
  | `--yes` `-y` | 跳过确认提示 |
137
169
  | `--all` `-a` | 卸载全部已安装 Skills 和 Plugins |
package/dist/index.js CHANGED
@@ -1467,20 +1467,21 @@ function verifyPluginFilesExist(configRoot, manifest, tool, level) {
1467
1467
  if (manifest.installed_skills && manifest.installed_skills.length > 0) {
1468
1468
  const hasAnySkill = manifest.installed_skills.some((skillId) => {
1469
1469
  const skillPath = join5(skillsDir, skillId);
1470
- return existsSync5(skillPath);
1470
+ return existsSync5(skillPath) || isSymlink(skillPath);
1471
1471
  });
1472
1472
  if (hasAnySkill) hasAnyComponent = true;
1473
1473
  }
1474
1474
  if (manifest.installed_agents && manifest.installed_agents.length > 0) {
1475
1475
  const hasAnyAgent = manifest.installed_agents.some((agentId) => {
1476
1476
  const agentPath = join5(agentsDir, agentId);
1477
- return existsSync5(agentPath);
1477
+ const agentPathMd = join5(agentsDir, agentId + ".md");
1478
+ return existsSync5(agentPath) || isSymlink(agentPath) || existsSync5(agentPathMd) || isSymlink(agentPathMd);
1478
1479
  });
1479
1480
  if (hasAnyAgent) hasAnyComponent = true;
1480
1481
  }
1481
1482
  const agentsFileName = getAgentsFileName(tool);
1482
1483
  const configFilePath = level === "project" ? join5(configRoot, "..", agentsFileName) : join5(configRoot, agentsFileName);
1483
- if (existsSync5(configFilePath)) hasAnyComponent = true;
1484
+ if (existsSync5(configFilePath) || isSymlink(configFilePath)) hasAnyComponent = true;
1484
1485
  const pluginManifestPath = join5(configRoot, `${manifest.team}-manifest.json`);
1485
1486
  if (existsSync5(pluginManifestPath)) hasAnyComponent = true;
1486
1487
  return hasAnyComponent;
@@ -1490,6 +1491,7 @@ var init_manifest = __esm({
1490
1491
  "use strict";
1491
1492
  init_paths();
1492
1493
  init_registry();
1494
+ init_fs_helpers();
1493
1495
  }
1494
1496
  });
1495
1497
 
@@ -2854,12 +2856,14 @@ function addSkillsToRecord(skillIds, tool, level, installPath) {
2854
2856
  }
2855
2857
  }
2856
2858
  entry.installTime = now;
2857
- if (!entry.batches) entry.batches = [];
2858
- entry.batches.push({
2859
- batchId: `batch-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`,
2860
- installedAt: now,
2861
- skills: newSkills.length > 0 ? newSkills : [...skillIds]
2862
- });
2859
+ if (newSkills.length > 0) {
2860
+ if (!entry.batches) entry.batches = [];
2861
+ entry.batches.push({
2862
+ batchId: `batch-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`,
2863
+ installedAt: now,
2864
+ skills: newSkills
2865
+ });
2866
+ }
2863
2867
  writeSkillRecord(record);
2864
2868
  }
2865
2869
  function removeSkillsFromRecord(skillIds, tool, level, installPath) {
@@ -4991,7 +4995,7 @@ async function installPlugins(pluginIds, tool, level, repoPath, installPath, yes
4991
4995
 
4992
4996
  // src/commands/uninstall.ts
4993
4997
  init_registry();
4994
- import { existsSync as existsSync18, unlinkSync as unlinkSync6, rmdirSync, readdirSync as readdirSync7 } from "fs";
4998
+ import { existsSync as existsSync18, unlinkSync as unlinkSync6, rmdirSync, readdirSync as readdirSync7, readFileSync as readFileSync9 } from "fs";
4995
4999
  import { resolve, basename as basename3, sep, join as join18 } from "path";
4996
5000
  import chalk11 from "chalk";
4997
5001
  import { select as select5, checkbox as checkbox2, Separator as Separator4, confirm as confirm3 } from "@inquirer/prompts";
@@ -5004,6 +5008,8 @@ init_manifest();
5004
5008
  init_theme();
5005
5009
  init_wizard();
5006
5010
  async function uninstallCommand(names, options) {
5011
+ const userSpecifiedTool = !!options.tool;
5012
+ const userSpecifiedLevel = !!options.level;
5007
5013
  const tool = options.tool ? validateTool(options.tool) : "opencode";
5008
5014
  const level = options.level ? validateLevel(options.level) : "project";
5009
5015
  if (options.all) {
@@ -5015,7 +5021,7 @@ async function uninstallCommand(names, options) {
5015
5021
  return;
5016
5022
  }
5017
5023
  if (names.length === 0) {
5018
- await uninstallInteractive(tool, level);
5024
+ await uninstallInteractive(tool, level, userSpecifiedTool, userSpecifiedLevel);
5019
5025
  return;
5020
5026
  }
5021
5027
  const plugins = [];
@@ -5107,18 +5113,18 @@ async function uninstallRecent(tool, level, yes) {
5107
5113
  logger.success(t("skill_uninstall_done"));
5108
5114
  logger.blank();
5109
5115
  }
5110
- async function uninstallInteractive(defaultTool, defaultLevel) {
5116
+ async function uninstallInteractive(defaultTool, defaultLevel, userSpecifiedTool, userSpecifiedLevel) {
5111
5117
  let tool = defaultTool;
5112
5118
  let level = defaultLevel;
5113
5119
  const allInstalledPlugins = scanInstalled();
5114
5120
  const toolsWithPlugins = new Set(allInstalledPlugins.map((p) => `${p.tool}:${p.level}`));
5115
5121
  const toolsWithSkills = /* @__PURE__ */ new Set();
5116
- for (const t2 of ["opencode", "claude", "trae", "cursor", "copilot", "codearts"]) {
5117
- for (const l of ["project", "global"]) {
5118
- const ip = l === "project" ? process.cwd() : getConfigRoot(t2, l);
5119
- const skills = getInstalledSkills(t2, l, ip);
5122
+ for (const toolName of ["opencode", "claude", "trae", "cursor", "copilot", "codearts"]) {
5123
+ for (const lvl of ["project", "global"]) {
5124
+ const ip = lvl === "project" ? process.cwd() : getConfigRoot(toolName, lvl);
5125
+ const skills = getInstalledSkills(toolName, lvl, ip);
5120
5126
  if (skills.length > 0) {
5121
- toolsWithSkills.add(`${t2}:${l}`);
5127
+ toolsWithSkills.add(`${toolName}:${lvl}`);
5122
5128
  }
5123
5129
  }
5124
5130
  }
@@ -5132,9 +5138,9 @@ async function uninstallInteractive(defaultTool, defaultLevel) {
5132
5138
  if (hasSkills && hasPlugins) {
5133
5139
  printBoxTitle(t("uninstall_interactive_title"));
5134
5140
  const skillCount = [...toolsWithSkills].reduce((sum, key) => {
5135
- const [t2, l] = key.split(":");
5136
- const ip = l === "project" ? process.cwd() : getConfigRoot(t2, l);
5137
- return sum + getInstalledSkills(t2, l, ip).length;
5141
+ const [toolName, lvl] = key.split(":");
5142
+ const ip = lvl === "project" ? process.cwd() : getConfigRoot(toolName, lvl);
5143
+ return sum + getInstalledSkills(toolName, lvl, ip).length;
5138
5144
  }, 0);
5139
5145
  const pluginCount = allInstalledPlugins.length;
5140
5146
  const typeChoices = [
@@ -5167,7 +5173,9 @@ async function uninstallInteractive(defaultTool, defaultLevel) {
5167
5173
  }
5168
5174
  if (toolsWithContent.size === 1) {
5169
5175
  tool = [...toolsWithContent][0];
5170
- } else if (!process.env.INSTALL_HELPER_TOOL) {
5176
+ } else if (userSpecifiedTool && toolsWithContent.has(defaultTool)) {
5177
+ tool = defaultTool;
5178
+ } else {
5171
5179
  const detected = await selectToolWithDetection();
5172
5180
  if (detected === "back" || detected === "cancel") {
5173
5181
  logger.info(t("init_cancelled"));
@@ -5177,14 +5185,16 @@ async function uninstallInteractive(defaultTool, defaultLevel) {
5177
5185
  }
5178
5186
  const levelsWithContent = /* @__PURE__ */ new Set();
5179
5187
  for (const key of relevantKeys) {
5180
- const [t2, l] = key.split(":");
5181
- if (t2 === tool) {
5182
- levelsWithContent.add(l);
5188
+ const [toolName, lvl] = key.split(":");
5189
+ if (toolName === tool) {
5190
+ levelsWithContent.add(lvl);
5183
5191
  }
5184
5192
  }
5185
5193
  if (levelsWithContent.size === 1) {
5186
5194
  level = [...levelsWithContent][0];
5187
- } else if (!process.env.INSTALL_HELPER_LEVEL) {
5195
+ } else if (userSpecifiedLevel && levelsWithContent.has(defaultLevel)) {
5196
+ level = defaultLevel;
5197
+ } else {
5188
5198
  const { stepLevel: stepLevel2 } = await Promise.resolve().then(() => (init_wizard(), wizard_exports));
5189
5199
  const levelResult = await stepLevel2();
5190
5200
  if (levelResult === "__back__" || levelResult === "__cancel__") {
@@ -5267,7 +5277,36 @@ async function uninstallPlugins(pluginIds, batchMode) {
5267
5277
  async function uninstallPluginById(pluginId, batchMode) {
5268
5278
  const plugin = findPlugin(pluginId);
5269
5279
  if (!plugin) return;
5270
- const record = readRecord(plugin.id);
5280
+ let record = readRecord(plugin.id);
5281
+ if (!record) {
5282
+ for (const toolName of VALID_TOOLS) {
5283
+ for (const lvl of ["project", "global"]) {
5284
+ const configRoot2 = getConfigRoot(toolName, lvl);
5285
+ const manifestPath = join18(configRoot2, `${pluginId}-manifest.json`);
5286
+ if (!existsSync18(manifestPath)) continue;
5287
+ let manifest = null;
5288
+ try {
5289
+ manifest = JSON.parse(readFileSync9(manifestPath, "utf-8"));
5290
+ } catch {
5291
+ continue;
5292
+ }
5293
+ const installPath = lvl === "project" ? process.cwd() : configRoot2;
5294
+ record = scanInstalledFiles(
5295
+ pluginId,
5296
+ plugin.displayName,
5297
+ toolName,
5298
+ lvl,
5299
+ installPath,
5300
+ configRoot2,
5301
+ manifest,
5302
+ plugin.externalRepos?.map((r) => basename3(r.dir)),
5303
+ plugin.configRootConfigLink
5304
+ );
5305
+ break;
5306
+ }
5307
+ if (record) break;
5308
+ }
5309
+ }
5271
5310
  if (!record) {
5272
5311
  logger.warn(`${plugin.displayName} ${t("uninstall_no_record")}`);
5273
5312
  logger.info(`${t("uninstall_no_record_hint")}`);
@@ -5559,7 +5598,7 @@ async function langCommand(action, value) {
5559
5598
  // src/cli.ts
5560
5599
  init_config();
5561
5600
  init_i18n();
5562
- import { readFileSync as readFileSync9, existsSync as existsSync20 } from "fs";
5601
+ import { readFileSync as readFileSync10, existsSync as existsSync20 } from "fs";
5563
5602
  import { fileURLToPath as fileURLToPath4 } from "url";
5564
5603
  import { dirname as dirname6, join as join20 } from "path";
5565
5604
  function readVersion() {
@@ -5579,7 +5618,7 @@ function readVersion() {
5579
5618
  ];
5580
5619
  for (const pkgPath of candidates) {
5581
5620
  if (existsSync20(pkgPath)) {
5582
- const pkg = JSON.parse(readFileSync9(pkgPath, "utf-8"));
5621
+ const pkg = JSON.parse(readFileSync10(pkgPath, "utf-8"));
5583
5622
  if (pkg.version && (pkg.name === "@cannbot-ai/install-helper" || pkg.name?.startsWith("@cannbot-ai/install-helper-"))) {
5584
5623
  return pkg.version;
5585
5624
  }