devklean 1.0.2__tar.gz → 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.
Files changed (98) hide show
  1. {devklean-1.0.2 → devklean-1.1.0}/CHANGELOG.md +30 -0
  2. {devklean-1.0.2 → devklean-1.1.0}/PKG-INFO +88 -3
  3. {devklean-1.0.2 → devklean-1.1.0}/README.md +84 -2
  4. {devklean-1.0.2 → devklean-1.1.0}/pyproject.toml +4 -0
  5. {devklean-1.0.2 → devklean-1.1.0}/src/devklean/_version.py +1 -1
  6. devklean-1.1.0/src/devklean/cli/commands/analyze.py +34 -0
  7. {devklean-1.0.2 → devklean-1.1.0}/src/devklean/cli/commands/clean.py +24 -2
  8. {devklean-1.0.2 → devklean-1.1.0}/src/devklean/cli/commands/common.py +17 -3
  9. devklean-1.1.0/src/devklean/cli/commands/explain.py +35 -0
  10. {devklean-1.0.2 → devklean-1.1.0}/src/devklean/cli/dispatcher.py +4 -0
  11. {devklean-1.0.2 → devklean-1.1.0}/src/devklean/cli/parser.py +41 -2
  12. {devklean-1.0.2 → devklean-1.1.0}/src/devklean/config/manager.py +19 -0
  13. {devklean-1.0.2 → devklean-1.1.0}/src/devklean/config/models.py +14 -0
  14. devklean-1.1.0/src/devklean/deletion/compression.py +248 -0
  15. {devklean-1.0.2 → devklean-1.1.0}/src/devklean/deletion/metadata.py +71 -3
  16. devklean-1.1.0/src/devklean/deletion/trash.py +188 -0
  17. {devklean-1.0.2 → devklean-1.1.0}/src/devklean/output/text.py +94 -1
  18. devklean-1.1.0/src/devklean/signatures/__init__.py +31 -0
  19. devklean-1.1.0/src/devklean/signatures/analysis.py +99 -0
  20. devklean-1.1.0/src/devklean/signatures/health.py +56 -0
  21. devklean-1.1.0/src/devklean/signatures/registry.py +206 -0
  22. devklean-1.1.0/src/devklean/signatures/staleness.py +126 -0
  23. devklean-1.1.0/src/devklean/signatures/structural.py +38 -0
  24. {devklean-1.0.2 → devklean-1.1.0}/src/devklean/tui.py +12 -1
  25. devklean-1.1.0/tests/test_analyze_command.py +146 -0
  26. {devklean-1.0.2 → devklean-1.1.0}/tests/test_cli_parser.py +8 -1
  27. devklean-1.1.0/tests/test_compression.py +188 -0
  28. {devklean-1.0.2 → devklean-1.1.0}/tests/test_config.py +15 -1
  29. {devklean-1.0.2 → devklean-1.1.0}/tests/test_config_precedence.py +3 -0
  30. devklean-1.1.0/tests/test_deletion.py +444 -0
  31. {devklean-1.0.2 → devklean-1.1.0}/tests/test_doctor.py +33 -1
  32. devklean-1.1.0/tests/test_explain_command.py +100 -0
  33. {devklean-1.0.2 → devklean-1.1.0}/tests/test_history.py +2 -2
  34. {devklean-1.0.2 → devklean-1.1.0}/tests/test_integrity.py +30 -2
  35. {devklean-1.0.2 → devklean-1.1.0}/tests/test_restore.py +1 -0
  36. devklean-1.1.0/tests/test_signatures_health.py +89 -0
  37. devklean-1.1.0/tests/test_signatures_registry.py +86 -0
  38. devklean-1.1.0/tests/test_signatures_staleness.py +102 -0
  39. devklean-1.1.0/tests/test_signatures_structural.py +39 -0
  40. devklean-1.0.2/src/devklean/deletion/trash.py +0 -89
  41. devklean-1.0.2/tests/test_deletion.py +0 -242
  42. {devklean-1.0.2 → devklean-1.1.0}/.gitignore +0 -0
  43. {devklean-1.0.2 → devklean-1.1.0}/LICENSE +0 -0
  44. {devklean-1.0.2 → devklean-1.1.0}/src/devklean/__init__.py +0 -0
  45. {devklean-1.0.2 → devklean-1.1.0}/src/devklean/__main__.py +0 -0
  46. {devklean-1.0.2 → devklean-1.1.0}/src/devklean/cli/__init__.py +0 -0
  47. {devklean-1.0.2 → devklean-1.1.0}/src/devklean/cli/commands/__init__.py +0 -0
  48. {devklean-1.0.2 → devklean-1.1.0}/src/devklean/cli/commands/doctor.py +0 -0
  49. {devklean-1.0.2 → devklean-1.1.0}/src/devklean/cli/commands/history.py +0 -0
  50. {devklean-1.0.2 → devklean-1.1.0}/src/devklean/cli/commands/restore.py +0 -0
  51. {devklean-1.0.2 → devklean-1.1.0}/src/devklean/cli/commands/scan.py +0 -0
  52. {devklean-1.0.2 → devklean-1.1.0}/src/devklean/cli/confirmation.py +0 -0
  53. {devklean-1.0.2 → devklean-1.1.0}/src/devklean/cli/main.py +0 -0
  54. {devklean-1.0.2 → devklean-1.1.0}/src/devklean/config/__init__.py +0 -0
  55. {devklean-1.0.2 → devklean-1.1.0}/src/devklean/config/defaults.py +0 -0
  56. {devklean-1.0.2 → devklean-1.1.0}/src/devklean/config/paths.py +0 -0
  57. {devklean-1.0.2 → devklean-1.1.0}/src/devklean/config/targets.py +0 -0
  58. {devklean-1.0.2 → devklean-1.1.0}/src/devklean/deletion/__init__.py +0 -0
  59. {devklean-1.0.2 → devklean-1.1.0}/src/devklean/deletion/history.py +0 -0
  60. {devklean-1.0.2 → devklean-1.1.0}/src/devklean/deletion/integrity.py +0 -0
  61. {devklean-1.0.2 → devklean-1.1.0}/src/devklean/deletion/paths.py +0 -0
  62. {devklean-1.0.2 → devklean-1.1.0}/src/devklean/deletion/safety.py +0 -0
  63. {devklean-1.0.2 → devklean-1.1.0}/src/devklean/formatting.py +0 -0
  64. {devklean-1.0.2 → devklean-1.1.0}/src/devklean/logging_setup.py +0 -0
  65. {devklean-1.0.2 → devklean-1.1.0}/src/devklean/models.py +0 -0
  66. {devklean-1.0.2 → devklean-1.1.0}/src/devklean/output/__init__.py +0 -0
  67. {devklean-1.0.2 → devklean-1.1.0}/src/devklean/output/base.py +0 -0
  68. {devklean-1.0.2 → devklean-1.1.0}/src/devklean/output/console.py +0 -0
  69. {devklean-1.0.2 → devklean-1.1.0}/src/devklean/output/history_payload.py +0 -0
  70. {devklean-1.0.2 → devklean-1.1.0}/src/devklean/output/json.py +0 -0
  71. {devklean-1.0.2 → devklean-1.1.0}/src/devklean/output/scan_payload.py +0 -0
  72. {devklean-1.0.2 → devklean-1.1.0}/src/devklean/output/sorting.py +0 -0
  73. {devklean-1.0.2 → devklean-1.1.0}/src/devklean/output/theme.py +0 -0
  74. {devklean-1.0.2 → devklean-1.1.0}/src/devklean/scanner/__init__.py +0 -0
  75. {devklean-1.0.2 → devklean-1.1.0}/src/devklean/scanner/filters.py +0 -0
  76. {devklean-1.0.2 → devklean-1.1.0}/src/devklean/scanner/scanner.py +0 -0
  77. {devklean-1.0.2 → devklean-1.1.0}/tests/benchmark_scanner.py +0 -0
  78. {devklean-1.0.2 → devklean-1.1.0}/tests/conftest.py +0 -0
  79. {devklean-1.0.2 → devklean-1.1.0}/tests/test_clean_flow.py +0 -0
  80. {devklean-1.0.2 → devklean-1.1.0}/tests/test_confirmation.py +0 -0
  81. {devklean-1.0.2 → devklean-1.1.0}/tests/test_console.py +0 -0
  82. {devklean-1.0.2 → devklean-1.1.0}/tests/test_dry_run.py +0 -0
  83. {devklean-1.0.2 → devklean-1.1.0}/tests/test_formatting.py +0 -0
  84. {devklean-1.0.2 → devklean-1.1.0}/tests/test_integration.py +0 -0
  85. {devklean-1.0.2 → devklean-1.1.0}/tests/test_json_output.py +0 -0
  86. {devklean-1.0.2 → devklean-1.1.0}/tests/test_logging.py +0 -0
  87. {devklean-1.0.2 → devklean-1.1.0}/tests/test_main_signal.py +0 -0
  88. {devklean-1.0.2 → devklean-1.1.0}/tests/test_models.py +0 -0
  89. {devklean-1.0.2 → devklean-1.1.0}/tests/test_output_sorting.py +0 -0
  90. {devklean-1.0.2 → devklean-1.1.0}/tests/test_packaging.py +0 -0
  91. {devklean-1.0.2 → devklean-1.1.0}/tests/test_perf_scan.py +0 -0
  92. {devklean-1.0.2 → devklean-1.1.0}/tests/test_safety.py +0 -0
  93. {devklean-1.0.2 → devklean-1.1.0}/tests/test_scan_json_cli.py +0 -0
  94. {devklean-1.0.2 → devklean-1.1.0}/tests/test_scan_permissions.py +0 -0
  95. {devklean-1.0.2 → devklean-1.1.0}/tests/test_scan_settings.py +0 -0
  96. {devklean-1.0.2 → devklean-1.1.0}/tests/test_scanner.py +0 -0
  97. {devklean-1.0.2 → devklean-1.1.0}/tests/test_text_renderer.py +0 -0
  98. {devklean-1.0.2 → devklean-1.1.0}/tests/test_windows_guard.py +0 -0
@@ -7,6 +7,36 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ### Added
11
+
12
+ - **`analyze [PATH]`** — scan for cleanable directories and cross-reference
13
+ them against a new artifact-signature registry: buckets results into
14
+ recognized (a known artifact type, with risk tier, confidence, and a
15
+ staleness estimate for its parent project) and unrecognized (no registry
16
+ entry, no verdict fabricated), flags project roots with conflicting
17
+ package-manager lockfiles, and reports an overall workspace-health score
18
+ (0-100). `--verbose` prints the scoring formula and its raw inputs.
19
+ - **`explain PATH`** — look up a single directory against the same
20
+ signature registry and explain what it is: ecosystem, what generates it,
21
+ how to regenerate it, risk tier, confidence, and the rationale behind the
22
+ entry. An unrecognized path gets no risk/confidence verdict at all.
23
+ - Artifact-signature registry (`devklean.signatures`) backing both commands
24
+ above — static, maintainer-assigned data (not inferred) covering
25
+ `node_modules`, `venv`/`.venv`/`env`, `__pycache__`, `.next`, `dist`, and
26
+ `.cache`.
27
+ - `--compress` flag (and matching `compress` config default) for `clean`:
28
+ when set, eligible directories are archived into a sibling `.tar.gz` (or
29
+ `.tar.zst`, via the `devklean[zstd]` extra) before being sent to trash,
30
+ shrinking the footprint of large artifacts like `node_modules` or
31
+ `.venv`. Compression is ordered for safety — archive, verify, send the
32
+ archive to trash, and only then remove the original — so a failure at
33
+ any step leaves the source directory untouched. New `compress_min_size`
34
+ and `compress_format` config keys tune the size threshold and archive
35
+ format. Metadata schema bumped to version 5 to record the archive path,
36
+ format, and original/compressed sizes; restoring a compressed item
37
+ currently requires unpacking the archive by hand after pulling it out of
38
+ trash.
39
+
10
40
  ## [1.0.2] - 2026-07-01
11
41
 
12
42
  ### Changed
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: devklean
3
- Version: 1.0.2
3
+ Version: 1.1.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
@@ -33,6 +33,9 @@ Requires-Dist: mypy>=1.8; extra == 'dev'
33
33
  Requires-Dist: pytest-cov>=4.0; extra == 'dev'
34
34
  Requires-Dist: pytest>=7.0; extra == 'dev'
35
35
  Requires-Dist: ruff>=0.6; extra == 'dev'
36
+ Requires-Dist: zstandard>=0.21; extra == 'dev'
37
+ Provides-Extra: zstd
38
+ Requires-Dist: zstandard>=0.21; extra == 'zstd'
36
39
  Description-Content-Type: text/markdown
37
40
 
38
41
  # devklean
@@ -62,7 +65,7 @@ pipx install devklean
62
65
  pip install devklean
63
66
  ```
64
67
 
65
- Requires Python 3.8+. Runtime dependencies are `send2trash` (used for all deletions) and `tomli` (only on Python < 3.11).
68
+ 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
69
 
67
70
  ## Quick start
68
71
 
@@ -83,6 +86,8 @@ devklean clean --dry-run
83
86
  | --- | --- |
84
87
  | `devklean scan [PATH]` | Find cleanable directories and report sizes. Never deletes. |
85
88
  | `devklean clean [PATH]` | Scan, then delete (to trash) after confirmation. |
89
+ | `devklean analyze [PATH]` | Scan and report a signature-backed analysis: risk, staleness, structural issues, workspace health. |
90
+ | `devklean explain PATH` | Explain what a single directory is, using the artifact-signature registry. |
86
91
  | `devklean restore` | Explain how to recover deleted items from your system trash. |
87
92
  | `devklean history` | Show previous cleanup operations (timestamp, size, strategy, item count). |
88
93
  | `devklean doctor` | Inspect and repair the deletion metadata store. |
@@ -107,6 +112,7 @@ devklean clean --dry-run # show what *would* be deleted; delete nothing
107
112
  devklean clean -i # interactive: pick items in a TUI (Linux/macOS only)
108
113
  devklean clean --allow-symlinks # permit deleting symlinked targets (blocked by default)
109
114
  devklean clean -y # skip the y/N prompt (large deletions still require typing DELETE)
115
+ devklean clean --compress # compress eligible directories (gzip) before sending them to trash
110
116
  ```
111
117
 
112
118
  | Flag | Meaning |
@@ -115,6 +121,31 @@ devklean clean -y # skip the y/N prompt (large deletions still req
115
121
  | `-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
122
  | `--allow-symlinks` | Allow deleting symbolic links. Off by default (symlinks are blocked). |
117
123
  | `-y`, `--yes` | Skip the standard confirmation. Deletions over the size threshold still require typing `DELETE`. |
124
+ | `--compress` | Compress eligible directories into a sibling archive before trashing them, shrinking their footprint in trash. Off by default — see [Compression](#compression). |
125
+
126
+ ### `analyze`
127
+
128
+ ```bash
129
+ devklean analyze # analyze the current directory
130
+ devklean analyze ~/projects # analyze a specific path
131
+ devklean analyze --verbose # also print the workspace-health formula and its raw inputs
132
+ ```
133
+
134
+ Scans like `scan`/`clean`, then cross-references every cleanable directory against the artifact-signature registry (the same data `explain` uses) and buckets each into:
135
+
136
+ - **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).
137
+ - **Not recognized** — no registry entry, so no risk/confidence verdict is given.
138
+
139
+ 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.
140
+
141
+ ### `explain`
142
+
143
+ ```bash
144
+ devklean explain node_modules # explain a directory relative to the current path
145
+ devklean explain ~/code/app/.next # explain an absolute path
146
+ ```
147
+
148
+ 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
149
 
119
150
  ### `restore`
120
151
 
@@ -130,6 +161,12 @@ devklean restore # explains how to recover from the Recycle Bin / Trash
130
161
  - **macOS** — open Trash in Finder and "Put Back".
131
162
  - **Linux** — open Trash in your file manager and restore.
132
163
 
164
+ If the item was deleted with `--compress`, what lands in trash is a `.tar.gz`
165
+ (or `.tar.zst`, if `compress_format = "zstd"`) archive rather than the original
166
+ directory — restore the archive from trash, then extract it to the original
167
+ path yourself, e.g. `tar -xf <name>.tar.gz`. devklean does not decompress
168
+ automatically (yet).
169
+
133
170
  Run `devklean history` to see what was removed and when.
134
171
 
135
172
  ### `history`
@@ -174,7 +211,8 @@ Delete 3 directories (~834.0 MB)? (y/N) y
174
211
  ## Platform support
175
212
 
176
213
  `devklean` runs on **Linux, macOS, and Windows**. All core commands — `scan`,
177
- `clean`, `history`, `doctor`, and `restore` — work on every platform.
214
+ `clean`, `analyze`, `explain`, `history`, `doctor`, and `restore` — work on
215
+ every platform.
178
216
 
179
217
  **Known limitation:** interactive mode (`-i` / `--interactive`) is **Linux/macOS
180
218
  only** for now. It is built on Python's `curses` module, which is not available
@@ -200,6 +238,9 @@ exclude = ["node_modules", ".git"]
200
238
  dry_run = false
201
239
  interactive = false
202
240
  default_yes = false # skip the y/N prompt (the large-deletion DELETE gate still applies)
241
+ compress = false # compress eligible directories before trashing them
242
+ compress_min_size = 10485760 # bytes; directories smaller than this are trashed uncompressed (default 10 MiB)
243
+ compress_format = "gzip" # "gzip" (stdlib, default) or "zstd" (needs the devklean[zstd] extra)
203
244
  theme = "default" # "default" or "mono"
204
245
  confirm_threshold = 1073741824 # bytes; deletions >= this require typing DELETE (default 1 GiB)
205
246
  path = "."
@@ -218,6 +259,50 @@ Scalar keys from the project file override the global file; list keys (`exclude`
218
259
 
219
260
  Color follows the `theme` setting and is automatically disabled when output is piped or `NO_COLOR` is set.
220
261
 
262
+ ## Compression
263
+
264
+ Common artifacts (`node_modules`, `.venv`, `.next`, build caches) often compress
265
+ to a fraction of their on-disk size. Pass `--compress` (or set `compress = true`
266
+ in config) and devklean will archive each eligible directory into a sibling
267
+ `.tar.gz` (gzip, the default) before sending *that* to trash instead of the raw
268
+ directory — shrinking how much space the deletion actually occupies in trash
269
+ before it's emptied. `zstd` is available as an opt-in format (see below) for a
270
+ better compression ratio.
271
+
272
+ Compression is always ordered for safety: devklean compresses to a temp
273
+ archive, verifies it (test-extracts every entry and cross-checks the file
274
+ count and total uncompressed size against the source), and only *after*
275
+ `send2trash` confirms the archive is in the trash does it remove the original
276
+ directory. If compression or verification fails, or `send2trash` itself fails,
277
+ the original directory is left completely untouched and the error is reported
278
+ per-item — nothing is ever partially deleted.
279
+
280
+ - Only applies to directories (not symlinks) at or above `compress_min_size`
281
+ (default 10 MiB); smaller directories and files are trashed as-is, since the
282
+ archive/verify overhead rarely pays for itself below that size.
283
+ - The archive path, format, original size, and compressed size are recorded in
284
+ deletion metadata, so `history` and `doctor` see compressed deletions the
285
+ same as uncompressed ones.
286
+ - Off by default, so existing scripts and habits aren't surprised by archives
287
+ appearing in trash.
288
+ - Restoring a compressed item is manual today — see [`restore`](#restore).
289
+
290
+ ### zstd (optional)
291
+
292
+ ```bash
293
+ pip install 'devklean[zstd]'
294
+ ```
295
+
296
+ ```toml
297
+ [defaults]
298
+ compress = true
299
+ compress_format = "zstd"
300
+ ```
301
+
302
+ If `compress_format = "zstd"` is set but the `zstandard` package isn't
303
+ installed, devklean logs a warning and falls back to gzip rather than
304
+ crashing.
305
+
221
306
  ## Logs
222
307
 
223
308
  `devklean` writes detailed structured logs (commands, scanned/deleted paths, sizes, errors) to:
@@ -25,7 +25,7 @@ pipx install devklean
25
25
  pip install devklean
26
26
  ```
27
27
 
28
- Requires Python 3.8+. Runtime dependencies are `send2trash` (used for all deletions) and `tomli` (only on Python < 3.11).
28
+ 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
29
 
30
30
  ## Quick start
31
31
 
@@ -46,6 +46,8 @@ devklean clean --dry-run
46
46
  | --- | --- |
47
47
  | `devklean scan [PATH]` | Find cleanable directories and report sizes. Never deletes. |
48
48
  | `devklean clean [PATH]` | Scan, then delete (to trash) after confirmation. |
49
+ | `devklean analyze [PATH]` | Scan and report a signature-backed analysis: risk, staleness, structural issues, workspace health. |
50
+ | `devklean explain PATH` | Explain what a single directory is, using the artifact-signature registry. |
49
51
  | `devklean restore` | Explain how to recover deleted items from your system trash. |
50
52
  | `devklean history` | Show previous cleanup operations (timestamp, size, strategy, item count). |
51
53
  | `devklean doctor` | Inspect and repair the deletion metadata store. |
@@ -70,6 +72,7 @@ devklean clean --dry-run # show what *would* be deleted; delete nothing
70
72
  devklean clean -i # interactive: pick items in a TUI (Linux/macOS only)
71
73
  devklean clean --allow-symlinks # permit deleting symlinked targets (blocked by default)
72
74
  devklean clean -y # skip the y/N prompt (large deletions still require typing DELETE)
75
+ devklean clean --compress # compress eligible directories (gzip) before sending them to trash
73
76
  ```
74
77
 
75
78
  | Flag | Meaning |
@@ -78,6 +81,31 @@ devklean clean -y # skip the y/N prompt (large deletions still req
78
81
  | `-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
82
  | `--allow-symlinks` | Allow deleting symbolic links. Off by default (symlinks are blocked). |
80
83
  | `-y`, `--yes` | Skip the standard confirmation. Deletions over the size threshold still require typing `DELETE`. |
84
+ | `--compress` | Compress eligible directories into a sibling archive before trashing them, shrinking their footprint in trash. Off by default — see [Compression](#compression). |
85
+
86
+ ### `analyze`
87
+
88
+ ```bash
89
+ devklean analyze # analyze the current directory
90
+ devklean analyze ~/projects # analyze a specific path
91
+ devklean analyze --verbose # also print the workspace-health formula and its raw inputs
92
+ ```
93
+
94
+ Scans like `scan`/`clean`, then cross-references every cleanable directory against the artifact-signature registry (the same data `explain` uses) and buckets each into:
95
+
96
+ - **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).
97
+ - **Not recognized** — no registry entry, so no risk/confidence verdict is given.
98
+
99
+ 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.
100
+
101
+ ### `explain`
102
+
103
+ ```bash
104
+ devklean explain node_modules # explain a directory relative to the current path
105
+ devklean explain ~/code/app/.next # explain an absolute path
106
+ ```
107
+
108
+ 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
109
 
82
110
  ### `restore`
83
111
 
@@ -93,6 +121,12 @@ devklean restore # explains how to recover from the Recycle Bin / Trash
93
121
  - **macOS** — open Trash in Finder and "Put Back".
94
122
  - **Linux** — open Trash in your file manager and restore.
95
123
 
124
+ If the item was deleted with `--compress`, what lands in trash is a `.tar.gz`
125
+ (or `.tar.zst`, if `compress_format = "zstd"`) archive rather than the original
126
+ directory — restore the archive from trash, then extract it to the original
127
+ path yourself, e.g. `tar -xf <name>.tar.gz`. devklean does not decompress
128
+ automatically (yet).
129
+
96
130
  Run `devklean history` to see what was removed and when.
97
131
 
98
132
  ### `history`
@@ -137,7 +171,8 @@ Delete 3 directories (~834.0 MB)? (y/N) y
137
171
  ## Platform support
138
172
 
139
173
  `devklean` runs on **Linux, macOS, and Windows**. All core commands — `scan`,
140
- `clean`, `history`, `doctor`, and `restore` — work on every platform.
174
+ `clean`, `analyze`, `explain`, `history`, `doctor`, and `restore` — work on
175
+ every platform.
141
176
 
142
177
  **Known limitation:** interactive mode (`-i` / `--interactive`) is **Linux/macOS
143
178
  only** for now. It is built on Python's `curses` module, which is not available
@@ -163,6 +198,9 @@ exclude = ["node_modules", ".git"]
163
198
  dry_run = false
164
199
  interactive = false
165
200
  default_yes = false # skip the y/N prompt (the large-deletion DELETE gate still applies)
201
+ compress = false # compress eligible directories before trashing them
202
+ compress_min_size = 10485760 # bytes; directories smaller than this are trashed uncompressed (default 10 MiB)
203
+ compress_format = "gzip" # "gzip" (stdlib, default) or "zstd" (needs the devklean[zstd] extra)
166
204
  theme = "default" # "default" or "mono"
167
205
  confirm_threshold = 1073741824 # bytes; deletions >= this require typing DELETE (default 1 GiB)
168
206
  path = "."
@@ -181,6 +219,50 @@ Scalar keys from the project file override the global file; list keys (`exclude`
181
219
 
182
220
  Color follows the `theme` setting and is automatically disabled when output is piped or `NO_COLOR` is set.
183
221
 
222
+ ## Compression
223
+
224
+ Common artifacts (`node_modules`, `.venv`, `.next`, build caches) often compress
225
+ to a fraction of their on-disk size. Pass `--compress` (or set `compress = true`
226
+ in config) and devklean will archive each eligible directory into a sibling
227
+ `.tar.gz` (gzip, the default) before sending *that* to trash instead of the raw
228
+ directory — shrinking how much space the deletion actually occupies in trash
229
+ before it's emptied. `zstd` is available as an opt-in format (see below) for a
230
+ better compression ratio.
231
+
232
+ Compression is always ordered for safety: devklean compresses to a temp
233
+ archive, verifies it (test-extracts every entry and cross-checks the file
234
+ count and total uncompressed size against the source), and only *after*
235
+ `send2trash` confirms the archive is in the trash does it remove the original
236
+ directory. If compression or verification fails, or `send2trash` itself fails,
237
+ the original directory is left completely untouched and the error is reported
238
+ per-item — nothing is ever partially deleted.
239
+
240
+ - Only applies to directories (not symlinks) at or above `compress_min_size`
241
+ (default 10 MiB); smaller directories and files are trashed as-is, since the
242
+ archive/verify overhead rarely pays for itself below that size.
243
+ - The archive path, format, original size, and compressed size are recorded in
244
+ deletion metadata, so `history` and `doctor` see compressed deletions the
245
+ same as uncompressed ones.
246
+ - Off by default, so existing scripts and habits aren't surprised by archives
247
+ appearing in trash.
248
+ - Restoring a compressed item is manual today — see [`restore`](#restore).
249
+
250
+ ### zstd (optional)
251
+
252
+ ```bash
253
+ pip install 'devklean[zstd]'
254
+ ```
255
+
256
+ ```toml
257
+ [defaults]
258
+ compress = true
259
+ compress_format = "zstd"
260
+ ```
261
+
262
+ If `compress_format = "zstd"` is set but the `zstandard` package isn't
263
+ installed, devklean logs a warning and falls back to gzip rather than
264
+ crashing.
265
+
184
266
  ## Logs
185
267
 
186
268
  `devklean` writes detailed structured logs (commands, scanned/deleted paths, sizes, errors) to:
@@ -36,12 +36,16 @@ dependencies = [
36
36
  ]
37
37
 
38
38
  [project.optional-dependencies]
39
+ zstd = [
40
+ "zstandard>=0.21",
41
+ ]
39
42
  dev = [
40
43
  "pytest>=7.0",
41
44
  "pytest-cov>=4.0",
42
45
  "ruff>=0.6",
43
46
  "mypy>=1.8",
44
47
  "build>=1.0",
48
+ "zstandard>=0.21",
45
49
  ]
46
50
 
47
51
  [project.scripts]
@@ -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.1.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
 
@@ -5,9 +5,22 @@ import argparse
5
5
  from devklean._version import __version__
6
6
 
7
7
  COMMAND_NAMES = frozenset(
8
- {"scan", "clean", "history", "doctor", "stats", "restore", "config", "plugins"}
8
+ {
9
+ "scan",
10
+ "clean",
11
+ "history",
12
+ "doctor",
13
+ "stats",
14
+ "restore",
15
+ "explain",
16
+ "analyze",
17
+ "config",
18
+ "plugins",
19
+ }
20
+ )
21
+ IMPLEMENTED_COMMANDS = frozenset(
22
+ {"scan", "clean", "history", "doctor", "restore", "explain", "analyze"}
9
23
  )
10
- IMPLEMENTED_COMMANDS = frozenset({"scan", "clean", "history", "doctor", "restore"})
11
24
  RESERVED_COMMANDS = frozenset({"stats", "config", "plugins"})
12
25
  GLOBAL_OPTIONS = frozenset({"-h", "--help", "--version"})
13
26
 
@@ -36,6 +49,12 @@ def _add_clean_arguments(parser: argparse.ArgumentParser) -> None:
36
49
  action="store_true",
37
50
  help="Show what would be deleted without deleting anything",
38
51
  )
52
+ parser.add_argument(
53
+ "--compress",
54
+ action="store_true",
55
+ help="Compress eligible directories into a .tar.gz (or .tar.zst) archive "
56
+ "before trashing them",
57
+ )
39
58
  parser.add_argument(
40
59
  "-i",
41
60
  "--interactive",
@@ -79,6 +98,26 @@ def _add_subparsers(parser: argparse.ArgumentParser) -> None:
79
98
  "restore", help="Show how to recover deleted items from your system trash"
80
99
  )
81
100
 
101
+ explain_parser = subparsers.add_parser(
102
+ "explain",
103
+ help="Explain what a directory is, using the artifact-signature registry",
104
+ )
105
+ explain_parser.add_argument(
106
+ "path",
107
+ help="Path to a directory to look up in the signature registry",
108
+ )
109
+
110
+ analyze_parser = subparsers.add_parser(
111
+ "analyze",
112
+ help="Analyze cleanable directories using the artifact-signature registry",
113
+ )
114
+ _add_path_argument(analyze_parser)
115
+ analyze_parser.add_argument(
116
+ "--verbose",
117
+ action="store_true",
118
+ help="Show the workspace-health formula and its raw inputs",
119
+ )
120
+
82
121
  history_parser = subparsers.add_parser(
83
122
  "history",
84
123
  help="Show previous cleanup operations",
@@ -20,6 +20,9 @@ _KNOWN_TOP_LEVEL = {"defaults", "targets", "ignore", "exclude"}
20
20
  _KNOWN_DEFAULTS = {
21
21
  "dry_run",
22
22
  "interactive",
23
+ "compress",
24
+ "compress_min_size",
25
+ "compress_format",
23
26
  "path",
24
27
  "default_yes",
25
28
  "theme",
@@ -83,6 +86,8 @@ class ConfigManager:
83
86
  args.dry_run = config.defaults.dry_run
84
87
  if "-i" not in raw_argv and "--interactive" not in raw_argv:
85
88
  args.interactive = config.defaults.interactive
89
+ if "--compress" not in raw_argv:
90
+ args.compress = config.defaults.compress
86
91
 
87
92
  if getattr(args, "path", None) == "." and not _explicit_path_provided(raw_argv):
88
93
  args.path = os.path.expanduser(config.defaults.path)
@@ -149,6 +154,9 @@ class ConfigManager:
149
154
  merged: dict[str, Any] = {
150
155
  "dry_run": base.dry_run,
151
156
  "interactive": base.interactive,
157
+ "compress": base.compress,
158
+ "compress_min_size": base.compress_min_size,
159
+ "compress_format": base.compress_format,
152
160
  "path": base.path,
153
161
  "default_yes": base.default_yes,
154
162
  "theme": base.theme,
@@ -161,6 +169,15 @@ class ConfigManager:
161
169
  for key in ("dry_run", "interactive", "default_yes"):
162
170
  if key in section:
163
171
  merged[key] = bool(section[key])
172
+ if "compress" in section:
173
+ merged["compress"] = bool(section["compress"])
174
+ if "compress_min_size" in section:
175
+ try:
176
+ merged["compress_min_size"] = int(section["compress_min_size"])
177
+ except (TypeError, ValueError):
178
+ pass
179
+ if "compress_format" in section:
180
+ merged["compress_format"] = str(section["compress_format"])
164
181
  if "path" in section:
165
182
  merged["path"] = str(section["path"])
166
183
  if "theme" in section:
@@ -211,6 +228,8 @@ def _explicit_path_provided(argv: list[str]) -> bool:
211
228
  "doctor",
212
229
  "stats",
213
230
  "restore",
231
+ "explain",
232
+ "analyze",
214
233
  "config",
215
234
  "plugins",
216
235
  }