From 984407cddc6474b6052f90190266e511f08f89e1 Mon Sep 17 00:00:00 2001 From: rUv Date: Tue, 13 Jan 2026 15:37:31 +0000 Subject: [PATCH] Checkpoint: File edits MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Automatic checkpoint created by Claude Code - Branch: v3 - Timestamp: 2026-01-13T15:37:31Z - Changes: 1 file(s) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- v3/@claude-flow/cli/src/update/index.ts | 114 ++++++++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 v3/@claude-flow/cli/src/update/index.ts diff --git a/v3/@claude-flow/cli/src/update/index.ts b/v3/@claude-flow/cli/src/update/index.ts new file mode 100644 index 0000000000..573ce7579b --- /dev/null +++ b/v3/@claude-flow/cli/src/update/index.ts @@ -0,0 +1,114 @@ +/** + * Auto-update system for @claude-flow packages + * + * Features: + * - Rate-limited update checks (24h default) + * - Automatic patch updates for security packages + * - Compatibility validation before updates + * - Rollback capability + * - Update history logging + */ + +export { + checkForUpdates, + checkSinglePackage, + getInstalledVersion, + UpdateCheckResult, + UpdateConfig, + DEFAULT_CONFIG, +} from './checker.js'; + +export { + shouldCheckForUpdates, + recordCheck, + getCachedVersions, + clearCache, + loadState, + RateLimitState, +} from './rate-limiter.js'; + +export { + validateUpdate, + validateBulkUpdate, + ValidationResult, +} from './validator.js'; + +export { + executeUpdate, + executeMultipleUpdates, + rollbackUpdate, + getUpdateHistory, + clearHistory, + loadHistory, + UpdateHistoryEntry, + UpdateExecutionResult, +} from './executor.js'; + +// Re-export a convenience function for startup +import { checkForUpdates, UpdateCheckResult, DEFAULT_CONFIG } from './checker.js'; +import { executeMultipleUpdates } from './executor.js'; +import { getInstalledVersion } from './checker.js'; + +/** + * Run auto-update check on startup + * This is the main entry point for the auto-update system + */ +export async function runStartupUpdateCheck(options: { + verbose?: boolean; + autoUpdate?: boolean; +}): Promise<{ + checked: boolean; + updatesAvailable: UpdateCheckResult[]; + updatesApplied: string[]; + skippedReason?: string; +}> { + const result = { + checked: false, + updatesAvailable: [] as UpdateCheckResult[], + updatesApplied: [] as string[], + skippedReason: undefined as string | undefined, + }; + + try { + const { results, skipped, reason } = await checkForUpdates(DEFAULT_CONFIG); + + if (skipped) { + result.skippedReason = reason; + return result; + } + + result.checked = true; + result.updatesAvailable = results; + + // Auto-update if enabled + if (options.autoUpdate !== false) { + const autoUpdateable = results.filter((r) => r.shouldAutoUpdate); + + if (autoUpdateable.length > 0) { + // Get current installed packages + const installedPackages: Record = {}; + for (const update of autoUpdateable) { + const version = getInstalledVersion(update.package); + if (version) { + installedPackages[update.package] = version; + } + } + + // Execute updates + const updateResults = await executeMultipleUpdates( + autoUpdateable, + installedPackages + ); + + result.updatesApplied = updateResults + .filter((r) => r.success) + .map((r) => `${r.package}@${r.version}`); + } + } + + return result; + } catch { + // Silently fail on startup - don't block CLI usage + return result; + } +}