Browse Source

fix(skill-sync): normalize reconciliation results

Alvin Unreal 1 month ago
parent
commit
b2044b3f3a

+ 4 - 4
src/cli/install.ts

@@ -444,13 +444,13 @@ async function runInstall(config: InstallConfig): Promise<number> {
             }
           }
         }
-        if ((result.staged ?? []).length > 0) {
-          for (const skill of result.staged ?? []) {
+        if (result.staged.length > 0) {
+          for (const skill of result.staged) {
             printInfo(`Staged for review: ${skill}`);
           }
         }
-        if ((result.adopted ?? []).length > 0) {
-          for (const skill of result.adopted ?? []) {
+        if (result.adopted.length > 0) {
+          for (const skill of result.adopted) {
             printInfo(`Adopted: ${skill}`);
           }
         }

+ 5 - 5
src/hooks/auto-update-checker/index.ts

@@ -75,10 +75,10 @@ async function runBackgroundUpdateCheck(
 ): Promise<void> {
   // Startup reconciliation (run once per top-level startup)
   if (!hasReconciledAtStartup) {
-    hasReconciledAtStartup = true;
     try {
       const runtimePackageJsonPath = getCurrentRuntimePackageJsonPath();
       if (runtimePackageJsonPath) {
+        hasReconciledAtStartup = true;
         const packageRoot = path.dirname(runtimePackageJsonPath);
         log('[auto-update-checker] Running startup skill reconciliation');
         const syncResult = syncBundledSkillsFromPackage(packageRoot);
@@ -92,14 +92,14 @@ async function runBackgroundUpdateCheck(
             `[auto-update-checker] Startup skill sync failures: ${syncResult.failed.join(', ')}`,
           );
         }
-        if ((syncResult.staged ?? []).length > 0) {
+        if (syncResult.staged.length > 0) {
           log(
-            `[auto-update-checker] Startup skill sync staged: ${syncResult.staged?.join(', ')}`,
+            `[auto-update-checker] Startup skill sync staged: ${syncResult.staged.join(', ')}`,
           );
         }
-        if ((syncResult.customized ?? []).length > 0) {
+        if (syncResult.customized.length > 0) {
           log(
-            `[auto-update-checker] Startup skill sync customized: ${syncResult.customized?.join(', ')}`,
+            `[auto-update-checker] Startup skill sync customized: ${syncResult.customized.join(', ')}`,
           );
         }
       } else {

+ 4 - 4
src/hooks/auto-update-checker/skill-sync.ts

@@ -35,10 +35,10 @@ export interface SkillSyncResult {
   installed: string[];
   skippedExisting: string[];
   failed: string[];
-  updated?: string[];
-  staged?: string[];
-  adopted?: string[];
-  customized?: string[];
+  updated: string[];
+  staged: string[];
+  adopted: string[];
+  customized: string[];
 }
 
 export interface SkillManifestEntry {