utils/cleanup/cleanup_manager
library
Functions
-
addCleanupResults(CleanupResult a, CleanupResult b)
→ CleanupResult
-
Add two cleanup results together.
-
cleanupNpmCacheForAnthropicPackages()
→ Future<void>
-
Clean up old npm cache entries for Anthropic packages.
Only runs once per day for Ant users.
-
cleanupOldDebugLogs()
→ Future<CleanupResult>
-
Clean up old debug log files from ~/.neomage/debug/.
Preserves the 'latest' symlink.
-
cleanupOldFileHistoryBackups()
→ Future<CleanupResult>
-
Clean up old file history backups.
-
cleanupOldMessageFiles()
→ Future<CleanupResult>
-
Clean up old message and error log files.
-
cleanupOldMessageFilesInBackground()
→ Future<void>
-
Run all cleanup operations in the background.
-
cleanupOldPlanFiles()
→ Future<CleanupResult>
-
Clean up old plan files from ~/.neomage/plans/.
-
cleanupOldSessionEnvDirs()
→ Future<CleanupResult>
-
Clean up old session environment directories.
-
cleanupOldSessionFiles()
→ Future<CleanupResult>
-
Clean up old session files (transcripts, tool results, etc.).
-
cleanupOldVersionsThrottled()
→ Future<void>
-
Registered cleanup functions are already handled above via
registerCleanup and runCleanupFunctions.
Throttled wrapper around version cleanup.
Uses a marker file and lock to ensure it runs at most once per 24 hours.
-
convertFileNameToDate(String filename)
→ DateTime
-
Convert a filename to a DateTime by parsing the ISO-like name.
Filenames use
- in place of : and . in ISO timestamps.
-
getCutoffDate()
→ DateTime
-
Compute the cutoff date from settings.
-
gracefulShutdown({int exitCode = 0, ExitReason reason = ExitReason.other, String? finalMessage})
→ Future<void>
-
Graceful shutdown: cleans up resources, runs hooks, flushes analytics, exits.
-
gracefulShutdownSync({int exitCode = 0, ExitReason reason = ExitReason.other})
→ void
-
Synchronous wrapper that kicks off graceful shutdown.
-
isShuttingDown()
→ bool
-
Check if graceful shutdown is in progress.
-
registerCleanup(CleanupCallback fn)
→ void
-
Register a cleanup function to run during graceful shutdown.
-
resetShutdownState()
→ void
-
Reset shutdown state — only for use in tests.
-
runCleanupFunctions()
→ Future<void>
-
Run all registered cleanup functions.
-
setAnalyticsShutdown(AnalyticsShutdownFn fn)
→ void
-
Set the analytics shutdown executor.
-
setCleanupSettingsProvider(SettingsProvider provider)
→ void
-
Set the settings provider callback.
-
setCleanupTerminalModes(void fn())
→ void
-
Set the terminal cleanup callback.
-
setHousekeepingInteractiveState({required bool isInteractive(), required int lastInteractionTime()})
→ void
-
Set the interactive-state getters.
-
setPrintResumeHint(void fn())
→ void
-
Set a callback for printing the resume hint.
-
setRawSettingsContainsKey(RawSettingsContainsKeyFn fn)
→ void
-
Set the raw settings key check function.
-
setSessionEndHooks(SessionEndHooksFn fn)
→ void
-
Set the session-end hooks executor.
-
setupGracefulShutdown()
→ void
-
-
startBackgroundHousekeeping()
→ void
-
Start background housekeeping tasks.