deadweight-cli 1.0.2__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.
- deadweight_cli-1.0.2/LICENSE +21 -0
- deadweight_cli-1.0.2/PKG-INFO +288 -0
- deadweight_cli-1.0.2/README.md +259 -0
- deadweight_cli-1.0.2/deadweight.py +800 -0
- deadweight_cli-1.0.2/deadweight_cli.egg-info/PKG-INFO +288 -0
- deadweight_cli-1.0.2/deadweight_cli.egg-info/SOURCES.txt +11 -0
- deadweight_cli-1.0.2/deadweight_cli.egg-info/dependency_links.txt +1 -0
- deadweight_cli-1.0.2/deadweight_cli.egg-info/entry_points.txt +2 -0
- deadweight_cli-1.0.2/deadweight_cli.egg-info/requires.txt +1 -0
- deadweight_cli-1.0.2/deadweight_cli.egg-info/top_level.txt +1 -0
- deadweight_cli-1.0.2/pyproject.toml +48 -0
- deadweight_cli-1.0.2/setup.cfg +4 -0
- deadweight_cli-1.0.2/tests/test_deadweight.py +223 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 DeadWeight 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.
|
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: deadweight-cli
|
|
3
|
+
Version: 1.0.2
|
|
4
|
+
Summary: Find and clean heavy build artifacts and virtual environments across your projects.
|
|
5
|
+
Author: DeadWeight contributors
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/ASCTeam-prog/deadweight
|
|
8
|
+
Project-URL: Repository, https://github.com/ASCTeam-prog/deadweight
|
|
9
|
+
Project-URL: Issues, https://github.com/ASCTeam-prog/deadweight/issues
|
|
10
|
+
Project-URL: Releases, https://github.com/ASCTeam-prog/deadweight/releases
|
|
11
|
+
Keywords: cleanup,cli,developer-tools,disk-space,venv,node-modules
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Environment :: Console
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
21
|
+
Classifier: Topic :: Software Development :: Build Tools
|
|
22
|
+
Classifier: Topic :: System :: Filesystems
|
|
23
|
+
Classifier: Topic :: Utilities
|
|
24
|
+
Requires-Python: >=3.11
|
|
25
|
+
Description-Content-Type: text/markdown
|
|
26
|
+
License-File: LICENSE
|
|
27
|
+
Requires-Dist: rich>=13.0
|
|
28
|
+
Dynamic: license-file
|
|
29
|
+
|
|
30
|
+
<p align="center">
|
|
31
|
+
<a href="https://www.python.org/"><img alt="Python 3.11+" src="https://img.shields.io/badge/Python-3.11%2B-3776AB?style=flat-square&logo=python&logoColor=white"></a>
|
|
32
|
+
<a href="LICENSE"><img alt="License: MIT" src="https://img.shields.io/badge/License-MIT-2ea44f?style=flat-square"></a>
|
|
33
|
+
<a href="#usage"><img alt="CLI" src="https://img.shields.io/badge/CLI-Rich-8A2BE2?style=flat-square&logo=gnubash&logoColor=white"></a>
|
|
34
|
+
<a href="#safety"><img alt="Zero-Risk" src="https://img.shields.io/badge/Zero--Risk-read--only%20by%20default-0ea5e9?style=flat-square"></a>
|
|
35
|
+
</p>
|
|
36
|
+
|
|
37
|
+
# DeadWeight
|
|
38
|
+
|
|
39
|
+
**Find the dead weight in your projects before it eats your disk.**
|
|
40
|
+
|
|
41
|
+
DeadWeight is a small CLI for developers who collect virtual environments, `node_modules`, build folders, and caches across dozens of repositories. Point it at a directory, and it shows what is heavy, how stale each project looks, and how much space you can reclaim.
|
|
42
|
+
|
|
43
|
+
<p align="center">
|
|
44
|
+
<img src="https://raw.githubusercontent.com/ASCTeam-prog/deadweight/main/assets/1.png" alt="DeadWeight terminal report showing heavy artifacts, Git status, and reclaimable space" width="100%">
|
|
45
|
+
</p>
|
|
46
|
+
|
|
47
|
+
## Features
|
|
48
|
+
|
|
49
|
+
- Scans a directory tree for heavy artifacts: `venv`, `.venv`, `node_modules`, `__pycache__`, `.pytest_cache`, `dist`, `build`, `.pio`.
|
|
50
|
+
- Detects custom virtual environments by their `pyvenv.cfg` marker, even when the folder is named `my_env` or `atlas vpn env`.
|
|
51
|
+
- Reports Git state for every project with reported artifacts: clean, dirty (with a change count), no repository, or Git error.
|
|
52
|
+
- Shows the date of the last commit so you can spot abandoned projects.
|
|
53
|
+
- Rich, colorized report with per-project and total reclaimable space.
|
|
54
|
+
- Progress bar while scanning, written to `stderr` so machine-readable output stays clean.
|
|
55
|
+
- `--min-size` filter to ignore the small stuff.
|
|
56
|
+
- `--older-than DAYS` filter to focus on abandoned projects with stale Git history.
|
|
57
|
+
- `--json` output for dashboards, scripts, and cron jobs.
|
|
58
|
+
- `--clean` is opt-in and always asks for explicit confirmation first.
|
|
59
|
+
- `--clean --select` shows a numbered list and deletes only the artifacts you choose.
|
|
60
|
+
- Read-only by default. Symlinks and Windows junctions are never followed.
|
|
61
|
+
|
|
62
|
+
## Requirements
|
|
63
|
+
|
|
64
|
+
- Python 3.11 or newer
|
|
65
|
+
- Git (optional, but required for repository status)
|
|
66
|
+
- [rich](https://github.com/Textualize/rich) (installed automatically)
|
|
67
|
+
|
|
68
|
+
## Installation
|
|
69
|
+
|
|
70
|
+
From PyPI:
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
pipx install deadweight-cli
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
The package is named `deadweight-cli` and installs the `deadweight` command.
|
|
77
|
+
|
|
78
|
+
From a source checkout:
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
git clone https://github.com/ASCTeam-prog/deadweight.git
|
|
82
|
+
cd deadweight
|
|
83
|
+
pipx install .
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Or install it into the current environment in editable mode:
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
pip install -e .
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
The package exposes a single `deadweight` command:
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
deadweight --help
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## Binary Downloads
|
|
99
|
+
|
|
100
|
+
Prebuilt one-file binaries for every supported platform are attached to each [GitHub Release](https://github.com/ASCTeam-prog/deadweight/releases/latest):
|
|
101
|
+
|
|
102
|
+
| Platform | Download |
|
|
103
|
+
| --- | --- |
|
|
104
|
+
| Windows x64 | [`deadweight-windows-x64.exe`](https://github.com/ASCTeam-prog/deadweight/releases/latest/download/deadweight-windows-x64.exe) |
|
|
105
|
+
| Linux x64 | [`deadweight-linux-x64`](https://github.com/ASCTeam-prog/deadweight/releases/latest/download/deadweight-linux-x64) |
|
|
106
|
+
| macOS arm64 | [`deadweight-macos-arm64`](https://github.com/ASCTeam-prog/deadweight/releases/latest/download/deadweight-macos-arm64) |
|
|
107
|
+
|
|
108
|
+
On Linux and macOS, make the downloaded file executable with `chmod +x <file>` before running it. If macOS Gatekeeper blocks the unsigned binary, remove the quarantine flag with `xattr -d com.apple.quarantine <file>`.
|
|
109
|
+
|
|
110
|
+
## Usage
|
|
111
|
+
|
|
112
|
+
```text
|
|
113
|
+
deadweight [PATH] [--min-size MB] [--older-than DAYS] [--clean] [--select] [--json]
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
| Option | Description |
|
|
117
|
+
| --- | --- |
|
|
118
|
+
| `PATH` | Directory to scan. Defaults to the current directory. |
|
|
119
|
+
| `--min-size MB` | Only report heavy directories of at least this size (in MB). |
|
|
120
|
+
| `--older-than DAYS` | Only report projects whose last commit is older than this many days. |
|
|
121
|
+
| `--clean` | After the report, delete the found artifacts after confirmation. |
|
|
122
|
+
| `--select` | With `--clean`, show a numbered list and delete only the selected artifacts. |
|
|
123
|
+
| `--json` | Print the report as JSON instead of a table. |
|
|
124
|
+
| `--version` | Print the version and exit. |
|
|
125
|
+
|
|
126
|
+
### Scan the current directory
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
deadweight
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### Scan a projects folder
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
deadweight ~/projects
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### Only look at artifacts larger than 100 MB
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
deadweight ~/projects --min-size 100
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### Only look at abandoned projects
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
deadweight ~/projects --older-than 180
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
This includes only projects whose last commit is older than 180 days. Projects without a Git repository, without commits, or with Git errors are excluded while the filter is active. The default value is `0`, which disables the filter. It also applies to `--json`, `--clean`, and `--select`.
|
|
151
|
+
|
|
152
|
+
### Export a machine-readable report
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
deadweight ~/projects --json > report.json
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
### Clean up interactively
|
|
159
|
+
|
|
160
|
+
```bash
|
|
161
|
+
deadweight ~/projects --clean
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
`--clean` prints the report first, then asks once to confirm deletion of everything that was found:
|
|
165
|
+
|
|
166
|
+
```text
|
|
167
|
+
Delete 14 directories and free 6.4 GB? [y/n] (n):
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
Nothing is deleted unless you answer `y`. Every target is re-checked before removal: it must still be a known artifact directory or a valid virtual environment, and it must live inside the scanned root.
|
|
171
|
+
|
|
172
|
+
### Choose exactly what to clean
|
|
173
|
+
|
|
174
|
+
```bash
|
|
175
|
+
deadweight ~/projects --clean --select
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
`--select` adds a numbered list of every artifact with its project and size. Enter one or more numbers separated by commas, a range such as `3-5`, a combination such as `1, 3-5`, or `all`. An empty answer cancels the cleanup.
|
|
179
|
+
|
|
180
|
+
<p align="center">
|
|
181
|
+
<img src="https://raw.githubusercontent.com/ASCTeam-prog/deadweight/main/assets/2.png" alt="DeadWeight --clean --select showing a numbered artifact list and the selection prompt" width="100%">
|
|
182
|
+
</p>
|
|
183
|
+
|
|
184
|
+
The final confirmation is still required, and only the selected directories are removed.
|
|
185
|
+
|
|
186
|
+
## Sample output
|
|
187
|
+
|
|
188
|
+
```text
|
|
189
|
+
DeadWeight v1.0.2
|
|
190
|
+
4 targets scanned in /home/dev/projects
|
|
191
|
+
|
|
192
|
+
┌───────────────┬───────────┬─────────────┬─────────────────────────────────────────────┬──────────┐
|
|
193
|
+
│ Project │ Git │ Last commit │ Heavy artifacts │ Size │
|
|
194
|
+
├───────────────┼───────────┼─────────────┼─────────────────────────────────────────────┼──────────┤
|
|
195
|
+
│ data-pipeline │ no git │ — │ .venv 3.1 GB │ 3.3 GB │
|
|
196
|
+
│ │ │ │ build 220.8 MB │ │
|
|
197
|
+
│ legacy-api │ dirty (3) │ 2024-11-02 │ .venv 1.2 GB │ 1.2 GB │
|
|
198
|
+
│ │ │ │ __pycache__ 12.4 MB │ │
|
|
199
|
+
│ web-dashboard │ clean │ 2026-05-18 │ node_modules 840.1 MB │ 885.8 MB │
|
|
200
|
+
│ │ │ │ dist 45.7 MB │ │
|
|
201
|
+
├───────────────┼───────────┼─────────────┼─────────────────────────────────────────────┼──────────┤
|
|
202
|
+
│ TOTAL │ │ │ 6 dirs · 3 projects │ 5.4 GB │
|
|
203
|
+
└───────────────┴───────────┴─────────────┴─────────────────────────────────────────────┴──────────┘
|
|
204
|
+
|
|
205
|
+
Total junk: 5.4 GB
|
|
206
|
+
Can free: 5.39 GB
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
## How projects are detected
|
|
210
|
+
|
|
211
|
+
- If the scanned directory is a Git repository, it is treated as **one project**. Artifacts are searched recursively, but `.git`, symlinks, and junctions are skipped.
|
|
212
|
+
- Otherwise, every first-level subdirectory is treated as a separate project.
|
|
213
|
+
- Any directory containing a `pyvenv.cfg` file is treated as a virtual environment, even if its name is not `venv` or `.venv` (for example, `my_env` or `atlas vpn env`).
|
|
214
|
+
- Artifacts found directly in the scanned root, including custom environments, are reported under the root folder's own name instead of being treated as projects.
|
|
215
|
+
- Found artifact directories are never traversed further, so nested caches are counted once and their parent's size wins.
|
|
216
|
+
- Projects with no artifacts above the size threshold are omitted from the report.
|
|
217
|
+
|
|
218
|
+
## JSON output
|
|
219
|
+
|
|
220
|
+
```json
|
|
221
|
+
{
|
|
222
|
+
"tool": "deadweight",
|
|
223
|
+
"version": "1.0.2",
|
|
224
|
+
"scanned_path": "/home/dev/projects",
|
|
225
|
+
"scanned_projects": 4,
|
|
226
|
+
"generated_at": "2026-12-05T12:00:00+00:00",
|
|
227
|
+
"min_size_mb": 0.0,
|
|
228
|
+
"older_than_days": 0,
|
|
229
|
+
"projects": [
|
|
230
|
+
{
|
|
231
|
+
"name": "legacy-api",
|
|
232
|
+
"path": "/home/dev/projects/legacy-api",
|
|
233
|
+
"git": {
|
|
234
|
+
"status": "dirty",
|
|
235
|
+
"changed_files": 3,
|
|
236
|
+
"last_commit": "2024-11-02T09:14:00+00:00",
|
|
237
|
+
"error": null
|
|
238
|
+
},
|
|
239
|
+
"heavy_dirs": [
|
|
240
|
+
{
|
|
241
|
+
"path": "/home/dev/projects/legacy-api/.venv",
|
|
242
|
+
"name": ".venv",
|
|
243
|
+
"size_bytes": 1288490188,
|
|
244
|
+
"size": "1.2 GB"
|
|
245
|
+
}
|
|
246
|
+
],
|
|
247
|
+
"total_size_bytes": 1288490188,
|
|
248
|
+
"total_size": "1.2 GB"
|
|
249
|
+
}
|
|
250
|
+
],
|
|
251
|
+
"totals": {
|
|
252
|
+
"projects": 1,
|
|
253
|
+
"heavy_dirs": 1,
|
|
254
|
+
"total_size_bytes": 1288490188,
|
|
255
|
+
"total_size": "1.2 GB",
|
|
256
|
+
"reclaimable_gb": 1.2
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
The `totals.reclaimable_gb` field makes it easy to feed the result into dashboards or alerting.
|
|
262
|
+
|
|
263
|
+
## Safety
|
|
264
|
+
|
|
265
|
+
- DeadWeight is **read-only by default**.
|
|
266
|
+
- Deletion requires both `--clean` and a `y` answer to the confirmation prompt.
|
|
267
|
+
- `--select` is only accepted together with `--clean`, and the final confirmation is still mandatory.
|
|
268
|
+
- `--clean` and `--json` cannot be combined, so a prompt can never corrupt JSON output.
|
|
269
|
+
- Only known artifact directory names or directories containing a valid `pyvenv.cfg` marker are eligible for deletion.
|
|
270
|
+
- Symlinks, junctions, unreadable directories, and locked files do not crash the scan; they are skipped or reported.
|
|
271
|
+
- The last line of defense: every deletion target is verified to be inside the scanned root.
|
|
272
|
+
|
|
273
|
+
## Development
|
|
274
|
+
|
|
275
|
+
```bash
|
|
276
|
+
git clone https://github.com/ASCTeam-prog/deadweight.git
|
|
277
|
+
cd deadweight
|
|
278
|
+
pip install -e .
|
|
279
|
+
python deadweight.py --help
|
|
280
|
+
python deadweight.py . --min-size 10
|
|
281
|
+
python -m unittest discover -s tests -v
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
The test suite creates disposable projects in a temporary directory, including custom-named virtual environments, and exercises selective cleanup. Run a manual scan against a scratch directory before trying `--clean` on real projects.
|
|
285
|
+
|
|
286
|
+
## License
|
|
287
|
+
|
|
288
|
+
MIT
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="https://www.python.org/"><img alt="Python 3.11+" src="https://img.shields.io/badge/Python-3.11%2B-3776AB?style=flat-square&logo=python&logoColor=white"></a>
|
|
3
|
+
<a href="LICENSE"><img alt="License: MIT" src="https://img.shields.io/badge/License-MIT-2ea44f?style=flat-square"></a>
|
|
4
|
+
<a href="#usage"><img alt="CLI" src="https://img.shields.io/badge/CLI-Rich-8A2BE2?style=flat-square&logo=gnubash&logoColor=white"></a>
|
|
5
|
+
<a href="#safety"><img alt="Zero-Risk" src="https://img.shields.io/badge/Zero--Risk-read--only%20by%20default-0ea5e9?style=flat-square"></a>
|
|
6
|
+
</p>
|
|
7
|
+
|
|
8
|
+
# DeadWeight
|
|
9
|
+
|
|
10
|
+
**Find the dead weight in your projects before it eats your disk.**
|
|
11
|
+
|
|
12
|
+
DeadWeight is a small CLI for developers who collect virtual environments, `node_modules`, build folders, and caches across dozens of repositories. Point it at a directory, and it shows what is heavy, how stale each project looks, and how much space you can reclaim.
|
|
13
|
+
|
|
14
|
+
<p align="center">
|
|
15
|
+
<img src="https://raw.githubusercontent.com/ASCTeam-prog/deadweight/main/assets/1.png" alt="DeadWeight terminal report showing heavy artifacts, Git status, and reclaimable space" width="100%">
|
|
16
|
+
</p>
|
|
17
|
+
|
|
18
|
+
## Features
|
|
19
|
+
|
|
20
|
+
- Scans a directory tree for heavy artifacts: `venv`, `.venv`, `node_modules`, `__pycache__`, `.pytest_cache`, `dist`, `build`, `.pio`.
|
|
21
|
+
- Detects custom virtual environments by their `pyvenv.cfg` marker, even when the folder is named `my_env` or `atlas vpn env`.
|
|
22
|
+
- Reports Git state for every project with reported artifacts: clean, dirty (with a change count), no repository, or Git error.
|
|
23
|
+
- Shows the date of the last commit so you can spot abandoned projects.
|
|
24
|
+
- Rich, colorized report with per-project and total reclaimable space.
|
|
25
|
+
- Progress bar while scanning, written to `stderr` so machine-readable output stays clean.
|
|
26
|
+
- `--min-size` filter to ignore the small stuff.
|
|
27
|
+
- `--older-than DAYS` filter to focus on abandoned projects with stale Git history.
|
|
28
|
+
- `--json` output for dashboards, scripts, and cron jobs.
|
|
29
|
+
- `--clean` is opt-in and always asks for explicit confirmation first.
|
|
30
|
+
- `--clean --select` shows a numbered list and deletes only the artifacts you choose.
|
|
31
|
+
- Read-only by default. Symlinks and Windows junctions are never followed.
|
|
32
|
+
|
|
33
|
+
## Requirements
|
|
34
|
+
|
|
35
|
+
- Python 3.11 or newer
|
|
36
|
+
- Git (optional, but required for repository status)
|
|
37
|
+
- [rich](https://github.com/Textualize/rich) (installed automatically)
|
|
38
|
+
|
|
39
|
+
## Installation
|
|
40
|
+
|
|
41
|
+
From PyPI:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
pipx install deadweight-cli
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
The package is named `deadweight-cli` and installs the `deadweight` command.
|
|
48
|
+
|
|
49
|
+
From a source checkout:
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
git clone https://github.com/ASCTeam-prog/deadweight.git
|
|
53
|
+
cd deadweight
|
|
54
|
+
pipx install .
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Or install it into the current environment in editable mode:
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
pip install -e .
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
The package exposes a single `deadweight` command:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
deadweight --help
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## Binary Downloads
|
|
70
|
+
|
|
71
|
+
Prebuilt one-file binaries for every supported platform are attached to each [GitHub Release](https://github.com/ASCTeam-prog/deadweight/releases/latest):
|
|
72
|
+
|
|
73
|
+
| Platform | Download |
|
|
74
|
+
| --- | --- |
|
|
75
|
+
| Windows x64 | [`deadweight-windows-x64.exe`](https://github.com/ASCTeam-prog/deadweight/releases/latest/download/deadweight-windows-x64.exe) |
|
|
76
|
+
| Linux x64 | [`deadweight-linux-x64`](https://github.com/ASCTeam-prog/deadweight/releases/latest/download/deadweight-linux-x64) |
|
|
77
|
+
| macOS arm64 | [`deadweight-macos-arm64`](https://github.com/ASCTeam-prog/deadweight/releases/latest/download/deadweight-macos-arm64) |
|
|
78
|
+
|
|
79
|
+
On Linux and macOS, make the downloaded file executable with `chmod +x <file>` before running it. If macOS Gatekeeper blocks the unsigned binary, remove the quarantine flag with `xattr -d com.apple.quarantine <file>`.
|
|
80
|
+
|
|
81
|
+
## Usage
|
|
82
|
+
|
|
83
|
+
```text
|
|
84
|
+
deadweight [PATH] [--min-size MB] [--older-than DAYS] [--clean] [--select] [--json]
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
| Option | Description |
|
|
88
|
+
| --- | --- |
|
|
89
|
+
| `PATH` | Directory to scan. Defaults to the current directory. |
|
|
90
|
+
| `--min-size MB` | Only report heavy directories of at least this size (in MB). |
|
|
91
|
+
| `--older-than DAYS` | Only report projects whose last commit is older than this many days. |
|
|
92
|
+
| `--clean` | After the report, delete the found artifacts after confirmation. |
|
|
93
|
+
| `--select` | With `--clean`, show a numbered list and delete only the selected artifacts. |
|
|
94
|
+
| `--json` | Print the report as JSON instead of a table. |
|
|
95
|
+
| `--version` | Print the version and exit. |
|
|
96
|
+
|
|
97
|
+
### Scan the current directory
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
deadweight
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### Scan a projects folder
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
deadweight ~/projects
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### Only look at artifacts larger than 100 MB
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
deadweight ~/projects --min-size 100
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### Only look at abandoned projects
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
deadweight ~/projects --older-than 180
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
This includes only projects whose last commit is older than 180 days. Projects without a Git repository, without commits, or with Git errors are excluded while the filter is active. The default value is `0`, which disables the filter. It also applies to `--json`, `--clean`, and `--select`.
|
|
122
|
+
|
|
123
|
+
### Export a machine-readable report
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
deadweight ~/projects --json > report.json
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### Clean up interactively
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
deadweight ~/projects --clean
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
`--clean` prints the report first, then asks once to confirm deletion of everything that was found:
|
|
136
|
+
|
|
137
|
+
```text
|
|
138
|
+
Delete 14 directories and free 6.4 GB? [y/n] (n):
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
Nothing is deleted unless you answer `y`. Every target is re-checked before removal: it must still be a known artifact directory or a valid virtual environment, and it must live inside the scanned root.
|
|
142
|
+
|
|
143
|
+
### Choose exactly what to clean
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
deadweight ~/projects --clean --select
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
`--select` adds a numbered list of every artifact with its project and size. Enter one or more numbers separated by commas, a range such as `3-5`, a combination such as `1, 3-5`, or `all`. An empty answer cancels the cleanup.
|
|
150
|
+
|
|
151
|
+
<p align="center">
|
|
152
|
+
<img src="https://raw.githubusercontent.com/ASCTeam-prog/deadweight/main/assets/2.png" alt="DeadWeight --clean --select showing a numbered artifact list and the selection prompt" width="100%">
|
|
153
|
+
</p>
|
|
154
|
+
|
|
155
|
+
The final confirmation is still required, and only the selected directories are removed.
|
|
156
|
+
|
|
157
|
+
## Sample output
|
|
158
|
+
|
|
159
|
+
```text
|
|
160
|
+
DeadWeight v1.0.2
|
|
161
|
+
4 targets scanned in /home/dev/projects
|
|
162
|
+
|
|
163
|
+
┌───────────────┬───────────┬─────────────┬─────────────────────────────────────────────┬──────────┐
|
|
164
|
+
│ Project │ Git │ Last commit │ Heavy artifacts │ Size │
|
|
165
|
+
├───────────────┼───────────┼─────────────┼─────────────────────────────────────────────┼──────────┤
|
|
166
|
+
│ data-pipeline │ no git │ — │ .venv 3.1 GB │ 3.3 GB │
|
|
167
|
+
│ │ │ │ build 220.8 MB │ │
|
|
168
|
+
│ legacy-api │ dirty (3) │ 2024-11-02 │ .venv 1.2 GB │ 1.2 GB │
|
|
169
|
+
│ │ │ │ __pycache__ 12.4 MB │ │
|
|
170
|
+
│ web-dashboard │ clean │ 2026-05-18 │ node_modules 840.1 MB │ 885.8 MB │
|
|
171
|
+
│ │ │ │ dist 45.7 MB │ │
|
|
172
|
+
├───────────────┼───────────┼─────────────┼─────────────────────────────────────────────┼──────────┤
|
|
173
|
+
│ TOTAL │ │ │ 6 dirs · 3 projects │ 5.4 GB │
|
|
174
|
+
└───────────────┴───────────┴─────────────┴─────────────────────────────────────────────┴──────────┘
|
|
175
|
+
|
|
176
|
+
Total junk: 5.4 GB
|
|
177
|
+
Can free: 5.39 GB
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
## How projects are detected
|
|
181
|
+
|
|
182
|
+
- If the scanned directory is a Git repository, it is treated as **one project**. Artifacts are searched recursively, but `.git`, symlinks, and junctions are skipped.
|
|
183
|
+
- Otherwise, every first-level subdirectory is treated as a separate project.
|
|
184
|
+
- Any directory containing a `pyvenv.cfg` file is treated as a virtual environment, even if its name is not `venv` or `.venv` (for example, `my_env` or `atlas vpn env`).
|
|
185
|
+
- Artifacts found directly in the scanned root, including custom environments, are reported under the root folder's own name instead of being treated as projects.
|
|
186
|
+
- Found artifact directories are never traversed further, so nested caches are counted once and their parent's size wins.
|
|
187
|
+
- Projects with no artifacts above the size threshold are omitted from the report.
|
|
188
|
+
|
|
189
|
+
## JSON output
|
|
190
|
+
|
|
191
|
+
```json
|
|
192
|
+
{
|
|
193
|
+
"tool": "deadweight",
|
|
194
|
+
"version": "1.0.2",
|
|
195
|
+
"scanned_path": "/home/dev/projects",
|
|
196
|
+
"scanned_projects": 4,
|
|
197
|
+
"generated_at": "2026-12-05T12:00:00+00:00",
|
|
198
|
+
"min_size_mb": 0.0,
|
|
199
|
+
"older_than_days": 0,
|
|
200
|
+
"projects": [
|
|
201
|
+
{
|
|
202
|
+
"name": "legacy-api",
|
|
203
|
+
"path": "/home/dev/projects/legacy-api",
|
|
204
|
+
"git": {
|
|
205
|
+
"status": "dirty",
|
|
206
|
+
"changed_files": 3,
|
|
207
|
+
"last_commit": "2024-11-02T09:14:00+00:00",
|
|
208
|
+
"error": null
|
|
209
|
+
},
|
|
210
|
+
"heavy_dirs": [
|
|
211
|
+
{
|
|
212
|
+
"path": "/home/dev/projects/legacy-api/.venv",
|
|
213
|
+
"name": ".venv",
|
|
214
|
+
"size_bytes": 1288490188,
|
|
215
|
+
"size": "1.2 GB"
|
|
216
|
+
}
|
|
217
|
+
],
|
|
218
|
+
"total_size_bytes": 1288490188,
|
|
219
|
+
"total_size": "1.2 GB"
|
|
220
|
+
}
|
|
221
|
+
],
|
|
222
|
+
"totals": {
|
|
223
|
+
"projects": 1,
|
|
224
|
+
"heavy_dirs": 1,
|
|
225
|
+
"total_size_bytes": 1288490188,
|
|
226
|
+
"total_size": "1.2 GB",
|
|
227
|
+
"reclaimable_gb": 1.2
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
The `totals.reclaimable_gb` field makes it easy to feed the result into dashboards or alerting.
|
|
233
|
+
|
|
234
|
+
## Safety
|
|
235
|
+
|
|
236
|
+
- DeadWeight is **read-only by default**.
|
|
237
|
+
- Deletion requires both `--clean` and a `y` answer to the confirmation prompt.
|
|
238
|
+
- `--select` is only accepted together with `--clean`, and the final confirmation is still mandatory.
|
|
239
|
+
- `--clean` and `--json` cannot be combined, so a prompt can never corrupt JSON output.
|
|
240
|
+
- Only known artifact directory names or directories containing a valid `pyvenv.cfg` marker are eligible for deletion.
|
|
241
|
+
- Symlinks, junctions, unreadable directories, and locked files do not crash the scan; they are skipped or reported.
|
|
242
|
+
- The last line of defense: every deletion target is verified to be inside the scanned root.
|
|
243
|
+
|
|
244
|
+
## Development
|
|
245
|
+
|
|
246
|
+
```bash
|
|
247
|
+
git clone https://github.com/ASCTeam-prog/deadweight.git
|
|
248
|
+
cd deadweight
|
|
249
|
+
pip install -e .
|
|
250
|
+
python deadweight.py --help
|
|
251
|
+
python deadweight.py . --min-size 10
|
|
252
|
+
python -m unittest discover -s tests -v
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
The test suite creates disposable projects in a temporary directory, including custom-named virtual environments, and exercises selective cleanup. Run a manual scan against a scratch directory before trying `--clean` on real projects.
|
|
256
|
+
|
|
257
|
+
## License
|
|
258
|
+
|
|
259
|
+
MIT
|