@cannbot-ai/install-helper 1.1.4 → 1.1.5-beta.0

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
@@ -16,7 +16,7 @@ import { readdirSync, existsSync } from "fs";
16
16
  import { join } from "path";
17
17
 
18
18
  // src/utils/fs-helpers.ts
19
- import { lstatSync, statSync } from "fs";
19
+ import { lstatSync, statSync, unlinkSync, rmSync } from "fs";
20
20
  function isSymlink(path) {
21
21
  try {
22
22
  return lstatSync(path).isSymbolicLink();
@@ -31,6 +31,17 @@ function isDirectory(path) {
31
31
  return false;
32
32
  }
33
33
  }
34
+ function removePath(p) {
35
+ try {
36
+ const stat = lstatSync(p);
37
+ if (stat.isDirectory()) {
38
+ rmSync(p, { recursive: true, force: true });
39
+ } else {
40
+ unlinkSync(p);
41
+ }
42
+ } catch {
43
+ }
44
+ }
34
45
 
35
46
  // src/embedded-plugins.json
36
47
  var embedded_plugins_default = [
@@ -1827,7 +1838,7 @@ async function stepConfirm(tool, level, plugins) {
1827
1838
  }
1828
1839
 
1829
1840
  // src/core/repository.ts
1830
- import { existsSync as existsSync10, mkdirSync as mkdirSync3, readFileSync as readFileSync6, rmSync } from "fs";
1841
+ import { existsSync as existsSync10, mkdirSync as mkdirSync3, readFileSync as readFileSync6, rmSync as rmSync2 } from "fs";
1831
1842
  import { join as join9, dirname as dirname4 } from "path";
1832
1843
  import { fileURLToPath as fileURLToPath3 } from "url";
1833
1844
  import { execa as execa2 } from "execa";
@@ -2477,7 +2488,7 @@ var RepositoryManager = class {
2477
2488
  this.repoPath = targetPath;
2478
2489
  return targetPath;
2479
2490
  }
2480
- rmSync(targetPath, { recursive: true, force: true });
2491
+ rmSync2(targetPath, { recursive: true, force: true });
2481
2492
  }
2482
2493
  try {
2483
2494
  logger.info(t("repo_cloning"));
@@ -2505,7 +2516,7 @@ import { join as join13, basename as basename2 } from "path";
2505
2516
  import { execa as execa4, execaSync } from "execa";
2506
2517
 
2507
2518
  // src/core/record.ts
2508
- import { existsSync as existsSync11, mkdirSync as mkdirSync4, readFileSync as readFileSync7, unlinkSync } from "fs";
2519
+ import { existsSync as existsSync11, mkdirSync as mkdirSync4, readFileSync as readFileSync7, unlinkSync as unlinkSync2 } from "fs";
2509
2520
  import { join as join10 } from "path";
2510
2521
  function getInstallsDir() {
2511
2522
  return join10(getCannbotConfigDir(), "installs");
@@ -2537,7 +2548,7 @@ function writeRecord(record) {
2537
2548
  function deleteRecord(pluginId) {
2538
2549
  const recordPath = getRecordPath(pluginId);
2539
2550
  if (existsSync11(recordPath)) {
2540
- unlinkSync(recordPath);
2551
+ unlinkSync2(recordPath);
2541
2552
  }
2542
2553
  }
2543
2554
  function scanInstalledFiles(pluginId, displayName, tool, level, installPath, configRoot, manifest, externalRepoNames) {
@@ -2676,7 +2687,7 @@ function getInstalledSkills(tool, level, installPath) {
2676
2687
  }
2677
2688
 
2678
2689
  // src/core/backup.ts
2679
- import { existsSync as existsSync12, copyFileSync, readdirSync as readdirSync3, unlinkSync as unlinkSync2 } from "fs";
2690
+ import { existsSync as existsSync12, copyFileSync, readdirSync as readdirSync3, unlinkSync as unlinkSync3 } from "fs";
2680
2691
  import { join as join11 } from "path";
2681
2692
  function detectCurrentPlugin(configRoot, tool, installPath) {
2682
2693
  const manifests = readAllManifests(configRoot);
@@ -2775,7 +2786,7 @@ function restoreBackup(backupPath, configRoot, tool) {
2775
2786
  function deleteBackup(backupPath) {
2776
2787
  try {
2777
2788
  if (existsSync12(backupPath)) {
2778
- unlinkSync2(backupPath);
2789
+ unlinkSync3(backupPath);
2779
2790
  return true;
2780
2791
  }
2781
2792
  return false;
@@ -2843,7 +2854,7 @@ async function showRestorePrompt(backups) {
2843
2854
  }
2844
2855
 
2845
2856
  // src/core/plugin-installer.ts
2846
- import { existsSync as existsSync13, mkdirSync as mkdirSync5, symlinkSync, unlinkSync as unlinkSync3, realpathSync, readlinkSync, copyFileSync as copyFileSync2, cpSync, writeFileSync as writeFileSync2, rmSync as rmSync2 } from "fs";
2857
+ import { existsSync as existsSync13, mkdirSync as mkdirSync5, symlinkSync, realpathSync, readlinkSync, copyFileSync as copyFileSync2, cpSync, writeFileSync as writeFileSync2, rmSync as rmSync3 } from "fs";
2847
2858
  import { join as join12, basename } from "path";
2848
2859
  import { execa as execa3 } from "execa";
2849
2860
  function installLink(source, target) {
@@ -2862,7 +2873,7 @@ function installLink(source, target) {
2862
2873
  }
2863
2874
  }
2864
2875
  if (existsSync13(target) || isSymlink(target)) {
2865
- unlinkSync3(target);
2876
+ removePath(target);
2866
2877
  }
2867
2878
  try {
2868
2879
  symlinkSync(resolved, target);
@@ -2892,7 +2903,7 @@ function installConfigFile(pluginDir, configFile, tool, level, configRoot, insta
2892
2903
  try {
2893
2904
  const resolvedSource = realpathSync(sourcePath);
2894
2905
  if (existsSync13(primaryTarget) || isSymlink(primaryTarget)) {
2895
- unlinkSync3(primaryTarget);
2906
+ removePath(primaryTarget);
2896
2907
  }
2897
2908
  try {
2898
2909
  symlinkSync(resolvedSource, primaryTarget);
@@ -2910,7 +2921,7 @@ function installConfigFile(pluginDir, configFile, tool, level, configRoot, insta
2910
2921
  if (configRootConfigLink === false) return;
2911
2922
  const configRootTarget = join12(configRoot, agentsFileName);
2912
2923
  if (existsSync13(configRootTarget) || isSymlink(configRootTarget)) {
2913
- unlinkSync3(configRootTarget);
2924
+ removePath(configRootTarget);
2914
2925
  }
2915
2926
  try {
2916
2927
  symlinkSync(realpathSync(sourcePath), configRootTarget);
@@ -2946,7 +2957,7 @@ async function installExternalRepos(repos, repoPath, configRoot, installPath, le
2946
2957
  } catch {
2947
2958
  logger.warn(t("install_clone_failed").replace("{url}", repo.url).replace("{dir}", repo.dir));
2948
2959
  try {
2949
- rmSync2(targetDir, { recursive: true, force: true });
2960
+ rmSync3(targetDir, { recursive: true, force: true });
2950
2961
  } catch {
2951
2962
  }
2952
2963
  continue;
@@ -2959,7 +2970,7 @@ async function installExternalRepos(repos, repoPath, configRoot, installPath, le
2959
2970
  const configRootLink = join12(configRoot, linkName);
2960
2971
  try {
2961
2972
  if (existsSync13(configRootLink) || isSymlink(configRootLink)) {
2962
- unlinkSync3(configRootLink);
2973
+ removePath(configRootLink);
2963
2974
  }
2964
2975
  try {
2965
2976
  symlinkSync(resolved, configRootLink);
@@ -2976,7 +2987,7 @@ async function installExternalRepos(repos, repoPath, configRoot, installPath, le
2976
2987
  const projectLink = join12(installPath, linkName);
2977
2988
  try {
2978
2989
  if (existsSync13(projectLink) || isSymlink(projectLink)) {
2979
- unlinkSync3(projectLink);
2990
+ removePath(projectLink);
2980
2991
  }
2981
2992
  try {
2982
2993
  symlinkSync(resolved, projectLink);
@@ -2998,7 +3009,7 @@ function installWorkflows(pluginDir, configRoot) {
2998
3009
  try {
2999
3010
  const resolved = realpathSync(workflowsDir);
3000
3011
  if (existsSync13(targetPath) || isSymlink(targetPath)) {
3001
- unlinkSync3(targetPath);
3012
+ removePath(targetPath);
3002
3013
  }
3003
3014
  try {
3004
3015
  symlinkSync(resolved, targetPath);
@@ -3319,7 +3330,7 @@ async function installPlugin(opts) {
3319
3330
  }
3320
3331
 
3321
3332
  // src/core/skill-installer.ts
3322
- import { existsSync as existsSync15, mkdirSync as mkdirSync6, symlinkSync as symlinkSync2, unlinkSync as unlinkSync4, readdirSync as readdirSync4, rmSync as rmSync3, realpathSync as realpathSync2, readlinkSync as readlinkSync2, cpSync as cpSync2 } from "fs";
3333
+ import { existsSync as existsSync15, mkdirSync as mkdirSync6, symlinkSync as symlinkSync2, readdirSync as readdirSync4, rmSync as rmSync4, realpathSync as realpathSync2, readlinkSync as readlinkSync2, cpSync as cpSync2 } from "fs";
3323
3334
  import { join as join14, dirname as dirname5, isAbsolute } from "path";
3324
3335
  import { select as select3, checkbox, Separator as Separator2 } from "@inquirer/prompts";
3325
3336
  import chalk5 from "chalk";
@@ -3364,7 +3375,7 @@ async function installSkills(skillIds, tool, level, repoPath) {
3364
3375
  }
3365
3376
  }
3366
3377
  if (existsSync15(targetPath) || isSymlink(targetPath)) {
3367
- unlinkSync4(targetPath);
3378
+ removePath(targetPath);
3368
3379
  }
3369
3380
  try {
3370
3381
  symlinkSync2(resolvedSource, targetPath);
@@ -3400,7 +3411,7 @@ async function uninstallSkills(skillIds, tool, level) {
3400
3411
  const targetPath = join14(skillsDir, skillId);
3401
3412
  try {
3402
3413
  if (existsSync15(targetPath) || isSymlink(targetPath)) {
3403
- unlinkSync4(targetPath);
3414
+ removePath(targetPath);
3404
3415
  results.push({ skillId, success: true });
3405
3416
  removedIds.push(skillId);
3406
3417
  logger.step(` ${t("uninstall_remove_label")}: ${skillId}`);
@@ -3419,7 +3430,7 @@ async function uninstallSkills(skillIds, tool, level) {
3419
3430
  try {
3420
3431
  const entries = readdirSync4(skillsDir);
3421
3432
  if (entries.length === 0) {
3422
- rmSync3(skillsDir, { recursive: true });
3433
+ rmSync4(skillsDir, { recursive: true });
3423
3434
  logger.step(` ${t("uninstall_clean_empty_dir")}: skills/`);
3424
3435
  }
3425
3436
  } catch {
@@ -3938,7 +3949,7 @@ async function listCommand() {
3938
3949
 
3939
3950
  // src/commands/doctor.ts
3940
3951
  import chalk8 from "chalk";
3941
- import { existsSync as existsSync17, readdirSync as readdirSync5, lstatSync as lstatSync2, unlinkSync as unlinkSync5, mkdirSync as mkdirSync7 } from "fs";
3952
+ import { existsSync as existsSync17, readdirSync as readdirSync5, lstatSync as lstatSync2, unlinkSync as unlinkSync6, mkdirSync as mkdirSync7 } from "fs";
3942
3953
  import { join as join16 } from "path";
3943
3954
  async function doctorCommand(options = {}) {
3944
3955
  console.log();
@@ -4094,7 +4105,7 @@ function fixBrokenLinks(dir) {
4094
4105
  const stats = lstatSync2(fullPath);
4095
4106
  if (stats.isSymbolicLink()) {
4096
4107
  if (!existsSync17(fullPath)) {
4097
- unlinkSync5(fullPath);
4108
+ unlinkSync6(fullPath);
4098
4109
  fixed++;
4099
4110
  }
4100
4111
  }
@@ -4464,7 +4475,7 @@ async function installPlugins(pluginIds, tool, level, repoPath, installPath, yes
4464
4475
  }
4465
4476
 
4466
4477
  // src/commands/uninstall.ts
4467
- import { existsSync as existsSync18, unlinkSync as unlinkSync6, rmdirSync, readdirSync as readdirSync6 } from "fs";
4478
+ import { existsSync as existsSync18, unlinkSync as unlinkSync7, rmdirSync, readdirSync as readdirSync6 } from "fs";
4468
4479
  import { resolve, basename as basename3, sep } from "path";
4469
4480
  import chalk11 from "chalk";
4470
4481
  async function uninstallCommand(names, options) {
@@ -4507,7 +4518,7 @@ async function uninstallCommand(names, options) {
4507
4518
  if (!isSafePath(filePath)) continue;
4508
4519
  try {
4509
4520
  if (existsSync18(filePath) || isSymlink(filePath)) {
4510
- unlinkSync6(filePath);
4521
+ unlinkSync7(filePath);
4511
4522
  const name = basename3(filePath);
4512
4523
  logger.step(` ${t("uninstall_remove_label")}: ${name}`);
4513
4524
  removedFiles++;
@@ -4580,17 +4591,21 @@ async function uninstallCommand(names, options) {
4580
4591
  // src/commands/update.ts
4581
4592
  import chalk12 from "chalk";
4582
4593
  async function updateCommand(pluginNames, options) {
4594
+ const repoManager = createRepositoryManager();
4595
+ const updateSpinner = createSpinner(t("update_updating") + "...");
4596
+ updateSpinner.start();
4597
+ let repoPath;
4598
+ try {
4599
+ repoPath = await repoManager.ensureRepoAndScan();
4600
+ updateSpinner.succeed(t("install_repo_ready"));
4601
+ } catch (error) {
4602
+ updateSpinner.fail(t("repo_clone_failed").replace("{error}", error instanceof Error ? error.message : t("error_unknown")).replace("{url}", "").replace("{dir}", ""));
4603
+ return;
4604
+ }
4583
4605
  const installed = scanInstalled();
4584
4606
  let targets = [];
4585
4607
  if (pluginNames.length === 0) {
4586
4608
  if (installed.length === 0) {
4587
- if (!options.tool) {
4588
- const detected = await selectToolWithDetection();
4589
- if (detected === "back" || detected === "cancel") {
4590
- logger.info(t("init_cancelled"));
4591
- return;
4592
- }
4593
- }
4594
4609
  logger.info(t("update_no_plugins"));
4595
4610
  logger.info(t("update_install_hint").replace("{cmd}", chalk12.cyan("install-helper install <plugin>")));
4596
4611
  return;
@@ -4627,17 +4642,6 @@ async function updateCommand(pluginNames, options) {
4627
4642
  logger.info(t("update_no_plugins"));
4628
4643
  return;
4629
4644
  }
4630
- const repoManager = createRepositoryManager();
4631
- const updateSpinner = createSpinner(t("update_updating") + "...");
4632
- updateSpinner.start();
4633
- let repoPath;
4634
- try {
4635
- repoPath = await repoManager.ensureRepoAndScan();
4636
- updateSpinner.succeed(t("install_repo_ready"));
4637
- } catch (error) {
4638
- updateSpinner.fail(t("repo_clone_failed").replace("{error}", error instanceof Error ? error.message : t("error_unknown")).replace("{url}", "").replace("{dir}", ""));
4639
- return;
4640
- }
4641
4645
  const allPlugins = getAllPlugins();
4642
4646
  const results = [];
4643
4647
  const total = targets.length;