devklean 1.0.2__tar.gz → 1.2.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.
Files changed (99) hide show
  1. {devklean-1.0.2 → devklean-1.2.0}/CHANGELOG.md +52 -1
  2. {devklean-1.0.2 → devklean-1.2.0}/PKG-INFO +98 -5
  3. {devklean-1.0.2 → devklean-1.2.0}/README.md +92 -3
  4. {devklean-1.0.2 → devklean-1.2.0}/pyproject.toml +5 -0
  5. {devklean-1.0.2 → devklean-1.2.0}/src/devklean/__init__.py +2 -2
  6. {devklean-1.0.2 → devklean-1.2.0}/src/devklean/_version.py +1 -1
  7. devklean-1.2.0/src/devklean/cli/commands/analyze.py +34 -0
  8. {devklean-1.0.2 → devklean-1.2.0}/src/devklean/cli/commands/clean.py +24 -2
  9. {devklean-1.0.2 → devklean-1.2.0}/src/devklean/cli/commands/common.py +17 -3
  10. devklean-1.2.0/src/devklean/cli/commands/explain.py +35 -0
  11. {devklean-1.0.2 → devklean-1.2.0}/src/devklean/cli/dispatcher.py +4 -0
  12. {devklean-1.0.2 → devklean-1.2.0}/src/devklean/cli/parser.py +41 -2
  13. {devklean-1.0.2 → devklean-1.2.0}/src/devklean/config/manager.py +19 -0
  14. {devklean-1.0.2 → devklean-1.2.0}/src/devklean/config/models.py +14 -0
  15. devklean-1.2.0/src/devklean/deletion/compression.py +248 -0
  16. {devklean-1.0.2 → devklean-1.2.0}/src/devklean/deletion/metadata.py +96 -5
  17. devklean-1.2.0/src/devklean/deletion/trash.py +235 -0
  18. {devklean-1.0.2 → devklean-1.2.0}/src/devklean/models.py +22 -0
  19. {devklean-1.0.2 → devklean-1.2.0}/src/devklean/output/text.py +101 -2
  20. devklean-1.2.0/src/devklean/signatures/__init__.py +31 -0
  21. devklean-1.2.0/src/devklean/signatures/analysis.py +99 -0
  22. devklean-1.2.0/src/devklean/signatures/health.py +56 -0
  23. devklean-1.2.0/src/devklean/signatures/registry.py +206 -0
  24. devklean-1.2.0/src/devklean/signatures/staleness.py +126 -0
  25. devklean-1.2.0/src/devklean/signatures/structural.py +38 -0
  26. {devklean-1.0.2 → devklean-1.2.0}/src/devklean/tui.py +12 -1
  27. devklean-1.2.0/tests/test_analyze_command.py +146 -0
  28. {devklean-1.0.2 → devklean-1.2.0}/tests/test_cli_parser.py +8 -1
  29. devklean-1.2.0/tests/test_compression.py +188 -0
  30. {devklean-1.0.2 → devklean-1.2.0}/tests/test_config.py +15 -1
  31. {devklean-1.0.2 → devklean-1.2.0}/tests/test_config_precedence.py +3 -0
  32. devklean-1.2.0/tests/test_deletion.py +512 -0
  33. {devklean-1.0.2 → devklean-1.2.0}/tests/test_doctor.py +33 -1
  34. devklean-1.2.0/tests/test_explain_command.py +100 -0
  35. {devklean-1.0.2 → devklean-1.2.0}/tests/test_history.py +2 -2
  36. {devklean-1.0.2 → devklean-1.2.0}/tests/test_integrity.py +30 -2
  37. devklean-1.2.0/tests/test_interruption.py +178 -0
  38. {devklean-1.0.2 → devklean-1.2.0}/tests/test_restore.py +1 -0
  39. devklean-1.2.0/tests/test_signatures_health.py +89 -0
  40. devklean-1.2.0/tests/test_signatures_registry.py +86 -0
  41. devklean-1.2.0/tests/test_signatures_staleness.py +102 -0
  42. devklean-1.2.0/tests/test_signatures_structural.py +39 -0
  43. devklean-1.0.2/src/devklean/deletion/trash.py +0 -89
  44. devklean-1.0.2/tests/test_deletion.py +0 -242
  45. {devklean-1.0.2 → devklean-1.2.0}/.gitignore +0 -0
  46. {devklean-1.0.2 → devklean-1.2.0}/LICENSE +0 -0
  47. {devklean-1.0.2 → devklean-1.2.0}/src/devklean/__main__.py +0 -0
  48. {devklean-1.0.2 → devklean-1.2.0}/src/devklean/cli/__init__.py +0 -0
  49. {devklean-1.0.2 → devklean-1.2.0}/src/devklean/cli/commands/__init__.py +0 -0
  50. {devklean-1.0.2 → devklean-1.2.0}/src/devklean/cli/commands/doctor.py +0 -0
  51. {devklean-1.0.2 → devklean-1.2.0}/src/devklean/cli/commands/history.py +0 -0
  52. {devklean-1.0.2 → devklean-1.2.0}/src/devklean/cli/commands/restore.py +0 -0
  53. {devklean-1.0.2 → devklean-1.2.0}/src/devklean/cli/commands/scan.py +0 -0
  54. {devklean-1.0.2 → devklean-1.2.0}/src/devklean/cli/confirmation.py +0 -0
  55. {devklean-1.0.2 → devklean-1.2.0}/src/devklean/cli/main.py +0 -0
  56. {devklean-1.0.2 → devklean-1.2.0}/src/devklean/config/__init__.py +0 -0
  57. {devklean-1.0.2 → devklean-1.2.0}/src/devklean/config/defaults.py +0 -0
  58. {devklean-1.0.2 → devklean-1.2.0}/src/devklean/config/paths.py +0 -0
  59. {devklean-1.0.2 → devklean-1.2.0}/src/devklean/config/targets.py +0 -0
  60. {devklean-1.0.2 → devklean-1.2.0}/src/devklean/deletion/__init__.py +0 -0
  61. {devklean-1.0.2 → devklean-1.2.0}/src/devklean/deletion/history.py +0 -0
  62. {devklean-1.0.2 → devklean-1.2.0}/src/devklean/deletion/integrity.py +0 -0
  63. {devklean-1.0.2 → devklean-1.2.0}/src/devklean/deletion/paths.py +0 -0
  64. {devklean-1.0.2 → devklean-1.2.0}/src/devklean/deletion/safety.py +0 -0
  65. {devklean-1.0.2 → devklean-1.2.0}/src/devklean/formatting.py +0 -0
  66. {devklean-1.0.2 → devklean-1.2.0}/src/devklean/logging_setup.py +0 -0
  67. {devklean-1.0.2 → devklean-1.2.0}/src/devklean/output/__init__.py +0 -0
  68. {devklean-1.0.2 → devklean-1.2.0}/src/devklean/output/base.py +0 -0
  69. {devklean-1.0.2 → devklean-1.2.0}/src/devklean/output/console.py +0 -0
  70. {devklean-1.0.2 → devklean-1.2.0}/src/devklean/output/history_payload.py +0 -0
  71. {devklean-1.0.2 → devklean-1.2.0}/src/devklean/output/json.py +0 -0
  72. {devklean-1.0.2 → devklean-1.2.0}/src/devklean/output/scan_payload.py +0 -0
  73. {devklean-1.0.2 → devklean-1.2.0}/src/devklean/output/sorting.py +0 -0
  74. {devklean-1.0.2 → devklean-1.2.0}/src/devklean/output/theme.py +0 -0
  75. {devklean-1.0.2 → devklean-1.2.0}/src/devklean/scanner/__init__.py +0 -0
  76. {devklean-1.0.2 → devklean-1.2.0}/src/devklean/scanner/filters.py +0 -0
  77. {devklean-1.0.2 → devklean-1.2.0}/src/devklean/scanner/scanner.py +0 -0
  78. {devklean-1.0.2 → devklean-1.2.0}/tests/benchmark_scanner.py +0 -0
  79. {devklean-1.0.2 → devklean-1.2.0}/tests/conftest.py +0 -0
  80. {devklean-1.0.2 → devklean-1.2.0}/tests/test_clean_flow.py +0 -0
  81. {devklean-1.0.2 → devklean-1.2.0}/tests/test_confirmation.py +0 -0
  82. {devklean-1.0.2 → devklean-1.2.0}/tests/test_console.py +0 -0
  83. {devklean-1.0.2 → devklean-1.2.0}/tests/test_dry_run.py +0 -0
  84. {devklean-1.0.2 → devklean-1.2.0}/tests/test_formatting.py +0 -0
  85. {devklean-1.0.2 → devklean-1.2.0}/tests/test_integration.py +0 -0
  86. {devklean-1.0.2 → devklean-1.2.0}/tests/test_json_output.py +0 -0
  87. {devklean-1.0.2 → devklean-1.2.0}/tests/test_logging.py +0 -0
  88. {devklean-1.0.2 → devklean-1.2.0}/tests/test_main_signal.py +0 -0
  89. {devklean-1.0.2 → devklean-1.2.0}/tests/test_models.py +0 -0
  90. {devklean-1.0.2 → devklean-1.2.0}/tests/test_output_sorting.py +0 -0
  91. {devklean-1.0.2 → devklean-1.2.0}/tests/test_packaging.py +0 -0
  92. {devklean-1.0.2 → devklean-1.2.0}/tests/test_perf_scan.py +0 -0
  93. {devklean-1.0.2 → devklean-1.2.0}/tests/test_safety.py +0 -0
  94. {devklean-1.0.2 → devklean-1.2.0}/tests/test_scan_json_cli.py +0 -0
  95. {devklean-1.0.2 → devklean-1.2.0}/tests/test_scan_permissions.py +0 -0
  96. {devklean-1.0.2 → devklean-1.2.0}/tests/test_scan_settings.py +0 -0
  97. {devklean-1.0.2 → devklean-1.2.0}/tests/test_scanner.py +0 -0
  98. {devklean-1.0.2 → devklean-1.2.0}/tests/test_text_renderer.py +0 -0
  99. {devklean-1.0.2 → devklean-1.2.0}/tests/test_windows_guard.py +0 -0
@@ -7,6 +7,55 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [1.2.0] - 2026-11-29
11
+
12
+ ### Added
13
+
14
+ - Python 3.13 is now tested in CI (Linux, macOS, Windows) and declared via
15
+ the `Programming Language :: Python :: 3.13` classifier. No code changes
16
+ were needed; the universal `py3-none-any` wheel is unchanged.
17
+
18
+ ### Fixed
19
+
20
+ - Compress-before-trash where the archive reaches trash but the original
21
+ directory cannot be removed is now a distinct `partial` outcome on
22
+ `DeleteResult` (not success, not plain failure). The trashed archive is
23
+ recorded in metadata with `status = "partial"` (schema version 6) so
24
+ `history` and `doctor` can see it; CLI output warns plainly instead of
25
+ reporting a generic failure.
26
+
27
+ ## [1.1.0] - 2026-07-09
28
+
29
+ ### Added
30
+
31
+ - **`analyze [PATH]`** — scan for cleanable directories and cross-reference
32
+ them against a new artifact-signature registry: buckets results into
33
+ recognized (a known artifact type, with risk tier, confidence, and a
34
+ staleness estimate for its parent project) and unrecognized (no registry
35
+ entry, no verdict fabricated), flags project roots with conflicting
36
+ package-manager lockfiles, and reports an overall workspace-health score
37
+ (0-100). `--verbose` prints the scoring formula and its raw inputs.
38
+ - **`explain PATH`** — look up a single directory against the same
39
+ signature registry and explain what it is: ecosystem, what generates it,
40
+ how to regenerate it, risk tier, confidence, and the rationale behind the
41
+ entry. An unrecognized path gets no risk/confidence verdict at all.
42
+ - Artifact-signature registry (`devklean.signatures`) backing both commands
43
+ above — static, maintainer-assigned data (not inferred) covering
44
+ `node_modules`, `venv`/`.venv`/`env`, `__pycache__`, `.next`, `dist`, and
45
+ `.cache`.
46
+ - `--compress` flag (and matching `compress` config default) for `clean`:
47
+ when set, eligible directories are archived into a sibling `.tar.gz` (or
48
+ `.tar.zst`, via the `devklean[zstd]` extra) before being sent to trash,
49
+ shrinking the footprint of large artifacts like `node_modules` or
50
+ `.venv`. Compression is ordered for safety — archive, verify, send the
51
+ archive to trash, and only then remove the original — so a failure at
52
+ any step leaves the source directory untouched. New `compress_min_size`
53
+ and `compress_format` config keys tune the size threshold and archive
54
+ format. Metadata schema bumped to version 5 to record the archive path,
55
+ format, and original/compressed sizes; restoring a compressed item
56
+ currently requires unpacking the archive by hand after pulling it out of
57
+ trash.
58
+
10
59
  ## [1.0.2] - 2026-07-01
11
60
 
12
61
  ### Changed
@@ -104,7 +153,9 @@ First public pre-release.
104
153
  per-target sizing.
105
154
  - **Packaging** — distributable via `pip`/`pipx`; MIT licensed.
106
155
 
107
- [Unreleased]: https://github.com/smurftyy/devklean/compare/v1.0.2...HEAD
156
+ [Unreleased]: https://github.com/smurftyy/devklean/compare/v1.2.0...HEAD
157
+ [1.2.0]: https://github.com/smurftyy/devklean/compare/v1.1.0...v1.2.0
158
+ [1.1.0]: https://github.com/smurftyy/devklean/compare/v1.0.2...v1.1.0
108
159
  [1.0.2]: https://github.com/smurftyy/devklean/compare/v1.0.1...v1.0.2
109
160
  [1.0.1]: https://github.com/smurftyy/devklean/compare/v1.0.0...v1.0.1
110
161
  [1.0.0]: https://github.com/smurftyy/devklean/compare/v0.1.0...v1.0.0
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.4
1
+ Metadata-Version: 2.5
2
2
  Name: devklean
3
- Version: 1.0.2
3
+ Version: 1.2.0
4
4
  Summary: Clean up common development artifacts (node_modules, .venv, caches) to reclaim disk space
5
5
  Project-URL: Homepage, https://github.com/smurftyy/devklean
6
6
  Project-URL: Repository, https://github.com/smurftyy/devklean
@@ -21,6 +21,7 @@ Classifier: Programming Language :: Python :: 3.9
21
21
  Classifier: Programming Language :: Python :: 3.10
22
22
  Classifier: Programming Language :: Python :: 3.11
23
23
  Classifier: Programming Language :: Python :: 3.12
24
+ Classifier: Programming Language :: Python :: 3.13
24
25
  Classifier: Topic :: System :: Filesystems
25
26
  Classifier: Topic :: Utilities
26
27
  Requires-Python: >=3.8
@@ -33,14 +34,19 @@ Requires-Dist: mypy>=1.8; extra == 'dev'
33
34
  Requires-Dist: pytest-cov>=4.0; extra == 'dev'
34
35
  Requires-Dist: pytest>=7.0; extra == 'dev'
35
36
  Requires-Dist: ruff>=0.6; extra == 'dev'
37
+ Requires-Dist: zstandard>=0.21; extra == 'dev'
38
+ Provides-Extra: zstd
39
+ Requires-Dist: zstandard>=0.21; extra == 'zstd'
36
40
  Description-Content-Type: text/markdown
37
41
 
38
42
  # devklean
43
+ 🧹 The ultimate developer cleanup utility.
39
44
 
40
45
  [![CI](https://github.com/smurftyy/devklean/actions/workflows/ci.yml/badge.svg)](https://github.com/smurftyy/devklean/actions/workflows/ci.yml)
41
46
  [![PyPI version](https://img.shields.io/pypi/v/devklean.svg)](https://pypi.org/project/devklean/)
42
47
  [![Python versions](https://img.shields.io/pypi/pyversions/devklean.svg)](https://pypi.org/project/devklean/)
43
48
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/smurftyy/devklean/blob/main/LICENSE)
49
+ [![Website](https://img.shields.io/website?url=https%3A%2F%2Fdevklean.smurftyy.dev&up_message=online&up_color=green&down_message=offline&down_color=red&label=Landing%20Page)](https://devklean.smurftyy.dev)
44
50
 
45
51
  **Reclaim disk space by safely cleaning up development artifacts** — `node_modules`, `.venv`, build caches, and other regenerable directories — with a trash-backed safety net so nothing is ever lost to a typo.
46
52
 
@@ -62,7 +68,7 @@ pipx install devklean
62
68
  pip install devklean
63
69
  ```
64
70
 
65
- Requires Python 3.8+. Runtime dependencies are `send2trash` (used for all deletions) and `tomli` (only on Python < 3.11).
71
+ Requires Python 3.8+. Runtime dependencies are `send2trash` (used for all deletions) and `tomli` (only on Python < 3.11). `zstandard` is an optional dependency, only needed for `compress_format = "zstd"` — see [Compression](#compression).
66
72
 
67
73
  ## Quick start
68
74
 
@@ -83,6 +89,8 @@ devklean clean --dry-run
83
89
  | --- | --- |
84
90
  | `devklean scan [PATH]` | Find cleanable directories and report sizes. Never deletes. |
85
91
  | `devklean clean [PATH]` | Scan, then delete (to trash) after confirmation. |
92
+ | `devklean analyze [PATH]` | Scan and report a signature-backed analysis: risk, staleness, structural issues, workspace health. |
93
+ | `devklean explain PATH` | Explain what a single directory is, using the artifact-signature registry. |
86
94
  | `devklean restore` | Explain how to recover deleted items from your system trash. |
87
95
  | `devklean history` | Show previous cleanup operations (timestamp, size, strategy, item count). |
88
96
  | `devklean doctor` | Inspect and repair the deletion metadata store. |
@@ -107,6 +115,7 @@ devklean clean --dry-run # show what *would* be deleted; delete nothing
107
115
  devklean clean -i # interactive: pick items in a TUI (Linux/macOS only)
108
116
  devklean clean --allow-symlinks # permit deleting symlinked targets (blocked by default)
109
117
  devklean clean -y # skip the y/N prompt (large deletions still require typing DELETE)
118
+ devklean clean --compress # compress eligible directories (gzip) before sending them to trash
110
119
  ```
111
120
 
112
121
  | Flag | Meaning |
@@ -115,6 +124,31 @@ devklean clean -y # skip the y/N prompt (large deletions still req
115
124
  | `-i`, `--interactive` | Choose items in a terminal UI (SPACE select, A all, D none, ENTER confirm, Q quit). **Linux/macOS only** — see [Platform support](#platform-support). |
116
125
  | `--allow-symlinks` | Allow deleting symbolic links. Off by default (symlinks are blocked). |
117
126
  | `-y`, `--yes` | Skip the standard confirmation. Deletions over the size threshold still require typing `DELETE`. |
127
+ | `--compress` | Compress eligible directories into a sibling archive before trashing them, shrinking their footprint in trash. Off by default — see [Compression](#compression). |
128
+
129
+ ### `analyze`
130
+
131
+ ```bash
132
+ devklean analyze # analyze the current directory
133
+ devklean analyze ~/projects # analyze a specific path
134
+ devklean analyze --verbose # also print the workspace-health formula and its raw inputs
135
+ ```
136
+
137
+ Scans like `scan`/`clean`, then cross-references every cleanable directory against the artifact-signature registry (the same data `explain` uses) and buckets each into:
138
+
139
+ - **Recognized** — has a registry entry: shown with its risk tier, ecosystem, and a staleness estimate for its parent project (last git commit date, falling back to the newest source-file mtime).
140
+ - **Not recognized** — no registry entry, so no risk/confidence verdict is given.
141
+
142
+ It also flags project roots with conflicting package-manager lockfiles (e.g. both `package-lock.json` and `pnpm-lock.yaml` present) and prints an overall **workspace health** score from 0-100, weighted by recognized directories' risk and size. `analyze` never deletes anything — it's a read-only report.
143
+
144
+ ### `explain`
145
+
146
+ ```bash
147
+ devklean explain node_modules # explain a directory relative to the current path
148
+ devklean explain ~/code/app/.next # explain an absolute path
149
+ ```
150
+
151
+ Looks up the given path's directory name in the artifact-signature registry and prints what it is: ecosystem, what generates it, how to regenerate it, risk tier, confidence, and the rationale behind the entry. An unrecognized directory gets no fabricated risk or confidence verdict.
118
152
 
119
153
  ### `restore`
120
154
 
@@ -130,6 +164,12 @@ devklean restore # explains how to recover from the Recycle Bin / Trash
130
164
  - **macOS** — open Trash in Finder and "Put Back".
131
165
  - **Linux** — open Trash in your file manager and restore.
132
166
 
167
+ If the item was deleted with `--compress`, what lands in trash is a `.tar.gz`
168
+ (or `.tar.zst`, if `compress_format = "zstd"`) archive rather than the original
169
+ directory — restore the archive from trash, then extract it to the original
170
+ path yourself, e.g. `tar -xf <name>.tar.gz`. devklean does not decompress
171
+ automatically (yet).
172
+
133
173
  Run `devklean history` to see what was removed and when.
134
174
 
135
175
  ### `history`
@@ -174,7 +214,8 @@ Delete 3 directories (~834.0 MB)? (y/N) y
174
214
  ## Platform support
175
215
 
176
216
  `devklean` runs on **Linux, macOS, and Windows**. All core commands — `scan`,
177
- `clean`, `history`, `doctor`, and `restore` — work on every platform.
217
+ `clean`, `analyze`, `explain`, `history`, `doctor`, and `restore` — work on
218
+ every platform.
178
219
 
179
220
  **Known limitation:** interactive mode (`-i` / `--interactive`) is **Linux/macOS
180
221
  only** for now. It is built on Python's `curses` module, which is not available
@@ -200,6 +241,9 @@ exclude = ["node_modules", ".git"]
200
241
  dry_run = false
201
242
  interactive = false
202
243
  default_yes = false # skip the y/N prompt (the large-deletion DELETE gate still applies)
244
+ compress = false # compress eligible directories before trashing them
245
+ compress_min_size = 10485760 # bytes; directories smaller than this are trashed uncompressed (default 10 MiB)
246
+ compress_format = "gzip" # "gzip" (stdlib, default) or "zstd" (needs the devklean[zstd] extra)
203
247
  theme = "default" # "default" or "mono"
204
248
  confirm_threshold = 1073741824 # bytes; deletions >= this require typing DELETE (default 1 GiB)
205
249
  path = "."
@@ -218,6 +262,50 @@ Scalar keys from the project file override the global file; list keys (`exclude`
218
262
 
219
263
  Color follows the `theme` setting and is automatically disabled when output is piped or `NO_COLOR` is set.
220
264
 
265
+ ## Compression
266
+
267
+ Common artifacts (`node_modules`, `.venv`, `.next`, build caches) often compress
268
+ to a fraction of their on-disk size. Pass `--compress` (or set `compress = true`
269
+ in config) and devklean will archive each eligible directory into a sibling
270
+ `.tar.gz` (gzip, the default) before sending *that* to trash instead of the raw
271
+ directory — shrinking how much space the deletion actually occupies in trash
272
+ before it's emptied. `zstd` is available as an opt-in format (see below) for a
273
+ better compression ratio.
274
+
275
+ Compression is always ordered for safety: devklean compresses to a temp
276
+ archive, verifies it (test-extracts every entry and cross-checks the file
277
+ count and total uncompressed size against the source), and only *after*
278
+ `send2trash` confirms the archive is in the trash does it remove the original
279
+ directory. If compression or verification fails, or `send2trash` itself fails,
280
+ the original directory is left completely untouched and the error is reported
281
+ per-item — nothing is ever partially deleted.
282
+
283
+ - Only applies to directories (not symlinks) at or above `compress_min_size`
284
+ (default 10 MiB); smaller directories and files are trashed as-is, since the
285
+ archive/verify overhead rarely pays for itself below that size.
286
+ - The archive path, format, original size, and compressed size are recorded in
287
+ deletion metadata, so `history` and `doctor` see compressed deletions the
288
+ same as uncompressed ones.
289
+ - Off by default, so existing scripts and habits aren't surprised by archives
290
+ appearing in trash.
291
+ - Restoring a compressed item is manual today — see [`restore`](#restore).
292
+
293
+ ### zstd (optional)
294
+
295
+ ```bash
296
+ pip install 'devklean[zstd]'
297
+ ```
298
+
299
+ ```toml
300
+ [defaults]
301
+ compress = true
302
+ compress_format = "zstd"
303
+ ```
304
+
305
+ If `compress_format = "zstd"` is set but the `zstandard` package isn't
306
+ installed, devklean logs a warning and falls back to gzip rather than
307
+ crashing.
308
+
221
309
  ## Logs
222
310
 
223
311
  `devklean` writes detailed structured logs (commands, scanned/deleted paths, sizes, errors) to:
@@ -253,7 +341,12 @@ Run `devklean doctor` to detect and remove corrupt metadata records.
253
341
 
254
342
  ## Contributing
255
343
 
256
- See [CONTRIBUTING.md](CONTRIBUTING.md). Bug reports and PRs are welcome.
344
+ See [CONTRIBUTING.md](CONTRIBUTING.md) — pull requests target the `dev` branch.
345
+ Bug reports and PRs are welcome; [`good first issue`](https://github.com/smurftyy/devklean/labels/good%20first%20issue)
346
+ is a good place to start. Questions and ideas go in [Discussions](https://github.com/smurftyy/devklean/discussions).
347
+
348
+ This project follows a [Code of Conduct](CODE_OF_CONDUCT.md). To report a security
349
+ issue, see [SECURITY.md](SECURITY.md).
257
350
 
258
351
  ## License
259
352
 
@@ -1,9 +1,11 @@
1
1
  # devklean
2
+ 🧹 The ultimate developer cleanup utility.
2
3
 
3
4
  [![CI](https://github.com/smurftyy/devklean/actions/workflows/ci.yml/badge.svg)](https://github.com/smurftyy/devklean/actions/workflows/ci.yml)
4
5
  [![PyPI version](https://img.shields.io/pypi/v/devklean.svg)](https://pypi.org/project/devklean/)
5
6
  [![Python versions](https://img.shields.io/pypi/pyversions/devklean.svg)](https://pypi.org/project/devklean/)
6
7
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/smurftyy/devklean/blob/main/LICENSE)
8
+ [![Website](https://img.shields.io/website?url=https%3A%2F%2Fdevklean.smurftyy.dev&up_message=online&up_color=green&down_message=offline&down_color=red&label=Landing%20Page)](https://devklean.smurftyy.dev)
7
9
 
8
10
  **Reclaim disk space by safely cleaning up development artifacts** — `node_modules`, `.venv`, build caches, and other regenerable directories — with a trash-backed safety net so nothing is ever lost to a typo.
9
11
 
@@ -25,7 +27,7 @@ pipx install devklean
25
27
  pip install devklean
26
28
  ```
27
29
 
28
- Requires Python 3.8+. Runtime dependencies are `send2trash` (used for all deletions) and `tomli` (only on Python < 3.11).
30
+ Requires Python 3.8+. Runtime dependencies are `send2trash` (used for all deletions) and `tomli` (only on Python < 3.11). `zstandard` is an optional dependency, only needed for `compress_format = "zstd"` — see [Compression](#compression).
29
31
 
30
32
  ## Quick start
31
33
 
@@ -46,6 +48,8 @@ devklean clean --dry-run
46
48
  | --- | --- |
47
49
  | `devklean scan [PATH]` | Find cleanable directories and report sizes. Never deletes. |
48
50
  | `devklean clean [PATH]` | Scan, then delete (to trash) after confirmation. |
51
+ | `devklean analyze [PATH]` | Scan and report a signature-backed analysis: risk, staleness, structural issues, workspace health. |
52
+ | `devklean explain PATH` | Explain what a single directory is, using the artifact-signature registry. |
49
53
  | `devklean restore` | Explain how to recover deleted items from your system trash. |
50
54
  | `devklean history` | Show previous cleanup operations (timestamp, size, strategy, item count). |
51
55
  | `devklean doctor` | Inspect and repair the deletion metadata store. |
@@ -70,6 +74,7 @@ devklean clean --dry-run # show what *would* be deleted; delete nothing
70
74
  devklean clean -i # interactive: pick items in a TUI (Linux/macOS only)
71
75
  devklean clean --allow-symlinks # permit deleting symlinked targets (blocked by default)
72
76
  devklean clean -y # skip the y/N prompt (large deletions still require typing DELETE)
77
+ devklean clean --compress # compress eligible directories (gzip) before sending them to trash
73
78
  ```
74
79
 
75
80
  | Flag | Meaning |
@@ -78,6 +83,31 @@ devklean clean -y # skip the y/N prompt (large deletions still req
78
83
  | `-i`, `--interactive` | Choose items in a terminal UI (SPACE select, A all, D none, ENTER confirm, Q quit). **Linux/macOS only** — see [Platform support](#platform-support). |
79
84
  | `--allow-symlinks` | Allow deleting symbolic links. Off by default (symlinks are blocked). |
80
85
  | `-y`, `--yes` | Skip the standard confirmation. Deletions over the size threshold still require typing `DELETE`. |
86
+ | `--compress` | Compress eligible directories into a sibling archive before trashing them, shrinking their footprint in trash. Off by default — see [Compression](#compression). |
87
+
88
+ ### `analyze`
89
+
90
+ ```bash
91
+ devklean analyze # analyze the current directory
92
+ devklean analyze ~/projects # analyze a specific path
93
+ devklean analyze --verbose # also print the workspace-health formula and its raw inputs
94
+ ```
95
+
96
+ Scans like `scan`/`clean`, then cross-references every cleanable directory against the artifact-signature registry (the same data `explain` uses) and buckets each into:
97
+
98
+ - **Recognized** — has a registry entry: shown with its risk tier, ecosystem, and a staleness estimate for its parent project (last git commit date, falling back to the newest source-file mtime).
99
+ - **Not recognized** — no registry entry, so no risk/confidence verdict is given.
100
+
101
+ It also flags project roots with conflicting package-manager lockfiles (e.g. both `package-lock.json` and `pnpm-lock.yaml` present) and prints an overall **workspace health** score from 0-100, weighted by recognized directories' risk and size. `analyze` never deletes anything — it's a read-only report.
102
+
103
+ ### `explain`
104
+
105
+ ```bash
106
+ devklean explain node_modules # explain a directory relative to the current path
107
+ devklean explain ~/code/app/.next # explain an absolute path
108
+ ```
109
+
110
+ Looks up the given path's directory name in the artifact-signature registry and prints what it is: ecosystem, what generates it, how to regenerate it, risk tier, confidence, and the rationale behind the entry. An unrecognized directory gets no fabricated risk or confidence verdict.
81
111
 
82
112
  ### `restore`
83
113
 
@@ -93,6 +123,12 @@ devklean restore # explains how to recover from the Recycle Bin / Trash
93
123
  - **macOS** — open Trash in Finder and "Put Back".
94
124
  - **Linux** — open Trash in your file manager and restore.
95
125
 
126
+ If the item was deleted with `--compress`, what lands in trash is a `.tar.gz`
127
+ (or `.tar.zst`, if `compress_format = "zstd"`) archive rather than the original
128
+ directory — restore the archive from trash, then extract it to the original
129
+ path yourself, e.g. `tar -xf <name>.tar.gz`. devklean does not decompress
130
+ automatically (yet).
131
+
96
132
  Run `devklean history` to see what was removed and when.
97
133
 
98
134
  ### `history`
@@ -137,7 +173,8 @@ Delete 3 directories (~834.0 MB)? (y/N) y
137
173
  ## Platform support
138
174
 
139
175
  `devklean` runs on **Linux, macOS, and Windows**. All core commands — `scan`,
140
- `clean`, `history`, `doctor`, and `restore` — work on every platform.
176
+ `clean`, `analyze`, `explain`, `history`, `doctor`, and `restore` — work on
177
+ every platform.
141
178
 
142
179
  **Known limitation:** interactive mode (`-i` / `--interactive`) is **Linux/macOS
143
180
  only** for now. It is built on Python's `curses` module, which is not available
@@ -163,6 +200,9 @@ exclude = ["node_modules", ".git"]
163
200
  dry_run = false
164
201
  interactive = false
165
202
  default_yes = false # skip the y/N prompt (the large-deletion DELETE gate still applies)
203
+ compress = false # compress eligible directories before trashing them
204
+ compress_min_size = 10485760 # bytes; directories smaller than this are trashed uncompressed (default 10 MiB)
205
+ compress_format = "gzip" # "gzip" (stdlib, default) or "zstd" (needs the devklean[zstd] extra)
166
206
  theme = "default" # "default" or "mono"
167
207
  confirm_threshold = 1073741824 # bytes; deletions >= this require typing DELETE (default 1 GiB)
168
208
  path = "."
@@ -181,6 +221,50 @@ Scalar keys from the project file override the global file; list keys (`exclude`
181
221
 
182
222
  Color follows the `theme` setting and is automatically disabled when output is piped or `NO_COLOR` is set.
183
223
 
224
+ ## Compression
225
+
226
+ Common artifacts (`node_modules`, `.venv`, `.next`, build caches) often compress
227
+ to a fraction of their on-disk size. Pass `--compress` (or set `compress = true`
228
+ in config) and devklean will archive each eligible directory into a sibling
229
+ `.tar.gz` (gzip, the default) before sending *that* to trash instead of the raw
230
+ directory — shrinking how much space the deletion actually occupies in trash
231
+ before it's emptied. `zstd` is available as an opt-in format (see below) for a
232
+ better compression ratio.
233
+
234
+ Compression is always ordered for safety: devklean compresses to a temp
235
+ archive, verifies it (test-extracts every entry and cross-checks the file
236
+ count and total uncompressed size against the source), and only *after*
237
+ `send2trash` confirms the archive is in the trash does it remove the original
238
+ directory. If compression or verification fails, or `send2trash` itself fails,
239
+ the original directory is left completely untouched and the error is reported
240
+ per-item — nothing is ever partially deleted.
241
+
242
+ - Only applies to directories (not symlinks) at or above `compress_min_size`
243
+ (default 10 MiB); smaller directories and files are trashed as-is, since the
244
+ archive/verify overhead rarely pays for itself below that size.
245
+ - The archive path, format, original size, and compressed size are recorded in
246
+ deletion metadata, so `history` and `doctor` see compressed deletions the
247
+ same as uncompressed ones.
248
+ - Off by default, so existing scripts and habits aren't surprised by archives
249
+ appearing in trash.
250
+ - Restoring a compressed item is manual today — see [`restore`](#restore).
251
+
252
+ ### zstd (optional)
253
+
254
+ ```bash
255
+ pip install 'devklean[zstd]'
256
+ ```
257
+
258
+ ```toml
259
+ [defaults]
260
+ compress = true
261
+ compress_format = "zstd"
262
+ ```
263
+
264
+ If `compress_format = "zstd"` is set but the `zstandard` package isn't
265
+ installed, devklean logs a warning and falls back to gzip rather than
266
+ crashing.
267
+
184
268
  ## Logs
185
269
 
186
270
  `devklean` writes detailed structured logs (commands, scanned/deleted paths, sizes, errors) to:
@@ -216,7 +300,12 @@ Run `devklean doctor` to detect and remove corrupt metadata records.
216
300
 
217
301
  ## Contributing
218
302
 
219
- See [CONTRIBUTING.md](CONTRIBUTING.md). Bug reports and PRs are welcome.
303
+ See [CONTRIBUTING.md](CONTRIBUTING.md) — pull requests target the `dev` branch.
304
+ Bug reports and PRs are welcome; [`good first issue`](https://github.com/smurftyy/devklean/labels/good%20first%20issue)
305
+ is a good place to start. Questions and ideas go in [Discussions](https://github.com/smurftyy/devklean/discussions).
306
+
307
+ This project follows a [Code of Conduct](CODE_OF_CONDUCT.md). To report a security
308
+ issue, see [SECURITY.md](SECURITY.md).
220
309
 
221
310
  ## License
222
311
 
@@ -26,6 +26,7 @@ classifiers = [
26
26
  "Programming Language :: Python :: 3.10",
27
27
  "Programming Language :: Python :: 3.11",
28
28
  "Programming Language :: Python :: 3.12",
29
+ "Programming Language :: Python :: 3.13",
29
30
  "Topic :: System :: Filesystems",
30
31
  "Topic :: Utilities",
31
32
  ]
@@ -36,12 +37,16 @@ dependencies = [
36
37
  ]
37
38
 
38
39
  [project.optional-dependencies]
40
+ zstd = [
41
+ "zstandard>=0.21",
42
+ ]
39
43
  dev = [
40
44
  "pytest>=7.0",
41
45
  "pytest-cov>=4.0",
42
46
  "ruff>=0.6",
43
47
  "mypy>=1.8",
44
48
  "build>=1.0",
49
+ "zstandard>=0.21",
45
50
  ]
46
51
 
47
52
  [project.scripts]
@@ -1,6 +1,6 @@
1
1
  """devklean — scan and remove node_modules / venvs to reclaim disk space."""
2
2
 
3
3
  from devklean._version import __version__
4
- from devklean.models import CleanableItem, DeleteFailure, DeleteResult
4
+ from devklean.models import CleanableItem, DeleteFailure, DeleteResult, PartialDeletion
5
5
 
6
- __all__ = ["CleanableItem", "DeleteFailure", "DeleteResult", "__version__"]
6
+ __all__ = ["CleanableItem", "DeleteFailure", "DeleteResult", "PartialDeletion", "__version__"]
@@ -5,4 +5,4 @@ this file (see ``[tool.hatch.version]`` in pyproject.toml), so a release bump is
5
5
  a one-line change here and nowhere else.
6
6
  """
7
7
 
8
- __version__ = "1.0.2"
8
+ __version__ = "1.2.0"
@@ -0,0 +1,34 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import TYPE_CHECKING
4
+
5
+ from devklean.cli.commands.common import resolve_root
6
+ from devklean.config.models import AppConfig
7
+ from devklean.scanner.scanner import scan_tree
8
+ from devklean.signatures.analysis import analyze_candidates
9
+
10
+ if TYPE_CHECKING:
11
+ from devklean.output.text import TextRenderer
12
+
13
+
14
+ def run_analyze(args, renderer: TextRenderer, config: AppConfig) -> int:
15
+ """Scan for cleanable directories and report a signature-backed analysis.
16
+
17
+ Calls ``scan_tree`` directly — the exact discovery function ``clean``/
18
+ ``scan`` use via ``scan_directory`` — rather than a second walker.
19
+ ``scan_directory`` isn't reused as-is because its "nothing found" path
20
+ renders clean/scan's own summary and stops; analyze always wants to
21
+ render its own report (recognized/unrecognized buckets, structural
22
+ checks, health score), even over an empty candidate list.
23
+ """
24
+ root = resolve_root(args.path, renderer)
25
+ if root is None:
26
+ return 1
27
+
28
+ scan_report = scan_tree(root, settings=config.scan_settings)
29
+ if scan_report.permission_errors:
30
+ renderer.permission_warnings(scan_report.permission_errors)
31
+
32
+ analysis = analyze_candidates(root, scan_report.items)
33
+ renderer.analyze_report(analysis, verbose=getattr(args, "verbose", False))
34
+ return 0
@@ -8,7 +8,7 @@ from devklean.cli.confirmation import (
8
8
  confirm_large_deletion,
9
9
  exceeds_threshold,
10
10
  )
11
- from devklean.config.models import AppConfig
11
+ from devklean.config.models import DEFAULT_COMPRESS_FORMAT, DEFAULT_COMPRESS_MIN_SIZE, AppConfig
12
12
  from devklean.deletion.safety import SafetyValidator
13
13
  from devklean.models import CleanableItem
14
14
  from devklean.output.base import Renderer
@@ -45,6 +45,9 @@ def run_standard(
45
45
  dry_run: bool,
46
46
  validator: SafetyValidator | None = None,
47
47
  *,
48
+ compress: bool = False,
49
+ compress_min_size: int = DEFAULT_COMPRESS_MIN_SIZE,
50
+ compress_format: str = DEFAULT_COMPRESS_FORMAT,
48
51
  default_yes: bool = False,
49
52
  confirm_threshold: int = DEFAULT_LARGE_THRESHOLD,
50
53
  ) -> None:
@@ -58,7 +61,14 @@ def run_standard(
58
61
  renderer.aborted()
59
62
  return
60
63
 
61
- result = delete_items(found, total_size, validator=validator)
64
+ result = delete_items(
65
+ found,
66
+ total_size,
67
+ validator=validator,
68
+ compress=compress,
69
+ compress_min_size=compress_min_size,
70
+ compress_format=compress_format,
71
+ )
62
72
  renderer.deletion_result(result)
63
73
 
64
74
 
@@ -76,6 +86,12 @@ def run_clean(
76
86
  defaults = config.defaults
77
87
  default_yes = getattr(args, "yes", False) or getattr(defaults, "default_yes", False)
78
88
  confirm_threshold = getattr(defaults, "confirm_threshold", DEFAULT_LARGE_THRESHOLD)
89
+ compress = getattr(args, "compress", False) or getattr(defaults, "compress", False)
90
+ # compress_min_size/compress_format are config-only knobs, not CLI flags:
91
+ # --compress is the only opt-in surface on the command line, so these two
92
+ # are read straight from defaults rather than duplicated as flags.
93
+ compress_min_size = getattr(defaults, "compress_min_size", DEFAULT_COMPRESS_MIN_SIZE)
94
+ compress_format = getattr(defaults, "compress_format", DEFAULT_COMPRESS_FORMAT)
79
95
 
80
96
  if args.interactive:
81
97
  # Interactive mode relies on curses, which is unavailable on Windows.
@@ -97,6 +113,9 @@ def run_clean(
97
113
  found,
98
114
  args.dry_run,
99
115
  validator,
116
+ compress=compress,
117
+ compress_min_size=compress_min_size,
118
+ compress_format=compress_format,
100
119
  confirm_threshold=confirm_threshold,
101
120
  )
102
121
  else:
@@ -105,6 +124,9 @@ def run_clean(
105
124
  found,
106
125
  args.dry_run,
107
126
  validator,
127
+ compress=compress,
128
+ compress_min_size=compress_min_size,
129
+ compress_format=compress_format,
108
130
  default_yes=default_yes,
109
131
  confirm_threshold=confirm_threshold,
110
132
  )
@@ -9,15 +9,29 @@ from devklean.output.base import Renderer
9
9
  from devklean.scanner.scanner import scan_tree
10
10
 
11
11
 
12
+ def resolve_root(path: str, renderer: Renderer) -> str | None:
13
+ """Resolve ``path`` to an absolute directory, reporting and returning
14
+ ``None`` if it isn't one.
15
+
16
+ Shared by every command that takes a directory argument (``scan``,
17
+ ``clean``, ``analyze``, ``explain``) so they agree on what "invalid
18
+ directory" means.
19
+ """
20
+ root = os.path.abspath(path)
21
+ if not os.path.isdir(root):
22
+ renderer.invalid_directory(root)
23
+ return None
24
+ return root
25
+
26
+
12
27
  def scan_directory(
13
28
  args,
14
29
  renderer: Renderer,
15
30
  config: AppConfig,
16
31
  ) -> tuple[int, list[CleanableItem] | None]:
17
32
  """Validate the root path, scan, and report when nothing is found."""
18
- root = os.path.abspath(args.path)
19
- if not os.path.isdir(root):
20
- renderer.invalid_directory(root)
33
+ root = resolve_root(args.path, renderer)
34
+ if root is None:
21
35
  return 1, None
22
36
 
23
37
  renderer.scan_start(root)
@@ -0,0 +1,35 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import TYPE_CHECKING
4
+
5
+ from devklean.cli.commands.common import resolve_root
6
+ from devklean.signatures import match_signature
7
+
8
+ if TYPE_CHECKING:
9
+ from devklean.output.text import TextRenderer
10
+
11
+
12
+ def run_explain(args, renderer: TextRenderer, config) -> int:
13
+ """Resolve a path against the artifact-signature registry and explain it.
14
+
15
+ Every field printed on a match comes straight from the matched
16
+ ``ArtifactSignature`` — nothing here is generated freeform. On no match,
17
+ no risk/confidence verdict is given at all; guessing about an unrecognized
18
+ path is a hard constraint, not a style choice.
19
+
20
+ Text-only by design, like ``doctor``/``restore``: this is a direct lookup
21
+ report, not a scannable result set, so it never needs the JSON scan/history
22
+ payload shape.
23
+ """
24
+ path = resolve_root(args.path, renderer)
25
+ if path is None:
26
+ return 1
27
+
28
+ signature = match_signature(path)
29
+
30
+ if signature is None:
31
+ renderer.explain_no_match(path)
32
+ return 0
33
+
34
+ renderer.explain_match(path, signature)
35
+ return 0
@@ -3,8 +3,10 @@ from __future__ import annotations
3
3
  import sys
4
4
  from typing import Callable
5
5
 
6
+ from devklean.cli.commands.analyze import run_analyze
6
7
  from devklean.cli.commands.clean import run_clean
7
8
  from devklean.cli.commands.doctor import run_doctor
9
+ from devklean.cli.commands.explain import run_explain
8
10
  from devklean.cli.commands.history import run_history
9
11
  from devklean.cli.commands.restore import run_restore
10
12
  from devklean.cli.commands.scan import run_scan
@@ -23,6 +25,8 @@ _COMMANDS: dict[str, CommandHandler] = {
23
25
  "history": run_history,
24
26
  "doctor": run_doctor,
25
27
  "restore": run_restore,
28
+ "explain": run_explain,
29
+ "analyze": run_analyze,
26
30
  }
27
31
 
28
32