diff --git a/src/cliproxy/sync/auto-sync-watcher.ts b/src/cliproxy/sync/auto-sync-watcher.ts index af81292e..b3d60452 100644 --- a/src/cliproxy/sync/auto-sync-watcher.ts +++ b/src/cliproxy/sync/auto-sync-watcher.ts @@ -130,6 +130,7 @@ export function startAutoSyncWatcher(): void { watcherInstance.on('change', onFileChange); watcherInstance.on('add', onFileChange); + watcherInstance.on('unlink', onFileChange); watcherInstance.on('error', (error) => { log(`Watcher error: ${error.message}`); diff --git a/src/commands/api-command.ts b/src/commands/api-command.ts index 69138ed1..ba98f6af 100644 --- a/src/commands/api-command.ts +++ b/src/commands/api-command.ts @@ -277,8 +277,13 @@ async function handleCreate(args: string[]): Promise { process.exit(1); } - // Trigger sync to local CLIProxy config (best-effort, ignore result) - syncToLocalConfig(); + // Trigger sync to local CLIProxy config (best-effort) + try { + syncToLocalConfig(); + } catch (err) { + const message = err instanceof Error ? err.message : 'Unknown error'; + console.log(`[i] Auto-sync to CLIProxy config skipped: ${message}`); + } // Display success console.log(''); diff --git a/src/config/unified-config-types.ts b/src/config/unified-config-types.ts index 5a997480..130d6e0b 100644 --- a/src/config/unified-config-types.ts +++ b/src/config/unified-config-types.ts @@ -132,7 +132,7 @@ export interface CLIProxyConfig { auth?: CLIProxyAuthConfig; /** Background token refresh worker settings */ token_refresh?: TokenRefreshSettings; - /** Auto-sync API profiles to local CLIProxy config on settings change (default: false) */ + /** Auto-sync API profiles to local CLIProxy config on settings change (default: true) */ auto_sync?: boolean; }