@cannbot-ai/install-helper 0.0.2-beta.35 → 0.0.2-beta.37

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.
@@ -24,3 +24,5 @@ scanDirs:
24
24
  pluginDirs:
25
25
  - plugins-official
26
26
  - plugins-community
27
+
28
+ scanCacheTtlHours: 24
package/dist/index.js CHANGED
@@ -417,8 +417,9 @@ async function getCommandVersion(cmd, args = ["--version"]) {
417
417
  }
418
418
  async function getCommandPath(cmd) {
419
419
  try {
420
- const result = await execa("which", [cmd], { timeout: 5e3 });
421
- return result.stdout.trim();
420
+ const whichCmd = process.platform === "win32" ? "where" : "which";
421
+ const result = await execa(whichCmd, [cmd], { timeout: 5e3 });
422
+ return result.stdout.trim().split("\n")[0];
422
423
  } catch {
423
424
  return void 0;
424
425
  }
@@ -979,14 +980,17 @@ function loadScanConfig() {
979
980
  const configPath = join7(__dirname3, "config", "repository.yaml");
980
981
  try {
981
982
  const config = parseYaml2(readFileSync5(configPath, "utf-8"));
983
+ const ttlHours = config.scanCacheTtlHours || 24;
982
984
  return {
983
985
  skillDirs: config.scanDirs || ["ops", "model", "graph", "infra", "ops-lab", "runtime"],
984
- pluginDirs: config.pluginDirs || ["plugins-official", "plugins-community"]
986
+ pluginDirs: config.pluginDirs || ["plugins-official", "plugins-community"],
987
+ cacheTtlMs: ttlHours * 60 * 60 * 1e3
985
988
  };
986
989
  } catch {
987
990
  return {
988
991
  skillDirs: ["ops", "model", "graph", "infra", "ops-lab", "runtime"],
989
- pluginDirs: ["plugins-official", "plugins-community"]
992
+ pluginDirs: ["plugins-official", "plugins-community"],
993
+ cacheTtlMs: 24 * 60 * 60 * 1e3
990
994
  };
991
995
  }
992
996
  }
@@ -1098,7 +1102,7 @@ function readScanCache() {
1098
1102
  const cache = JSON.parse(content);
1099
1103
  if (!cache.skills || !cache.timestamp) return null;
1100
1104
  const age = Date.now() - cache.timestamp;
1101
- if (age > 24 * 60 * 60 * 1e3) return null;
1105
+ if (age > scanConfig.cacheTtlMs) return null;
1102
1106
  return cache;
1103
1107
  } catch {
1104
1108
  return null;
@@ -1906,13 +1910,14 @@ async function installPlugin(opts) {
1906
1910
  }
1907
1911
  }
1908
1912
  try {
1913
+ const shell = process.platform === "win32" ? "sh" : "bash";
1909
1914
  const execOptions = {
1910
1915
  cwd,
1911
1916
  timeout: 3e5,
1912
1917
  stdio: "pipe",
1913
1918
  input: opts.yes ? "y\n" : void 0
1914
1919
  };
1915
- await execa3("bash", [scriptPath, ...args], execOptions);
1920
+ await execa3(shell, [scriptPath, ...args], execOptions);
1916
1921
  const manifest = readManifest(configRoot);
1917
1922
  let skillsCount = 0;
1918
1923
  let agentsCount = 0;
@@ -2002,7 +2007,11 @@ async function installSkills(skillIds, tool, level, repoPath) {
2002
2007
  results.push({ skillId, success: true });
2003
2008
  installedIds.push(skillId);
2004
2009
  } catch (error) {
2005
- results.push({ skillId, success: false, error: error instanceof Error ? error.message : t("error_unknown") });
2010
+ let msg = error instanceof Error ? error.message : t("error_unknown");
2011
+ if (process.platform === "win32" && msg.includes("EPERM")) {
2012
+ msg = t("error_symlink_windows");
2013
+ }
2014
+ results.push({ skillId, success: false, error: msg });
2006
2015
  }
2007
2016
  }
2008
2017
  if (installedIds.length > 0) {
@@ -3032,7 +3041,7 @@ async function installPlugins(pluginIds, tool, level, repoPath, installPath, yes
3032
3041
 
3033
3042
  // src/commands/uninstall.ts
3034
3043
  import { existsSync as existsSync15, unlinkSync as unlinkSync6, rmdirSync as rmdirSync2, readdirSync as readdirSync6 } from "fs";
3035
- import { resolve } from "path";
3044
+ import { resolve, basename } from "path";
3036
3045
  import chalk11 from "chalk";
3037
3046
  async function uninstallCommand(names, options) {
3038
3047
  const tool = options.tool ? validateTool(options.tool) : "opencode";
@@ -3075,7 +3084,7 @@ async function uninstallCommand(names, options) {
3075
3084
  try {
3076
3085
  if (existsSync15(filePath) || isSymlink(filePath)) {
3077
3086
  unlinkSync6(filePath);
3078
- const name = filePath.split("/").pop() || filePath;
3087
+ const name = basename(filePath);
3079
3088
  logger.step(` ${t("uninstall_remove_label")}: ${name}`);
3080
3089
  removedFiles++;
3081
3090
  }
@@ -3092,7 +3101,7 @@ async function uninstallCommand(names, options) {
3092
3101
  const entries = readdirSync6(dirPath);
3093
3102
  if (entries.length === 0) {
3094
3103
  rmdirSync2(dirPath);
3095
- const name = dirPath.split("/").pop() || dirPath;
3104
+ const name = basename(dirPath);
3096
3105
  logger.step(` ${t("uninstall_clean_empty_dir")}: ${name}/`);
3097
3106
  removedDirs++;
3098
3107
  }
@@ -3182,9 +3191,7 @@ async function updateCommand(pluginNames, options) {
3182
3191
  const repoManager = createRepositoryManager();
3183
3192
  const updateSpinner = createSpinner(t("update_updating") + "...");
3184
3193
  updateSpinner.start();
3185
- await repoManager.updateRepo();
3186
- const repoPath = repoManager.getRepoPath();
3187
- await repoManager.ensureRepoAndScan();
3194
+ const repoPath = await repoManager.ensureRepoAndScan();
3188
3195
  updateSpinner.succeed(t("install_repo_ready"));
3189
3196
  const allPlugins = getAllPlugins();
3190
3197
  const results = [];
@@ -3238,7 +3245,8 @@ async function infoCommand(pluginName) {
3238
3245
  return;
3239
3246
  }
3240
3247
  const installed = scanInstalled();
3241
- const isInstalled = installed.some((p) => p.id === plugin.id);
3248
+ const inst = installed.find((p) => p.id === plugin.id);
3249
+ const isInstalled = !!inst;
3242
3250
  const statusText = isInstalled ? chalk13.green(`\u2713 ${t("status_installed")}`) : chalk13.dim(`\u2014 ${t("status_not_installed")}`);
3243
3251
  console.log();
3244
3252
  console.log(chalk13.bold(` ${plugin.displayName}`));
@@ -3247,8 +3255,8 @@ async function infoCommand(pluginName) {
3247
3255
  console.log(` ${chalk13.dim(t("info_description") + ":")} ${plugin.description}`);
3248
3256
  console.log(` ${chalk13.dim("ID:")} ${plugin.id}`);
3249
3257
  console.log(` ${chalk13.dim(t("info_status") + ":")} ${statusText}`);
3250
- console.log(` ${chalk13.dim(t("info_skills") + ":")} ${plugin.skills}`);
3251
- console.log(` ${chalk13.dim(t("info_agents") + ":")} ${plugin.agents}`);
3258
+ console.log(` ${chalk13.dim(t("info_skills") + ":")} ${inst ? inst.skillsCount : plugin.skills}`);
3259
+ console.log(` ${chalk13.dim(t("info_agents") + ":")} ${inst ? inst.agentsCount : plugin.agents}`);
3252
3260
  console.log(` ${chalk13.dim(t("info_aliases") + ":")} ${plugin.aliases.join(", ")}`);
3253
3261
  console.log();
3254
3262
  try {