Просмотр исходного кода

fix(install): preserve legacy skill installer API

Alvin Unreal 1 месяц назад
Родитель
Сommit
04680ee186
3 измененных файлов с 18 добавлено и 22 удалено
  1. 8 8
      src/cli/custom-skills.ts
  2. 9 9
      src/cli/install.test.ts
  3. 1 5
      src/cli/install.ts

+ 8 - 8
src/cli/custom-skills.ts

@@ -1,6 +1,6 @@
+import { cpSync, existsSync, mkdirSync } from 'node:fs';
 import { join } from 'node:path';
 import { fileURLToPath } from 'node:url';
-import { syncBundledSkillsFromPackage } from '../hooks/auto-update-checker/skill-sync';
 import { CUSTOM_SKILLS, type CustomSkill } from './custom-skills-registry';
 import { getConfigDir } from './paths';
 
@@ -25,13 +25,13 @@ export function installCustomSkill(skill: CustomSkill): boolean {
   );
   try {
     const packageRoot = fileURLToPath(new URL('../..', import.meta.url));
-    const result = syncBundledSkillsFromPackage(packageRoot, {
-      skills: [skill],
-    });
-    return (
-      result.installed.includes(skill.name) ||
-      result.skippedExisting.includes(skill.name)
-    );
+    const sourceDir = join(packageRoot, skill.sourcePath);
+    if (!existsSync(sourceDir)) return false;
+
+    const targetDir = join(getCustomSkillsDir(), skill.name);
+    mkdirSync(getCustomSkillsDir(), { recursive: true });
+    cpSync(sourceDir, targetDir, { recursive: true, force: true });
+    return true;
   } catch (error) {
     console.error(
       `Failed to install custom skill safely: ${skill.name}`,

+ 9 - 9
src/cli/install.test.ts

@@ -224,12 +224,12 @@ describe('install skill synchronization error mapping', () => {
     );
     expect(hasRawSentinel).toBe(false);
 
-    // Verify counter does not count __lock__ as a failed skill
+    // Verify summary does not count __lock__ as a failed skill
     const summaryMsg = calls.find((msg: string) =>
-      msg?.includes('Skill synchronization complete.'),
+      msg?.includes('Skill synchronization complete'),
     );
     expect(summaryMsg).toBeDefined();
-    expect(summaryMsg).toContain('Processed 0 skills:');
+    expect(summaryMsg).not.toContain('Processed');
     expect(summaryMsg).toContain('0 failed.');
   });
 
@@ -254,12 +254,12 @@ describe('install skill synchronization error mapping', () => {
     );
     expect(hasRawSentinel).toBe(false);
 
-    // Verify counter does not count __manifest__ as a failed skill
+    // Verify summary does not count __manifest__ as a failed skill
     const summaryMsg = calls.find((msg: string) =>
-      msg?.includes('Skill synchronization complete.'),
+      msg?.includes('Skill synchronization complete'),
     );
     expect(summaryMsg).toBeDefined();
-    expect(summaryMsg).toContain('Processed 0 skills:');
+    expect(summaryMsg).not.toContain('Processed');
     expect(summaryMsg).toContain('0 failed.');
   });
 
@@ -279,12 +279,12 @@ describe('install skill synchronization error mapping', () => {
     );
     expect(hasSkillErr).toBe(true);
 
-    // Verify counter DOES count standard skill failures in the failed count
+    // Verify summary DOES count standard skill failures in the failed count
     const summaryMsg = calls.find((msg: string) =>
-      msg?.includes('Skill synchronization complete.'),
+      msg?.includes('Skill synchronization complete'),
     );
     expect(summaryMsg).toBeDefined();
-    expect(summaryMsg).toContain('Processed 1 skills:');
+    expect(summaryMsg).not.toContain('Processed');
     expect(summaryMsg).toContain('1 failed.');
   });
 

+ 1 - 5
src/cli/install.ts

@@ -458,12 +458,8 @@ async function runInstall(config: InstallConfig): Promise<number> {
         const realFailed = result.failed.filter(
           (skill) => skill !== '__lock__' && skill !== '__manifest__',
         );
-        const totalProcessed =
-          result.installed.length +
-          result.skippedExisting.length +
-          realFailed.length;
         printSuccess(
-          `Skill synchronization complete. Processed ${totalProcessed} skills: ` +
+          `Skill synchronization complete: ` +
             `${result.installed.length} installed/updated, ` +
             `${result.skippedExisting.length} skipped/preserved, ` +
             `${realFailed.length} failed.`,