diff --git a/src/cliproxy/sync/auto-sync-watcher.ts b/src/cliproxy/sync/auto-sync-watcher.ts index b3d60452..dd60d48b 100644 --- a/src/cliproxy/sync/auto-sync-watcher.ts +++ b/src/cliproxy/sync/auto-sync-watcher.ts @@ -169,6 +169,10 @@ export async function restartAutoSyncWatcher(): Promise { await new Promise((resolve) => setTimeout(resolve, 100)); } + if (isSyncing) { + log('Warning: Sync still in progress after 10s timeout, proceeding with restart'); + } + await stopAutoSyncWatcher(); startAutoSyncWatcher(); } diff --git a/src/cliproxy/sync/local-config-sync.ts b/src/cliproxy/sync/local-config-sync.ts index f01d3de5..d52a03eb 100644 --- a/src/cliproxy/sync/local-config-sync.ts +++ b/src/cliproxy/sync/local-config-sync.ts @@ -124,13 +124,14 @@ function replaceSectionInYaml(content: string, sectionKey: string, newSection: s // If we're in the section, skip lines until we hit another top-level key if (inSection) { - // Top-level key starts at column 0 and has format "key:" or "key :" + // Top-level key: starts at column 0, valid YAML key format (word chars + hyphens) + // Must match pattern like "key:", "my-key:", "key_name:" but not comments or strings const isTopLevelKey = line.length > 0 && !line.startsWith(' ') && !line.startsWith('\t') && !line.startsWith('#') && - line.includes(':'); + /^[a-zA-Z_][a-zA-Z0-9_-]*\s*:/.test(line); if (isTopLevelKey) { // We've exited the section, resume normal processing diff --git a/src/commands/cliproxy-command.ts b/src/commands/cliproxy-command.ts index 7123364c..55761a59 100644 --- a/src/commands/cliproxy-command.ts +++ b/src/commands/cliproxy-command.ts @@ -621,7 +621,7 @@ async function showHelp(): Promise { [ ['sync', 'Sync API profiles to local CLIProxy config'], ['sync --dry-run', 'Preview sync without applying'], - ['sync --force', 'Sync without confirmation prompt'], + ['sync --verbose', 'Show detailed sync information'], ], ], [ diff --git a/src/commands/cliproxy-sync-handler.ts b/src/commands/cliproxy-sync-handler.ts index fb4bceef..f0cc370c 100644 --- a/src/commands/cliproxy-sync-handler.ts +++ b/src/commands/cliproxy-sync-handler.ts @@ -10,6 +10,7 @@ import { initUI, header, subheader, color, dim, ok, fail, warn, info, table } fr interface SyncArgs { dryRun: boolean; verbose: boolean; + force: boolean; } /** @@ -19,6 +20,7 @@ export function parseSyncArgs(args: string[]): SyncArgs { return { dryRun: args.includes('--dry-run') || args.includes('-n'), verbose: args.includes('--verbose') || args.includes('-v'), + force: args.includes('--force') || args.includes('-f'), }; }