Skip to content

feat: add cleanup support for Elixir, Haskell, OCaml, and Editors#302

Merged
tw93 merged 5 commits intotw93:windowsfrom
bhadraagada:windows
Jan 12, 2026
Merged

feat: add cleanup support for Elixir, Haskell, OCaml, and Editors#302
tw93 merged 5 commits intotw93:windowsfrom
bhadraagada:windows

Conversation

@bhadraagada
Copy link
Contributor

Windows port of biplavbarua's extended dev cleanup feature:

  • Elixir: Mix archives and Hex cache cleanup
  • Haskell: Cabal packages/store and Stack programs cache
  • OCaml: Opam download and repo cache
  • Editors: VS Code, VS Code Insiders, Zed, Sublime Text, Atom caches

Mirrors the macOS implementation from PR #287

Windows port of biplavbarua's extended dev cleanup feature:
- Elixir: Mix archives and Hex cache cleanup
- Haskell: Cabal packages/store and Stack programs cache
- OCaml: Opam download and repo cache
- Editors: VS Code, VS Code Insiders, Zed, Sublime Text, Atom caches

Mirrors the macOS implementation from PR tw93#287
Copilot AI review requested due to automatic review settings January 12, 2026 05:15
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request adds cleanup support for four additional development ecosystems (Elixir, Haskell, OCaml) and various code editors (VS Code, VS Code Insiders, Zed, Sublime Text, Atom) to the Windows PowerShell implementation of the Mole cleanup tool. This mirrors functionality from PR #287 for macOS.

Changes:

  • Added Clear-ElixirCaches function to clean Mix archives and Hex cache/packages
  • Added Clear-HaskellCaches function to clean Cabal and Stack caches with age-based cleanup for Cabal store
  • Added Clear-OCamlCaches function to clean Opam download and repository caches
  • Added Clear-EditorCaches function to clean various editor caches including VS Code, VS Code Insiders, Zed, Sublime Text, and Atom

# Cabal packages cache
$cabalPackagesPath = "$env:USERPROFILE\.cabal\packages"
if (Test-Path $cabalPackagesPath) {
Clear-DirectoryContents -Path $cabalPackagesPath -Description "Cabal packages cache"
Copy link

Copilot AI Jan 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clearing the entire Cabal packages cache may be overly aggressive as it contains downloaded package archives that may still be needed. Consider implementing selective cleanup similar to the Cabal store cleanup (age-based) or only cleaning temporary files and cache metadata rather than the entire packages directory.

Suggested change
Clear-DirectoryContents -Path $cabalPackagesPath -Description "Cabal packages cache"
# Avoid clearing the entire packages cache; only remove old, non-archive metadata
$now = Get-Date
$cutoff = $now.AddDays(-90)
$oldCacheItems = Get-ChildItem -Path $cabalPackagesPath -Recurse -File -ErrorAction SilentlyContinue |
Where-Object {
$_.LastWriteTime -lt $cutoff -and
$_.Extension -notin @('.tar', '.gz', '.tgz', '.bz2', '.xz')
}
if ($oldCacheItems) {
$paths = $oldCacheItems | ForEach-Object { $_.FullName }
Remove-SafeItems -Paths $paths -Description "Cabal old packages cache metadata"
}

Copilot uses AI. Check for mistakes.
Comment on lines +425 to +428
# Mix archives cache
$mixArchivesPath = "$env:USERPROFILE\.mix\archives"
if (Test-Path $mixArchivesPath) {
Clear-DirectoryContents -Path $mixArchivesPath -Description "Mix archives cache"
Copy link

Copilot AI Jan 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clearing the entire Mix archives directory removes all globally installed Mix tools and tasks. This may be too aggressive as users may have intentionally installed these tools. Consider either documenting this behavior more clearly or implementing selective cleanup that preserves commonly-used archives.

Suggested change
# Mix archives cache
$mixArchivesPath = "$env:USERPROFILE\.mix\archives"
if (Test-Path $mixArchivesPath) {
Clear-DirectoryContents -Path $mixArchivesPath -Description "Mix archives cache"
# Mix archives directory
# NOTE: This directory may contain globally installed Mix tools and tasks.
# To avoid unintentionally removing user-installed tools, we do not clear
# this directory automatically. Clean it manually if you understand the
# impact (e.g., by removing stale archives you no longer need).
$mixArchivesPath = "$env:USERPROFILE\.mix\archives"
if (Test-Path $mixArchivesPath) {
Write-Log -Level 'Info' -Message "Skipping automatic cleanup of Mix archives at '$mixArchivesPath' to avoid removing globally installed Mix tools and tasks."

Copilot uses AI. Check for mistakes.
Comment on lines +437 to +440
# Hex packages
$hexPackagesPath = "$env:USERPROFILE\.hex\packages"
if (Test-Path $hexPackagesPath) {
Clear-DirectoryContents -Path $hexPackagesPath -Description "Hex packages cache"
Copy link

Copilot AI Jan 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clearing the entire Hex packages directory removes all downloaded and compiled Elixir dependencies. This is likely too aggressive as these packages are actively used by projects and will need to be re-downloaded and recompiled. Consider either removing this cleanup entirely or implementing age-based cleanup for packages not accessed recently.

Suggested change
# Hex packages
$hexPackagesPath = "$env:USERPROFILE\.hex\packages"
if (Test-Path $hexPackagesPath) {
Clear-DirectoryContents -Path $hexPackagesPath -Description "Hex packages cache"
# Hex packages (only clean old/unused packages - be careful here)
$hexPackagesPath = "$env:USERPROFILE\.hex\packages"
if (Test-Path $hexPackagesPath) {
$oldHexPackages = Get-ChildItem -Path $hexPackagesPath -Directory -ErrorAction SilentlyContinue |
Where-Object { $_.LastWriteTime -lt (Get-Date).AddDays(-90) }
if ($oldHexPackages) {
foreach ($pkg in $oldHexPackages) {
Remove-SafeItem -Path $pkg.FullName -Description "Old Hex package ($($pkg.Name))" -Recurse
}
}

Copilot uses AI. Check for mistakes.
"$env:APPDATA\Code\CachedExtensionVSIXs"
"$env:APPDATA\Code\Code Cache"
"$env:APPDATA\Code\GPUCache"
"$env:APPDATA\Code\User\workspaceStorage"
Copy link

Copilot AI Jan 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clearing VS Code's workspaceStorage directory removes workspace-specific settings, state, and extension data. This may cause loss of user preferences and workspace configurations. Consider either removing this path from cleanup, implementing age-based cleanup, or clearly documenting this behavior as it may surprise users.

Copilot uses AI. Check for mistakes.
$vscodeInsidersCachePaths = @(
"$env:APPDATA\Code - Insiders\Cache"
"$env:APPDATA\Code - Insiders\CachedData"
"$env:APPDATA\Code - Insiders\User\workspaceStorage"
Copy link

Copilot AI Jan 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clearing VS Code Insiders' workspaceStorage directory removes workspace-specific settings, state, and extension data. This may cause loss of user preferences and workspace configurations. Consider either removing this path from cleanup, implementing age-based cleanup, or clearly documenting this behavior as it may surprise users.

Copilot uses AI. Check for mistakes.
# VS Code Insiders
$vscodeInsidersCachePaths = @(
"$env:APPDATA\Code - Insiders\Cache"
"$env:APPDATA\Code - Insiders\CachedData"
Copy link

Copilot AI Jan 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VS Code Insiders should have similar cache directories as VS Code regular. Consider adding the missing cache paths for consistency: CachedExtensions, CachedExtensionVSIXs, Code Cache, and GPUCache under the "Code - Insiders" directory.

Suggested change
"$env:APPDATA\Code - Insiders\CachedData"
"$env:APPDATA\Code - Insiders\CachedData"
"$env:APPDATA\Code - Insiders\CachedExtensions"
"$env:APPDATA\Code - Insiders\CachedExtensionVSIXs"
"$env:APPDATA\Code - Insiders\Code Cache"
"$env:APPDATA\Code - Insiders\GPUCache"

Copilot uses AI. Check for mistakes.
# Stack programs cache
$stackProgramsPath = "$env:USERPROFILE\.stack\programs"
if (Test-Path $stackProgramsPath) {
Clear-DirectoryContents -Path $stackProgramsPath -Description "Stack programs cache"
Copy link

Copilot AI Jan 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clearing the entire Stack programs cache may be overly aggressive as it contains GHC compiler installations that can be large and time-consuming to re-download. Consider implementing age-based cleanup similar to the Cabal store cleanup, or only cleaning temporary files instead of the entire directory.

Suggested change
Clear-DirectoryContents -Path $stackProgramsPath -Description "Stack programs cache"
# Avoid clearing the entire Stack programs cache as it contains GHC installations.
# Only remove old program directories that have not been modified for a long time.
$oldProgramDirs = Get-ChildItem -Path $stackProgramsPath -Directory -ErrorAction SilentlyContinue |
Where-Object { $_.LastWriteTime -lt (Get-Date).AddDays(-90) }
if ($oldProgramDirs) {
foreach ($dir in $oldProgramDirs) {
Remove-SafeItem -Path $dir.FullName -Description "Stack old program ($($dir.Name))" -Recurse
}
}

Copilot uses AI. Check for mistakes.
bhadraagada and others added 4 commits January 12, 2026 10:53
- Rewrite check.yml for Windows (PowerShell syntax check, Go linting)
- Rewrite test.yml for Windows (Pester tests, Go tests, security checks)
- Rewrite release.yml for Windows releases (W* tags, zip package)
- Update update-contributors.yml to trigger on windows branch
- Use age-based cleanup (90 days) for Cabal packages instead of clearing all
- Skip Mix archives cleanup to preserve globally installed tools
- Use age-based cleanup for Hex packages instead of clearing all
- Use age-based cleanup for Stack programs (GHC installations)
- Remove workspaceStorage from VS Code cleanup to preserve workspace settings
- Add missing cache paths for VS Code Insiders (CachedExtensions, etc.)

These changes make cleanup less aggressive and prevent accidental removal
of user-installed tools and workspace preferences.
Run go mod tidy to add missing indirect dependencies required for CI build.
This fixes the 'missing go.sum entry' errors in the test workflow.
@bhadraagada
Copy link
Contributor Author

@tw93 man i cant merge this pr into windows branch

Copy link
Owner

@tw93 tw93 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.
@bhadraagada I‘ve merged, you can do next things.

@tw93 tw93 merged commit 9a354d3 into tw93:windows Jan 12, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants