wsldu 1.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
wsldu-1.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 wsldu contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
wsldu-1.1.0/PKG-INFO ADDED
@@ -0,0 +1,300 @@
1
+ Metadata-Version: 2.4
2
+ Name: wsldu
3
+ Version: 1.1.0
4
+ Summary: Find what fills your WSL disk, clean it up, and give the space back to Windows (compact ext4.vhdx).
5
+ Author: Koffi Joel
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://koffijoel.github.io/wsldu/
8
+ Project-URL: Source, https://github.com/koffijoel/wsldu
9
+ Project-URL: Changelog, https://github.com/koffijoel/wsldu/blob/main/CHANGELOG.md
10
+ Project-URL: Funding, https://www.patreon.com/koffijoel
11
+ Keywords: wsl,wsl2,vhdx,disk-usage,docker,cleanup,windows
12
+ Classifier: Environment :: Console :: Curses
13
+ Classifier: Environment :: Web Environment
14
+ Classifier: Operating System :: POSIX :: Linux
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Topic :: System :: Filesystems
17
+ Classifier: Topic :: Utilities
18
+ Requires-Python: >=3.8
19
+ Description-Content-Type: text/markdown
20
+ License-File: LICENSE
21
+ Dynamic: license-file
22
+
23
+ <div align="center">
24
+
25
+ # wsldu
26
+
27
+ **Find what fills your WSL disk, clean it up, and actually give the space back to Windows.**
28
+
29
+ Terminal UI · local web UI · Docker aware · one-click VHDX compaction · AI-agent ready · zero dependencies
30
+
31
+ [Website](https://koffijoel.github.io/wsldu/) · [Install](#install) · [Usage](#usage) · [Compaction](#giving-the-space-back-to-windows) · [AI mode](#ai-mode-the-agent-proposes-you-decide) · [Support](https://www.patreon.com/koffijoel) · [Français](README.fr.md)
32
+
33
+ <img src="docs/img/en-disks.png" alt="wsldu web UI: virtual disks tab" width="860">
34
+
35
+ </div>
36
+
37
+ ---
38
+
39
+ ## The story
40
+
41
+ My Windows `C:` drive was down to a few gigabytes. I opened WSL, found a pile of old
42
+ `node_modules`, Docker images and caches, deleted **tens of gigabytes** of them, and went back to Windows
43
+ expecting relief.
44
+
45
+ **Free space on C: had not moved. Not one byte.**
46
+
47
+ That is how WSL 2 works: every distribution lives in a virtual disk file,
48
+ `ext4.vhdx`, which **grows automatically but never shrinks**. Deleting files frees space *inside*
49
+ Linux; the file on Windows keeps its biggest size forever. Getting the space back means running
50
+ `fstrim`, shutting WSL down, and compacting the file from an **administrator** PowerShell with
51
+ `Optimize-VHD` (Windows Pro) or `diskpart` (Windows Home), after finding where the `.vhdx`
52
+ actually lives, including Docker Desktop's.
53
+
54
+ I did that by hand a few times, then wrote **wsldu** so that nobody has to again.
55
+
56
+ ## What it does
57
+
58
+ | | |
59
+ |---|---|
60
+ | **Explorer** | WinDirStat-style size tree of any folder (does not cross into `/mnt/c`, handles hard links and bind mounts). |
61
+ | **Big files** | The 300 biggest files, one key or click to open or delete. |
62
+ | **Multi-select** | Tick (or shift+click) as many files, folders or Docker objects as you want, across folders, and delete them in one go. In the terminal: `space` to mark, `d` to delete. |
63
+ | **Regenerable** | `node_modules`, `.venv`, `target`, `__pycache__`, `.next`, `.gradle`... with their age. Ambiguous names are verified (`target` needs a `Cargo.toml`/`pom.xml`, `.venv` a `pyvenv.cfg`). |
64
+ | **Docker** | Images, containers, volumes and build cache, **mapped to the project folder** they belong to (compose labels, bind mounts, name guessing). |
65
+ | **Cleanup** | ~30 one-click cleanups with their size: apt, journald, pip, npm, yarn, pnpm, uv, cargo, go, maven, gradle, Playwright, HuggingFace, VS Code Server, Docker prune... Each shows the exact command and a warning when it matters. |
66
+ | **Virtual disks** | Every WSL and Docker Desktop `.vhdx`, its size on Windows, space used inside Linux, and **how much compaction will give back**. Compact in one click, interactively or silently. |
67
+ | **AI plan** | An AI agent proposes what to delete, **you approve item by item**. |
68
+
69
+ Everything runs locally. English and French, auto-detected.
70
+
71
+ <table><tr>
72
+ <td><img src="docs/img/en-explorer.png" alt="Explorer"></td>
73
+ <td><img src="docs/img/en-clean.png" alt="Cleanup catalogue"></td>
74
+ </tr></table>
75
+
76
+ ## Install
77
+
78
+ wsldu is a single 60 KB file. It only needs `python3`, which Ubuntu and Debian on WSL already have.
79
+
80
+ ```sh
81
+ curl -fsSL https://raw.githubusercontent.com/koffijoel/wsldu/main/install.sh | sh
82
+ ```
83
+
84
+ This downloads the latest release (`wsldu.pyz`, sha256-checked) to `~/.local/bin/wsldu`.
85
+
86
+ <details><summary>Other ways</summary>
87
+
88
+ ```sh
89
+ # PyPI (pipx recommended)
90
+ pipx install wsldu
91
+
92
+ # from a clone (updates with git pull)
93
+ git clone https://github.com/koffijoel/wsldu && ln -s "$PWD/wsldu/bin/wsldu" ~/.local/bin/wsldu
94
+
95
+ # manual
96
+ curl -fLo ~/.local/bin/wsldu https://github.com/koffijoel/wsldu/releases/latest/download/wsldu.pyz
97
+ chmod +x ~/.local/bin/wsldu
98
+ ```
99
+ </details>
100
+
101
+ ### Updates
102
+
103
+ ```sh
104
+ wsldu --update # download and install the latest release (sha256 checked)
105
+ wsldu --check-update # just tell me
106
+ ```
107
+
108
+ wsldu checks GitHub at most once a day, in the background, and shows a one-line notice when a
109
+ new version exists. Set `WSLDU_NO_UPDATE_CHECK=1` to disable it. Releases are produced
110
+ automatically by CI for every version merged into `main`.
111
+
112
+ ## Usage
113
+
114
+ ```sh
115
+ wsldu # terminal UI on /
116
+ sudo wsldu # recommended: also sees /var/lib/docker, /root, other users' files
117
+ wsldu ~/projects # any folder
118
+ wsldu --web # the same tool in your browser
119
+ wsldu --report # text report; --json for scripts; --scan ~ to include folders
120
+ wsldu --compact # give the space back to Windows (see below)
121
+ ```
122
+
123
+ ### Terminal UI
124
+
125
+ `1`-`6` or `Tab` switch tabs, arrows / `j` `k` move, `Enter` opens, `space` marks (multi-select),
126
+ `d` deletes the current or marked items (always asks first), `r` rescans, `w` opens the web UI,
127
+ `?` shows help, `q` quits.
128
+
129
+ ### Web UI
130
+
131
+ `wsldu --web` starts a small local server and opens your Windows browser on it.
132
+
133
+ - It listens on `127.0.0.1` only; WSL forwards it to Windows.
134
+ - Each run creates a random access token that is part of the URL.
135
+ - The `Host` header is checked, which blocks DNS-rebinding attacks.
136
+ - It uses only the Python standard library: no framework, no CDN.
137
+
138
+ Options: `--port`, `--no-browser`, `--lang en|fr`. Stop it with the **Quit** button or `Ctrl+C`.
139
+
140
+ ## Giving the space back to Windows
141
+
142
+ ```sh
143
+ wsldu --compact # asks for confirmation in an admin PowerShell window
144
+ wsldu --compact --yes # silent: no question, hidden window, Windows notification at the end
145
+ wsldu --compact --disk Ubuntu # only some disks (name or .vhdx path, repeatable)
146
+ ```
147
+
148
+ What happens:
149
+
150
+ 1. `fstrim` marks the freed blocks. wsldu runs it as root through `wsl.exe -u root`, so no sudo password is needed.
151
+ 2. Windows shows a **UAC prompt**: compaction needs administrator rights.
152
+ 3. A PowerShell script stops WSL (`wsl --shutdown`) and waits for the disks to be released.
153
+ 4. If Docker Desktop is running, the script closes it and restarts it at the end.
154
+ 5. Each disk is compacted with `Optimize-VHD`, or `diskpart` when Hyper-V tools are missing.
155
+ 6. The result is written to `%LOCALAPPDATA%\wsldu\last-compact.json`, and wsldu shows it the next time it runs.
156
+
157
+ > **WSL is stopped during compaction**: every terminal, editor session and container. Save your
158
+ > work first.
159
+
160
+ ### Fully silent mode (no prompt at all)
161
+
162
+ The UAC prompt is a Windows security boundary and cannot be skipped by a script. The standard,
163
+ explicit way around it is a scheduled task that you approve **once**:
164
+
165
+ ```sh
166
+ wsldu --install-task # one UAC prompt now
167
+ wsldu --compact --yes # from now on: no prompt, no window, just a notification
168
+ wsldu --uninstall-task # remove it
169
+ ```
170
+
171
+ The task (`wsldu-compact`) runs `C:\ProgramData\wsldu\compact.ps1` with highest privileges.
172
+
173
+ - **Admin-only script.** That folder is restricted so only administrators can modify the
174
+ script. A user-level process cannot swap the script for something else.
175
+ - **Version check.** The script carries its version; wsldu tells you when the installed task is
176
+ outdated.
177
+ - **No Linux code runs elevated.** The elevated script never runs code from inside your distros:
178
+ it only calls `wsl --shutdown`.
179
+
180
+ Run it from Windows directly if you prefer: `schtasks /run /tn wsldu-compact`.
181
+
182
+ ## AI mode: the agent proposes, you decide
183
+
184
+ Let any AI coding agent on your machine (Claude Code, Codex, Gemini CLI, Cursor...) look at your
185
+ disk and **suggest** what to delete. The agent never deletes anything itself:
186
+
187
+ 1. It reads `wsldu --report --json --scan ~`, which lists folders, big files, regenerable folders
188
+ with their age, caches, Docker objects and virtual disks.
189
+ 2. It writes a plan, `~/wsldu-plan.json`, with a reason for every item.
190
+ 3. **You** review it, item by item, in the terminal or in the browser with checkboxes:
191
+
192
+ ```sh
193
+ wsldu --apply ~/wsldu-plan.json # y / n / all / quit for each item
194
+ wsldu --web --plan ~/wsldu-plan.json # checkboxes, "Apply selected"
195
+ ```
196
+
197
+ Every item is re-checked against the machine before it is shown. Protected system paths,
198
+ missing files, unknown cleanups and invalid Docker ids are refused. **There is intentionally no
199
+ non-interactive way to apply a plan.**
200
+
201
+ <img src="docs/img/en-plan.png" alt="AI plan review in the web UI" width="860">
202
+
203
+ Install the skill for Claude Code:
204
+
205
+ ```sh
206
+ wsldu --install-skill # -> ~/.claude/skills/wsldu/SKILL.md
207
+ ```
208
+
209
+ Then ask: *"my WSL disk is full, what can I delete?"*. For other agents, point them to
210
+ [`wsldu/skill/SKILL.md`](wsldu/skill/SKILL.md) or [`AGENTS.md`](AGENTS.md).
211
+
212
+ <details><summary>Plan format</summary>
213
+
214
+ ```json
215
+ {
216
+ "wsldu_plan": 1,
217
+ "author": "Claude Code",
218
+ "summary": "Free ~12 GB: stale node_modules, pip/npm caches, dangling Docker images",
219
+ "items": [
220
+ {"type": "path", "path": "/home/me/old-app/node_modules", "reason": "not modified for 412 days"},
221
+ {"type": "cleanup", "id": "pip-cache", "reason": "pip cache, re-downloaded on demand"},
222
+ {"type": "docker", "kind": "image", "id": "4f2a9c1e7b3d", "reason": "dangling image"}
223
+ ]
224
+ }
225
+ ```
226
+ </details>
227
+
228
+ ## Safety
229
+
230
+ - **Every deletion asks first.** Deletions are permanent, so wsldu always shows the path or the
231
+ exact command before running it.
232
+ - **Protected paths.** System directories (`/`, `/usr`, `/etc`, `/var/lib/docker`...), your home
233
+ folder itself, `~/.ssh`, `~/.gnupg`, `~/.config` and Windows drives are always refused.
234
+ - **Validated Docker ids.** Docker object ids are checked before use, and commands are built
235
+ without shell injection.
236
+ - **Local web UI only.** It listens on localhost, requires a per-run random token, and checks the
237
+ `Host` header.
238
+ - **Root when needed.** Commands that need root use `sudo`. Without a terminal (web UI), they fall
239
+ back to `wsl.exe -u root`: you own the distro, so no password is needed.
240
+
241
+ ## Performance
242
+
243
+ wsldu walks the disk with `os.scandir`. It starts with a single thread and adds threads (up to 8)
244
+ only while the disk is the bottleneck. On a warm cache, Python threads only add contention.
245
+
246
+ | 1.53 M files, 280 k folders | warm cache | cold cache |
247
+ |---|---|---|
248
+ | single thread | 12.3 s | 262 s |
249
+ | **wsldu (adaptive)** | **10.8 to 16.6 s** | **116 s (×2.25)** |
250
+ | `du -sx` (C, reference) | 3.9 s | n/a |
251
+
252
+ All tabs except the explorer work while the scan runs.
253
+
254
+ ## FAQ
255
+
256
+ **Why not `wsl --manage <distro> --set-sparse true`?** Sparse VHDs shrink automatically, but
257
+ Microsoft documents corruption risks and the setting is not the default. Manual compaction is
258
+ safe and predictable.
259
+
260
+ **Windows Home?** Supported: wsldu uses `diskpart` when `Optimize-VHD` (Hyper-V) is not available.
261
+
262
+ **Docker Desktop?** Its disks (`docker_data.vhdx`, older `ext4.vhdx`) are detected and compacted
263
+ too. Its images are listed in the Docker tab when Docker Desktop integration is enabled for your
264
+ distro.
265
+
266
+ **WSL 1?** WSL 1 distros have no virtual disk: the analysis and cleanup tabs work, compaction is
267
+ not needed.
268
+
269
+ **Configuration?**
270
+
271
+ | Variable | Effect |
272
+ |---|---|
273
+ | `WSLDU_LANG` | Force the language (`en`, `fr`). |
274
+ | `WSLDU_PROJECTS` | Project roots used to map Docker objects to folders, separated by `:`. Default: `project:projects:src:code:dev:work:repos:git:workspace`. |
275
+ | `WSLDU_THREADS` | Maximum number of scan threads. |
276
+ | `WSLDU_NO_UPDATE_CHECK=1` | Disable the daily update check. |
277
+
278
+ ## Contributing
279
+
280
+ Issues and pull requests are welcome. wsldu has no dependencies and must stay that way.
281
+
282
+ ```sh
283
+ python3 -m unittest discover -s tests # tests
284
+ python3 tools/i18n_check.py # every UI string has a French translation
285
+ python3 tools/build_pyz.py # build dist/wsldu.pyz
286
+ ```
287
+
288
+ New language: copy `wsldu/lang_fr.py`, translate the values, and register it in `wsldu/i18n.py`.
289
+
290
+ To release, bump `__version__` in `wsldu/__init__.py` and add a `CHANGELOG.md` section. CI tags
291
+ and publishes the release when the change lands on `main`.
292
+
293
+ ## Support
294
+
295
+ wsldu is free and will stay free. If it saved your disk (or your afternoon), you can support my work on
296
+ **[Patreon](https://www.patreon.com/koffijoel)**. Stars, issues and pull requests help a lot too.
297
+
298
+ ## License
299
+
300
+ [MIT](LICENSE)
wsldu-1.1.0/README.md ADDED
@@ -0,0 +1,278 @@
1
+ <div align="center">
2
+
3
+ # wsldu
4
+
5
+ **Find what fills your WSL disk, clean it up, and actually give the space back to Windows.**
6
+
7
+ Terminal UI · local web UI · Docker aware · one-click VHDX compaction · AI-agent ready · zero dependencies
8
+
9
+ [Website](https://koffijoel.github.io/wsldu/) · [Install](#install) · [Usage](#usage) · [Compaction](#giving-the-space-back-to-windows) · [AI mode](#ai-mode-the-agent-proposes-you-decide) · [Support](https://www.patreon.com/koffijoel) · [Français](README.fr.md)
10
+
11
+ <img src="docs/img/en-disks.png" alt="wsldu web UI: virtual disks tab" width="860">
12
+
13
+ </div>
14
+
15
+ ---
16
+
17
+ ## The story
18
+
19
+ My Windows `C:` drive was down to a few gigabytes. I opened WSL, found a pile of old
20
+ `node_modules`, Docker images and caches, deleted **tens of gigabytes** of them, and went back to Windows
21
+ expecting relief.
22
+
23
+ **Free space on C: had not moved. Not one byte.**
24
+
25
+ That is how WSL 2 works: every distribution lives in a virtual disk file,
26
+ `ext4.vhdx`, which **grows automatically but never shrinks**. Deleting files frees space *inside*
27
+ Linux; the file on Windows keeps its biggest size forever. Getting the space back means running
28
+ `fstrim`, shutting WSL down, and compacting the file from an **administrator** PowerShell with
29
+ `Optimize-VHD` (Windows Pro) or `diskpart` (Windows Home), after finding where the `.vhdx`
30
+ actually lives, including Docker Desktop's.
31
+
32
+ I did that by hand a few times, then wrote **wsldu** so that nobody has to again.
33
+
34
+ ## What it does
35
+
36
+ | | |
37
+ |---|---|
38
+ | **Explorer** | WinDirStat-style size tree of any folder (does not cross into `/mnt/c`, handles hard links and bind mounts). |
39
+ | **Big files** | The 300 biggest files, one key or click to open or delete. |
40
+ | **Multi-select** | Tick (or shift+click) as many files, folders or Docker objects as you want, across folders, and delete them in one go. In the terminal: `space` to mark, `d` to delete. |
41
+ | **Regenerable** | `node_modules`, `.venv`, `target`, `__pycache__`, `.next`, `.gradle`... with their age. Ambiguous names are verified (`target` needs a `Cargo.toml`/`pom.xml`, `.venv` a `pyvenv.cfg`). |
42
+ | **Docker** | Images, containers, volumes and build cache, **mapped to the project folder** they belong to (compose labels, bind mounts, name guessing). |
43
+ | **Cleanup** | ~30 one-click cleanups with their size: apt, journald, pip, npm, yarn, pnpm, uv, cargo, go, maven, gradle, Playwright, HuggingFace, VS Code Server, Docker prune... Each shows the exact command and a warning when it matters. |
44
+ | **Virtual disks** | Every WSL and Docker Desktop `.vhdx`, its size on Windows, space used inside Linux, and **how much compaction will give back**. Compact in one click, interactively or silently. |
45
+ | **AI plan** | An AI agent proposes what to delete, **you approve item by item**. |
46
+
47
+ Everything runs locally. English and French, auto-detected.
48
+
49
+ <table><tr>
50
+ <td><img src="docs/img/en-explorer.png" alt="Explorer"></td>
51
+ <td><img src="docs/img/en-clean.png" alt="Cleanup catalogue"></td>
52
+ </tr></table>
53
+
54
+ ## Install
55
+
56
+ wsldu is a single 60 KB file. It only needs `python3`, which Ubuntu and Debian on WSL already have.
57
+
58
+ ```sh
59
+ curl -fsSL https://raw.githubusercontent.com/koffijoel/wsldu/main/install.sh | sh
60
+ ```
61
+
62
+ This downloads the latest release (`wsldu.pyz`, sha256-checked) to `~/.local/bin/wsldu`.
63
+
64
+ <details><summary>Other ways</summary>
65
+
66
+ ```sh
67
+ # PyPI (pipx recommended)
68
+ pipx install wsldu
69
+
70
+ # from a clone (updates with git pull)
71
+ git clone https://github.com/koffijoel/wsldu && ln -s "$PWD/wsldu/bin/wsldu" ~/.local/bin/wsldu
72
+
73
+ # manual
74
+ curl -fLo ~/.local/bin/wsldu https://github.com/koffijoel/wsldu/releases/latest/download/wsldu.pyz
75
+ chmod +x ~/.local/bin/wsldu
76
+ ```
77
+ </details>
78
+
79
+ ### Updates
80
+
81
+ ```sh
82
+ wsldu --update # download and install the latest release (sha256 checked)
83
+ wsldu --check-update # just tell me
84
+ ```
85
+
86
+ wsldu checks GitHub at most once a day, in the background, and shows a one-line notice when a
87
+ new version exists. Set `WSLDU_NO_UPDATE_CHECK=1` to disable it. Releases are produced
88
+ automatically by CI for every version merged into `main`.
89
+
90
+ ## Usage
91
+
92
+ ```sh
93
+ wsldu # terminal UI on /
94
+ sudo wsldu # recommended: also sees /var/lib/docker, /root, other users' files
95
+ wsldu ~/projects # any folder
96
+ wsldu --web # the same tool in your browser
97
+ wsldu --report # text report; --json for scripts; --scan ~ to include folders
98
+ wsldu --compact # give the space back to Windows (see below)
99
+ ```
100
+
101
+ ### Terminal UI
102
+
103
+ `1`-`6` or `Tab` switch tabs, arrows / `j` `k` move, `Enter` opens, `space` marks (multi-select),
104
+ `d` deletes the current or marked items (always asks first), `r` rescans, `w` opens the web UI,
105
+ `?` shows help, `q` quits.
106
+
107
+ ### Web UI
108
+
109
+ `wsldu --web` starts a small local server and opens your Windows browser on it.
110
+
111
+ - It listens on `127.0.0.1` only; WSL forwards it to Windows.
112
+ - Each run creates a random access token that is part of the URL.
113
+ - The `Host` header is checked, which blocks DNS-rebinding attacks.
114
+ - It uses only the Python standard library: no framework, no CDN.
115
+
116
+ Options: `--port`, `--no-browser`, `--lang en|fr`. Stop it with the **Quit** button or `Ctrl+C`.
117
+
118
+ ## Giving the space back to Windows
119
+
120
+ ```sh
121
+ wsldu --compact # asks for confirmation in an admin PowerShell window
122
+ wsldu --compact --yes # silent: no question, hidden window, Windows notification at the end
123
+ wsldu --compact --disk Ubuntu # only some disks (name or .vhdx path, repeatable)
124
+ ```
125
+
126
+ What happens:
127
+
128
+ 1. `fstrim` marks the freed blocks. wsldu runs it as root through `wsl.exe -u root`, so no sudo password is needed.
129
+ 2. Windows shows a **UAC prompt**: compaction needs administrator rights.
130
+ 3. A PowerShell script stops WSL (`wsl --shutdown`) and waits for the disks to be released.
131
+ 4. If Docker Desktop is running, the script closes it and restarts it at the end.
132
+ 5. Each disk is compacted with `Optimize-VHD`, or `diskpart` when Hyper-V tools are missing.
133
+ 6. The result is written to `%LOCALAPPDATA%\wsldu\last-compact.json`, and wsldu shows it the next time it runs.
134
+
135
+ > **WSL is stopped during compaction**: every terminal, editor session and container. Save your
136
+ > work first.
137
+
138
+ ### Fully silent mode (no prompt at all)
139
+
140
+ The UAC prompt is a Windows security boundary and cannot be skipped by a script. The standard,
141
+ explicit way around it is a scheduled task that you approve **once**:
142
+
143
+ ```sh
144
+ wsldu --install-task # one UAC prompt now
145
+ wsldu --compact --yes # from now on: no prompt, no window, just a notification
146
+ wsldu --uninstall-task # remove it
147
+ ```
148
+
149
+ The task (`wsldu-compact`) runs `C:\ProgramData\wsldu\compact.ps1` with highest privileges.
150
+
151
+ - **Admin-only script.** That folder is restricted so only administrators can modify the
152
+ script. A user-level process cannot swap the script for something else.
153
+ - **Version check.** The script carries its version; wsldu tells you when the installed task is
154
+ outdated.
155
+ - **No Linux code runs elevated.** The elevated script never runs code from inside your distros:
156
+ it only calls `wsl --shutdown`.
157
+
158
+ Run it from Windows directly if you prefer: `schtasks /run /tn wsldu-compact`.
159
+
160
+ ## AI mode: the agent proposes, you decide
161
+
162
+ Let any AI coding agent on your machine (Claude Code, Codex, Gemini CLI, Cursor...) look at your
163
+ disk and **suggest** what to delete. The agent never deletes anything itself:
164
+
165
+ 1. It reads `wsldu --report --json --scan ~`, which lists folders, big files, regenerable folders
166
+ with their age, caches, Docker objects and virtual disks.
167
+ 2. It writes a plan, `~/wsldu-plan.json`, with a reason for every item.
168
+ 3. **You** review it, item by item, in the terminal or in the browser with checkboxes:
169
+
170
+ ```sh
171
+ wsldu --apply ~/wsldu-plan.json # y / n / all / quit for each item
172
+ wsldu --web --plan ~/wsldu-plan.json # checkboxes, "Apply selected"
173
+ ```
174
+
175
+ Every item is re-checked against the machine before it is shown. Protected system paths,
176
+ missing files, unknown cleanups and invalid Docker ids are refused. **There is intentionally no
177
+ non-interactive way to apply a plan.**
178
+
179
+ <img src="docs/img/en-plan.png" alt="AI plan review in the web UI" width="860">
180
+
181
+ Install the skill for Claude Code:
182
+
183
+ ```sh
184
+ wsldu --install-skill # -> ~/.claude/skills/wsldu/SKILL.md
185
+ ```
186
+
187
+ Then ask: *"my WSL disk is full, what can I delete?"*. For other agents, point them to
188
+ [`wsldu/skill/SKILL.md`](wsldu/skill/SKILL.md) or [`AGENTS.md`](AGENTS.md).
189
+
190
+ <details><summary>Plan format</summary>
191
+
192
+ ```json
193
+ {
194
+ "wsldu_plan": 1,
195
+ "author": "Claude Code",
196
+ "summary": "Free ~12 GB: stale node_modules, pip/npm caches, dangling Docker images",
197
+ "items": [
198
+ {"type": "path", "path": "/home/me/old-app/node_modules", "reason": "not modified for 412 days"},
199
+ {"type": "cleanup", "id": "pip-cache", "reason": "pip cache, re-downloaded on demand"},
200
+ {"type": "docker", "kind": "image", "id": "4f2a9c1e7b3d", "reason": "dangling image"}
201
+ ]
202
+ }
203
+ ```
204
+ </details>
205
+
206
+ ## Safety
207
+
208
+ - **Every deletion asks first.** Deletions are permanent, so wsldu always shows the path or the
209
+ exact command before running it.
210
+ - **Protected paths.** System directories (`/`, `/usr`, `/etc`, `/var/lib/docker`...), your home
211
+ folder itself, `~/.ssh`, `~/.gnupg`, `~/.config` and Windows drives are always refused.
212
+ - **Validated Docker ids.** Docker object ids are checked before use, and commands are built
213
+ without shell injection.
214
+ - **Local web UI only.** It listens on localhost, requires a per-run random token, and checks the
215
+ `Host` header.
216
+ - **Root when needed.** Commands that need root use `sudo`. Without a terminal (web UI), they fall
217
+ back to `wsl.exe -u root`: you own the distro, so no password is needed.
218
+
219
+ ## Performance
220
+
221
+ wsldu walks the disk with `os.scandir`. It starts with a single thread and adds threads (up to 8)
222
+ only while the disk is the bottleneck. On a warm cache, Python threads only add contention.
223
+
224
+ | 1.53 M files, 280 k folders | warm cache | cold cache |
225
+ |---|---|---|
226
+ | single thread | 12.3 s | 262 s |
227
+ | **wsldu (adaptive)** | **10.8 to 16.6 s** | **116 s (×2.25)** |
228
+ | `du -sx` (C, reference) | 3.9 s | n/a |
229
+
230
+ All tabs except the explorer work while the scan runs.
231
+
232
+ ## FAQ
233
+
234
+ **Why not `wsl --manage <distro> --set-sparse true`?** Sparse VHDs shrink automatically, but
235
+ Microsoft documents corruption risks and the setting is not the default. Manual compaction is
236
+ safe and predictable.
237
+
238
+ **Windows Home?** Supported: wsldu uses `diskpart` when `Optimize-VHD` (Hyper-V) is not available.
239
+
240
+ **Docker Desktop?** Its disks (`docker_data.vhdx`, older `ext4.vhdx`) are detected and compacted
241
+ too. Its images are listed in the Docker tab when Docker Desktop integration is enabled for your
242
+ distro.
243
+
244
+ **WSL 1?** WSL 1 distros have no virtual disk: the analysis and cleanup tabs work, compaction is
245
+ not needed.
246
+
247
+ **Configuration?**
248
+
249
+ | Variable | Effect |
250
+ |---|---|
251
+ | `WSLDU_LANG` | Force the language (`en`, `fr`). |
252
+ | `WSLDU_PROJECTS` | Project roots used to map Docker objects to folders, separated by `:`. Default: `project:projects:src:code:dev:work:repos:git:workspace`. |
253
+ | `WSLDU_THREADS` | Maximum number of scan threads. |
254
+ | `WSLDU_NO_UPDATE_CHECK=1` | Disable the daily update check. |
255
+
256
+ ## Contributing
257
+
258
+ Issues and pull requests are welcome. wsldu has no dependencies and must stay that way.
259
+
260
+ ```sh
261
+ python3 -m unittest discover -s tests # tests
262
+ python3 tools/i18n_check.py # every UI string has a French translation
263
+ python3 tools/build_pyz.py # build dist/wsldu.pyz
264
+ ```
265
+
266
+ New language: copy `wsldu/lang_fr.py`, translate the values, and register it in `wsldu/i18n.py`.
267
+
268
+ To release, bump `__version__` in `wsldu/__init__.py` and add a `CHANGELOG.md` section. CI tags
269
+ and publishes the release when the change lands on `main`.
270
+
271
+ ## Support
272
+
273
+ wsldu is free and will stay free. If it saved your disk (or your afternoon), you can support my work on
274
+ **[Patreon](https://www.patreon.com/koffijoel)**. Stars, issues and pull requests help a lot too.
275
+
276
+ ## License
277
+
278
+ [MIT](LICENSE)
@@ -0,0 +1,51 @@
1
+ [build-system]
2
+ requires = ["setuptools>=77"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "wsldu"
7
+ dynamic = ["version"]
8
+ description = "Find what fills your WSL disk, clean it up, and give the space back to Windows (compact ext4.vhdx)."
9
+ readme = "README.md"
10
+ license = "MIT"
11
+ license-files = ["LICENSE"]
12
+ authors = [{ name = "Koffi Joel" }]
13
+ requires-python = ">=3.8"
14
+ dependencies = []
15
+ keywords = ["wsl", "wsl2", "vhdx", "disk-usage", "docker", "cleanup", "windows"]
16
+ classifiers = [
17
+ "Environment :: Console :: Curses",
18
+ "Environment :: Web Environment",
19
+ "Operating System :: POSIX :: Linux",
20
+ "Programming Language :: Python :: 3",
21
+ "Topic :: System :: Filesystems",
22
+ "Topic :: Utilities",
23
+ ]
24
+
25
+ [project.scripts]
26
+ wsldu = "wsldu.cli:main"
27
+
28
+ [project.urls]
29
+ Homepage = "https://koffijoel.github.io/wsldu/"
30
+ Source = "https://github.com/koffijoel/wsldu"
31
+ Changelog = "https://github.com/koffijoel/wsldu/blob/main/CHANGELOG.md"
32
+ Funding = "https://www.patreon.com/koffijoel"
33
+
34
+ [tool.setuptools]
35
+ packages = ["wsldu"]
36
+
37
+ [tool.setuptools.dynamic]
38
+ version = { attr = "wsldu.__version__" }
39
+
40
+ [tool.setuptools.package-data]
41
+ wsldu = ["static/*", "skill/*"]
42
+
43
+ [tool.ruff]
44
+ line-length = 150
45
+
46
+ [tool.ruff.lint]
47
+ select = ["E", "F", "W", "B"]
48
+
49
+ [tool.ruff.lint.per-file-ignores]
50
+ "wsldu/lang_fr.py" = ["E501"]
51
+ "tools/build_site.py" = ["E501"]
wsldu-1.1.0/setup.cfg ADDED
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+