@cannbot-ai/install-helper 1.2.0-beta.1 → 1.2.0-beta.3

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
@@ -2081,6 +2081,8 @@ var init_constants = __esm({
2081
2081
  // src/ui/wizard.ts
2082
2082
  var wizard_exports = {};
2083
2083
  __export(wizard_exports, {
2084
+ decodePluginChoice: () => decodePluginChoice,
2085
+ encodePluginChoice: () => encodePluginChoice,
2084
2086
  runWizard: () => runWizard,
2085
2087
  selectToolWithDetection: () => selectToolWithDetection,
2086
2088
  stepLevel: () => stepLevel
@@ -2099,6 +2101,14 @@ async function selectToolWithDetection() {
2099
2101
  if (result === CANCEL) return "cancel";
2100
2102
  return result;
2101
2103
  }
2104
+ function encodePluginChoice(id, source) {
2105
+ return source === "cannbot" ? `cannbot::${id}` : `skills::${id}`;
2106
+ }
2107
+ function decodePluginChoice(value) {
2108
+ if (value.startsWith("cannbot::")) return { id: value.slice("cannbot::".length), source: "cannbot" };
2109
+ if (value.startsWith("skills::")) return { id: value.slice("skills::".length), source: "skills" };
2110
+ return { id: value, source: "skills" };
2111
+ }
2102
2112
  async function runWizard() {
2103
2113
  const config = readConfig();
2104
2114
  logger.blank();
@@ -2273,7 +2283,7 @@ async function stepPlugins(tool, level) {
2273
2283
  const badge = p.source === "cannbot" ? chalk3.magenta(" [cannbot]") : "";
2274
2284
  return {
2275
2285
  name: `> ${chalk3.cyan(p.displayName)}${badge}${suffix}`,
2276
- value: p.id,
2286
+ value: encodePluginChoice(p.id, p.source),
2277
2287
  description: p.description
2278
2288
  };
2279
2289
  });
@@ -2295,7 +2305,10 @@ async function stepPlugins(tool, level) {
2295
2305
  async function stepConfirm(tool, level, plugins) {
2296
2306
  printBoxTitle(t("wizard_step_4_title"));
2297
2307
  const allPlugins = getAllPlugins();
2298
- const selectedPlugins = plugins.map((id) => allPlugins.find((p) => p.id === id));
2308
+ const selectedPlugins = plugins.map((value) => {
2309
+ const { id, source } = decodePluginChoice(value);
2310
+ return allPlugins.find((p) => p.id === id && (p.source ?? "skills") === source);
2311
+ });
2299
2312
  const displayPath = getConfigRoot(tool, level);
2300
2313
  const toolName = getToolDisplayName(tool);
2301
2314
  const levelText = level === "project" ? "project" : "global";
@@ -4563,6 +4576,14 @@ async function runDelegate(args, target) {
4563
4576
  };
4564
4577
  }
4565
4578
  }
4579
+ function installerSupportsBundledFlag() {
4580
+ try {
4581
+ const binSource = readFileSync12(getCannbotBinPath(), "utf-8");
4582
+ return binSource.includes('"--bundled"');
4583
+ } catch {
4584
+ return false;
4585
+ }
4586
+ }
4566
4587
  async function delegateInstall(options) {
4567
4588
  const { pluginId, tool, level } = options;
4568
4589
  const target = resolve2(options.target || process.cwd());
@@ -4606,7 +4627,7 @@ async function delegateInstall(options) {
4606
4627
  }
4607
4628
  result.warnings.push(...migrateSymlinkedInstructions(target, tool));
4608
4629
  let run = await runDelegate(["install", pluginId, "--tool", tool, "--target", target], target);
4609
- const hitRenameGap = !run.ok && (run.stdout.includes(`plugin not found: ${pluginId}`) || run.stderr.includes(`plugin not found: ${pluginId}`));
4630
+ const hitRenameGap = !run.ok && installerSupportsBundledFlag() && (run.stdout.includes(`plugin not found: ${pluginId}`) || run.stderr.includes(`plugin not found: ${pluginId}`));
4610
4631
  if (hitRenameGap) {
4611
4632
  result.warnings.push(t("cannbot_bundled_fallback"));
4612
4633
  run = await runDelegate(
@@ -4668,7 +4689,7 @@ async function delegateInstall(options) {
4668
4689
  return result;
4669
4690
  }
4670
4691
  async function installPluginRouted(options) {
4671
- const isCannbot = options.source === "cannbot" || options.plugin?.source === "cannbot";
4692
+ const isCannbot = options.source === "cannbot" || options.source !== "skills" && options.plugin?.source === "cannbot";
4672
4693
  if (isCannbot) {
4673
4694
  return delegateInstall({
4674
4695
  pluginId: options.pluginId,
@@ -5420,14 +5441,20 @@ async function pluginInstallFlow() {
5420
5441
  return "done";
5421
5442
  }
5422
5443
  const allPlugins = getAllPlugins();
5423
- const selectedPlugins = answers.plugins.map(
5424
- (id) => allPlugins.find((p) => p.id === id)
5425
- );
5444
+ const selected = answers.plugins.map((value) => {
5445
+ const { id, source } = decodePluginChoice(value);
5446
+ return {
5447
+ id,
5448
+ source,
5449
+ plugin: allPlugins.find((p) => p.id === id && (p.source ?? "skills") === source)
5450
+ };
5451
+ });
5426
5452
  const total = answers.plugins.length;
5427
5453
  const results = [];
5428
- for (let i = 0; i < answers.plugins.length; i++) {
5429
- const pluginId = answers.plugins[i];
5430
- const plugin = selectedPlugins[i];
5454
+ for (let i = 0; i < selected.length; i++) {
5455
+ const pluginId = selected[i].id;
5456
+ const source = selected[i].source;
5457
+ const plugin = selected[i].plugin;
5431
5458
  const displayName = plugin?.displayName || pluginId;
5432
5459
  const progress = `[${i + 1}/${total}]`;
5433
5460
  const pluginSpinner = createSpinner(`${progress} ${t("install_progress")} ${displayName}...`);
@@ -5437,7 +5464,8 @@ async function pluginInstallFlow() {
5437
5464
  tool: answers.tool,
5438
5465
  level: answers.level,
5439
5466
  repoPath,
5440
- plugin
5467
+ plugin,
5468
+ source
5441
5469
  });
5442
5470
  if (result.success) {
5443
5471
  pluginSpinner.succeed(
@@ -5456,7 +5484,7 @@ async function pluginInstallFlow() {
5456
5484
  }
5457
5485
  const summary = results.map((result, index) => ({
5458
5486
  pluginId: result.pluginId,
5459
- displayName: selectedPlugins[index]?.displayName || result.pluginId,
5487
+ displayName: selected[index]?.plugin?.displayName || result.pluginId,
5460
5488
  success: result.success,
5461
5489
  skillsCount: result.skillsCount,
5462
5490
  agentsCount: result.agentsCount
@@ -6216,7 +6244,7 @@ async function installPlugins(pluginIds, tool, level, repoPath, installPath, yes
6216
6244
  const progress = `[${i + 1}/${total}]`;
6217
6245
  const spinner = createSpinner(`${progress} ${t("install_progress")} ${pluginId}...`);
6218
6246
  spinner.start();
6219
- const plugin = findPlugin(pluginId);
6247
+ const plugin = findPlugin(pluginId, { source });
6220
6248
  const result = await installPluginRouted({
6221
6249
  pluginId,
6222
6250
  tool,
@@ -6796,12 +6824,13 @@ async function updateCommand(pluginNames, options) {
6796
6824
  }
6797
6825
  for (const name of pluginNames) {
6798
6826
  const cannbotMatches = cannbotInstalled.filter((e) => e.id === name);
6799
- const plugin = findPlugin(name);
6800
- if (cannbotMatches.length === 0 && !plugin) {
6827
+ const legacyPlugin = findPlugin(name, { source: "skills" });
6828
+ const anyPlugin = findPlugin(name);
6829
+ if (cannbotMatches.length === 0 && !legacyPlugin && !anyPlugin) {
6801
6830
  logger.error(`${t("error_plugin_not_found")}: ${name}`);
6802
6831
  continue;
6803
6832
  }
6804
- const legacyMatches = cannbotMatches.length === 0 && plugin && plugin.source !== "cannbot" ? installed.filter((p) => p.id === plugin.id) : [];
6833
+ const legacyMatches = cannbotMatches.length === 0 && legacyPlugin ? installed.filter((p) => p.id === legacyPlugin.id) : [];
6805
6834
  const matches = [
6806
6835
  ...cannbotMatches.map((e) => ({ pluginId: e.id, tool: e.tool, level: "project", source: "cannbot" })),
6807
6836
  ...legacyMatches.map((p) => ({ pluginId: p.id, tool: p.tool, level: p.level, source: "skills" }))
@@ -6813,7 +6842,8 @@ async function updateCommand(pluginNames, options) {
6813
6842
  targets.push(match);
6814
6843
  }
6815
6844
  } else {
6816
- logger.warn(`${plugin?.displayName || name} ${t("error_not_installed")}, ${t("update_skipped")}`);
6845
+ const displayName = cannbotMatches.length ? cannbotMatches[0].id : legacyPlugin?.displayName || anyPlugin?.displayName || name;
6846
+ logger.warn(`${displayName} ${t("error_not_installed")}, ${t("update_skipped")}`);
6817
6847
  }
6818
6848
  }
6819
6849
  }
@@ -6833,12 +6863,11 @@ async function updateCommand(pluginNames, options) {
6833
6863
  );
6834
6864
  }
6835
6865
  }
6836
- const allPlugins = getAllPlugins();
6837
6866
  const results = [];
6838
6867
  const total = targets.length;
6839
6868
  for (let i = 0; i < targets.length; i++) {
6840
6869
  const target = targets[i];
6841
- const plugin = allPlugins.find((p) => p.id === target.pluginId);
6870
+ const plugin = findPlugin(target.pluginId, { source: target.source });
6842
6871
  const displayName = plugin?.displayName || target.pluginId;
6843
6872
  const progress = `[${i + 1}/${total}]`;
6844
6873
  const pluginSpinner = createSpinner(`${progress} ${t("update_updating")} ${displayName}...`);
@@ -6866,8 +6895,9 @@ async function updateCommand(pluginNames, options) {
6866
6895
  }
6867
6896
  results.push(result);
6868
6897
  }
6869
- const summary = results.map((result) => {
6870
- const plugin = allPlugins.find((p) => p.id === result.pluginId);
6898
+ const summary = results.map((result, index) => {
6899
+ const source = targets[index]?.source;
6900
+ const plugin = source ? findPlugin(result.pluginId, { source }) : void 0;
6871
6901
  return {
6872
6902
  pluginId: result.pluginId,
6873
6903
  displayName: plugin?.displayName || result.pluginId,