devklean 1.0.1__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 (102) hide show
  1. {devklean-1.0.1 → devklean-1.1.0}/CHANGELOG.md +45 -1
  2. {devklean-1.0.1 → devklean-1.1.0}/PKG-INFO +91 -3
  3. {devklean-1.0.1 → devklean-1.1.0}/README.md +86 -2
  4. {devklean-1.0.1 → devklean-1.1.0}/pyproject.toml +5 -0
  5. {devklean-1.0.1 → devklean-1.1.0}/src/devklean/__main__.py +1 -1
  6. {devklean-1.0.1 → devklean-1.1.0}/src/devklean/_version.py +1 -1
  7. devklean-1.1.0/src/devklean/cli/__init__.py +11 -0
  8. devklean-1.1.0/src/devklean/cli/commands/__init__.py +13 -0
  9. devklean-1.1.0/src/devklean/cli/commands/analyze.py +34 -0
  10. {devklean-1.0.1 → devklean-1.1.0}/src/devklean/cli/commands/clean.py +31 -3
  11. {devklean-1.0.1 → devklean-1.1.0}/src/devklean/cli/commands/common.py +17 -3
  12. devklean-1.1.0/src/devklean/cli/commands/explain.py +35 -0
  13. {devklean-1.0.1 → devklean-1.1.0}/src/devklean/cli/dispatcher.py +4 -0
  14. {devklean-1.0.1 → devklean-1.1.0}/src/devklean/cli/main.py +3 -1
  15. {devklean-1.0.1 → devklean-1.1.0}/src/devklean/cli/parser.py +41 -2
  16. {devklean-1.0.1 → devklean-1.1.0}/src/devklean/config/manager.py +19 -0
  17. {devklean-1.0.1 → devklean-1.1.0}/src/devklean/config/models.py +14 -0
  18. devklean-1.1.0/src/devklean/deletion/__init__.py +31 -0
  19. devklean-1.1.0/src/devklean/deletion/compression.py +248 -0
  20. {devklean-1.0.1 → devklean-1.1.0}/src/devklean/deletion/metadata.py +71 -3
  21. devklean-1.1.0/src/devklean/deletion/trash.py +188 -0
  22. devklean-1.1.0/src/devklean/output/__init__.py +15 -0
  23. {devklean-1.0.1 → devklean-1.1.0}/src/devklean/output/console.py +5 -3
  24. {devklean-1.0.1 → devklean-1.1.0}/src/devklean/output/text.py +94 -1
  25. devklean-1.1.0/src/devklean/signatures/__init__.py +31 -0
  26. devklean-1.1.0/src/devklean/signatures/analysis.py +99 -0
  27. devklean-1.1.0/src/devklean/signatures/health.py +56 -0
  28. devklean-1.1.0/src/devklean/signatures/registry.py +206 -0
  29. devklean-1.1.0/src/devklean/signatures/staleness.py +126 -0
  30. devklean-1.1.0/src/devklean/signatures/structural.py +38 -0
  31. {devklean-1.0.1 → devklean-1.1.0}/src/devklean/tui.py +19 -2
  32. devklean-1.1.0/tests/test_analyze_command.py +146 -0
  33. {devklean-1.0.1 → devklean-1.1.0}/tests/test_cli_parser.py +8 -1
  34. devklean-1.1.0/tests/test_compression.py +188 -0
  35. {devklean-1.0.1 → devklean-1.1.0}/tests/test_config.py +15 -1
  36. {devklean-1.0.1 → devklean-1.1.0}/tests/test_config_precedence.py +3 -0
  37. devklean-1.1.0/tests/test_deletion.py +444 -0
  38. {devklean-1.0.1 → devklean-1.1.0}/tests/test_doctor.py +33 -1
  39. devklean-1.1.0/tests/test_explain_command.py +100 -0
  40. {devklean-1.0.1 → devklean-1.1.0}/tests/test_history.py +2 -2
  41. {devklean-1.0.1 → devklean-1.1.0}/tests/test_integrity.py +30 -2
  42. {devklean-1.0.1 → devklean-1.1.0}/tests/test_restore.py +1 -0
  43. devklean-1.1.0/tests/test_signatures_health.py +89 -0
  44. devklean-1.1.0/tests/test_signatures_registry.py +86 -0
  45. devklean-1.1.0/tests/test_signatures_staleness.py +102 -0
  46. devklean-1.1.0/tests/test_signatures_structural.py +39 -0
  47. {devklean-1.0.1 → devklean-1.1.0}/tests/test_windows_guard.py +3 -0
  48. devklean-1.0.1/src/devklean/cli/__init__.py +0 -3
  49. devklean-1.0.1/src/devklean/cli/commands/__init__.py +0 -4
  50. devklean-1.0.1/src/devklean/deletion/__init__.py +0 -17
  51. devklean-1.0.1/src/devklean/deletion/trash.py +0 -89
  52. devklean-1.0.1/src/devklean/output/__init__.py +0 -5
  53. devklean-1.0.1/tests/test_deletion.py +0 -242
  54. {devklean-1.0.1 → devklean-1.1.0}/.gitignore +0 -0
  55. {devklean-1.0.1 → devklean-1.1.0}/LICENSE +0 -0
  56. {devklean-1.0.1 → devklean-1.1.0}/src/devklean/__init__.py +0 -0
  57. {devklean-1.0.1 → devklean-1.1.0}/src/devklean/cli/commands/doctor.py +0 -0
  58. {devklean-1.0.1 → devklean-1.1.0}/src/devklean/cli/commands/history.py +0 -0
  59. {devklean-1.0.1 → devklean-1.1.0}/src/devklean/cli/commands/restore.py +0 -0
  60. {devklean-1.0.1 → devklean-1.1.0}/src/devklean/cli/commands/scan.py +0 -0
  61. {devklean-1.0.1 → devklean-1.1.0}/src/devklean/cli/confirmation.py +0 -0
  62. {devklean-1.0.1 → devklean-1.1.0}/src/devklean/config/__init__.py +0 -0
  63. {devklean-1.0.1 → devklean-1.1.0}/src/devklean/config/defaults.py +0 -0
  64. {devklean-1.0.1 → devklean-1.1.0}/src/devklean/config/paths.py +0 -0
  65. {devklean-1.0.1 → devklean-1.1.0}/src/devklean/config/targets.py +0 -0
  66. {devklean-1.0.1 → devklean-1.1.0}/src/devklean/deletion/history.py +0 -0
  67. {devklean-1.0.1 → devklean-1.1.0}/src/devklean/deletion/integrity.py +0 -0
  68. {devklean-1.0.1 → devklean-1.1.0}/src/devklean/deletion/paths.py +0 -0
  69. {devklean-1.0.1 → devklean-1.1.0}/src/devklean/deletion/safety.py +0 -0
  70. {devklean-1.0.1 → devklean-1.1.0}/src/devklean/formatting.py +0 -0
  71. {devklean-1.0.1 → devklean-1.1.0}/src/devklean/logging_setup.py +0 -0
  72. {devklean-1.0.1 → devklean-1.1.0}/src/devklean/models.py +0 -0
  73. {devklean-1.0.1 → devklean-1.1.0}/src/devklean/output/base.py +0 -0
  74. {devklean-1.0.1 → devklean-1.1.0}/src/devklean/output/history_payload.py +0 -0
  75. {devklean-1.0.1 → devklean-1.1.0}/src/devklean/output/json.py +0 -0
  76. {devklean-1.0.1 → devklean-1.1.0}/src/devklean/output/scan_payload.py +0 -0
  77. {devklean-1.0.1 → devklean-1.1.0}/src/devklean/output/sorting.py +0 -0
  78. {devklean-1.0.1 → devklean-1.1.0}/src/devklean/output/theme.py +0 -0
  79. {devklean-1.0.1 → devklean-1.1.0}/src/devklean/scanner/__init__.py +0 -0
  80. {devklean-1.0.1 → devklean-1.1.0}/src/devklean/scanner/filters.py +0 -0
  81. {devklean-1.0.1 → devklean-1.1.0}/src/devklean/scanner/scanner.py +0 -0
  82. {devklean-1.0.1 → devklean-1.1.0}/tests/benchmark_scanner.py +0 -0
  83. {devklean-1.0.1 → devklean-1.1.0}/tests/conftest.py +0 -0
  84. {devklean-1.0.1 → devklean-1.1.0}/tests/test_clean_flow.py +0 -0
  85. {devklean-1.0.1 → devklean-1.1.0}/tests/test_confirmation.py +0 -0
  86. {devklean-1.0.1 → devklean-1.1.0}/tests/test_console.py +0 -0
  87. {devklean-1.0.1 → devklean-1.1.0}/tests/test_dry_run.py +0 -0
  88. {devklean-1.0.1 → devklean-1.1.0}/tests/test_formatting.py +0 -0
  89. {devklean-1.0.1 → devklean-1.1.0}/tests/test_integration.py +0 -0
  90. {devklean-1.0.1 → devklean-1.1.0}/tests/test_json_output.py +0 -0
  91. {devklean-1.0.1 → devklean-1.1.0}/tests/test_logging.py +0 -0
  92. {devklean-1.0.1 → devklean-1.1.0}/tests/test_main_signal.py +0 -0
  93. {devklean-1.0.1 → devklean-1.1.0}/tests/test_models.py +0 -0
  94. {devklean-1.0.1 → devklean-1.1.0}/tests/test_output_sorting.py +0 -0
  95. {devklean-1.0.1 → devklean-1.1.0}/tests/test_packaging.py +0 -0
  96. {devklean-1.0.1 → devklean-1.1.0}/tests/test_perf_scan.py +0 -0
  97. {devklean-1.0.1 → devklean-1.1.0}/tests/test_safety.py +0 -0
  98. {devklean-1.0.1 → devklean-1.1.0}/tests/test_scan_json_cli.py +0 -0
  99. {devklean-1.0.1 → devklean-1.1.0}/tests/test_scan_permissions.py +0 -0
  100. {devklean-1.0.1 → devklean-1.1.0}/tests/test_scan_settings.py +0 -0
  101. {devklean-1.0.1 → devklean-1.1.0}/tests/test_scanner.py +0 -0
  102. {devklean-1.0.1 → devklean-1.1.0}/tests/test_text_renderer.py +0 -0
@@ -7,6 +7,49 @@ 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
+
40
+ ## [1.0.2] - 2026-07-01
41
+
42
+ ### Changed
43
+
44
+ - Replaced `print()` calls in the console layer with `click.echo()` for improved
45
+ Unicode and Windows terminal compatibility.
46
+ - Fixed `src/devklean/__main__.py` to correctly import `main` from
47
+ `devklean.cli.main`.
48
+ - Made package `__init__.py` imports lazy to avoid pulling in `send2trash`
49
+ during unrelated imports.
50
+ - Added `click` as a runtime dependency.
51
+ - Updated Windows guard test to work in subprocesses with `PYTHONPATH=src`.
52
+
10
53
  ## [1.0.1] - 2026-06-30
11
54
 
12
55
  ### Fixed
@@ -91,7 +134,8 @@ First public pre-release.
91
134
  per-target sizing.
92
135
  - **Packaging** — distributable via `pip`/`pipx`; MIT licensed.
93
136
 
94
- [Unreleased]: https://github.com/smurftyy/devklean/compare/v1.0.1...HEAD
137
+ [Unreleased]: https://github.com/smurftyy/devklean/compare/v1.0.2...HEAD
138
+ [1.0.2]: https://github.com/smurftyy/devklean/compare/v1.0.1...v1.0.2
95
139
  [1.0.1]: https://github.com/smurftyy/devklean/compare/v1.0.0...v1.0.1
96
140
  [1.0.0]: https://github.com/smurftyy/devklean/compare/v0.1.0...v1.0.0
97
141
  [0.1.0]: https://github.com/smurftyy/devklean/releases/tag/v0.1.0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: devklean
3
- Version: 1.0.1
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
@@ -24,6 +24,7 @@ Classifier: Programming Language :: Python :: 3.12
24
24
  Classifier: Topic :: System :: Filesystems
25
25
  Classifier: Topic :: Utilities
26
26
  Requires-Python: >=3.8
27
+ Requires-Dist: click>=8.1.0
27
28
  Requires-Dist: send2trash>=1.8.2
28
29
  Requires-Dist: tomli>=2.0.0; python_version < '3.11'
29
30
  Provides-Extra: dev
@@ -32,6 +33,9 @@ Requires-Dist: mypy>=1.8; extra == 'dev'
32
33
  Requires-Dist: pytest-cov>=4.0; extra == 'dev'
33
34
  Requires-Dist: pytest>=7.0; extra == 'dev'
34
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'
35
39
  Description-Content-Type: text/markdown
36
40
 
37
41
  # devklean
@@ -43,6 +47,8 @@ Description-Content-Type: text/markdown
43
47
 
44
48
  **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.
45
49
 
50
+ ![devklean in action](docs/assets/devklean.png)
51
+
46
52
  <!-- TODO: insert terminal recording GIF of `devklean clean` here -->
47
53
 
48
54
  ## Why
@@ -59,7 +65,7 @@ pipx install devklean
59
65
  pip install devklean
60
66
  ```
61
67
 
62
- 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).
63
69
 
64
70
  ## Quick start
65
71
 
@@ -80,6 +86,8 @@ devklean clean --dry-run
80
86
  | --- | --- |
81
87
  | `devklean scan [PATH]` | Find cleanable directories and report sizes. Never deletes. |
82
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. |
83
91
  | `devklean restore` | Explain how to recover deleted items from your system trash. |
84
92
  | `devklean history` | Show previous cleanup operations (timestamp, size, strategy, item count). |
85
93
  | `devklean doctor` | Inspect and repair the deletion metadata store. |
@@ -104,6 +112,7 @@ devklean clean --dry-run # show what *would* be deleted; delete nothing
104
112
  devklean clean -i # interactive: pick items in a TUI (Linux/macOS only)
105
113
  devklean clean --allow-symlinks # permit deleting symlinked targets (blocked by default)
106
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
107
116
  ```
108
117
 
109
118
  | Flag | Meaning |
@@ -112,6 +121,31 @@ devklean clean -y # skip the y/N prompt (large deletions still req
112
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). |
113
122
  | `--allow-symlinks` | Allow deleting symbolic links. Off by default (symlinks are blocked). |
114
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.
115
149
 
116
150
  ### `restore`
117
151
 
@@ -127,6 +161,12 @@ devklean restore # explains how to recover from the Recycle Bin / Trash
127
161
  - **macOS** — open Trash in Finder and "Put Back".
128
162
  - **Linux** — open Trash in your file manager and restore.
129
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
+
130
170
  Run `devklean history` to see what was removed and when.
131
171
 
132
172
  ### `history`
@@ -171,7 +211,8 @@ Delete 3 directories (~834.0 MB)? (y/N) y
171
211
  ## Platform support
172
212
 
173
213
  `devklean` runs on **Linux, macOS, and Windows**. All core commands — `scan`,
174
- `clean`, `history`, `doctor`, and `restore` — work on every platform.
214
+ `clean`, `analyze`, `explain`, `history`, `doctor`, and `restore` — work on
215
+ every platform.
175
216
 
176
217
  **Known limitation:** interactive mode (`-i` / `--interactive`) is **Linux/macOS
177
218
  only** for now. It is built on Python's `curses` module, which is not available
@@ -197,6 +238,9 @@ exclude = ["node_modules", ".git"]
197
238
  dry_run = false
198
239
  interactive = false
199
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)
200
244
  theme = "default" # "default" or "mono"
201
245
  confirm_threshold = 1073741824 # bytes; deletions >= this require typing DELETE (default 1 GiB)
202
246
  path = "."
@@ -215,6 +259,50 @@ Scalar keys from the project file override the global file; list keys (`exclude`
215
259
 
216
260
  Color follows the `theme` setting and is automatically disabled when output is piped or `NO_COLOR` is set.
217
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
+
218
306
  ## Logs
219
307
 
220
308
  `devklean` writes detailed structured logs (commands, scanned/deleted paths, sizes, errors) to:
@@ -7,6 +7,8 @@
7
7
 
8
8
  **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
9
 
10
+ ![devklean in action](docs/assets/devklean.png)
11
+
10
12
  <!-- TODO: insert terminal recording GIF of `devklean clean` here -->
11
13
 
12
14
  ## Why
@@ -23,7 +25,7 @@ pipx install devklean
23
25
  pip install devklean
24
26
  ```
25
27
 
26
- 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).
27
29
 
28
30
  ## Quick start
29
31
 
@@ -44,6 +46,8 @@ devklean clean --dry-run
44
46
  | --- | --- |
45
47
  | `devklean scan [PATH]` | Find cleanable directories and report sizes. Never deletes. |
46
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. |
47
51
  | `devklean restore` | Explain how to recover deleted items from your system trash. |
48
52
  | `devklean history` | Show previous cleanup operations (timestamp, size, strategy, item count). |
49
53
  | `devklean doctor` | Inspect and repair the deletion metadata store. |
@@ -68,6 +72,7 @@ devklean clean --dry-run # show what *would* be deleted; delete nothing
68
72
  devklean clean -i # interactive: pick items in a TUI (Linux/macOS only)
69
73
  devklean clean --allow-symlinks # permit deleting symlinked targets (blocked by default)
70
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
71
76
  ```
72
77
 
73
78
  | Flag | Meaning |
@@ -76,6 +81,31 @@ devklean clean -y # skip the y/N prompt (large deletions still req
76
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). |
77
82
  | `--allow-symlinks` | Allow deleting symbolic links. Off by default (symlinks are blocked). |
78
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.
79
109
 
80
110
  ### `restore`
81
111
 
@@ -91,6 +121,12 @@ devklean restore # explains how to recover from the Recycle Bin / Trash
91
121
  - **macOS** — open Trash in Finder and "Put Back".
92
122
  - **Linux** — open Trash in your file manager and restore.
93
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
+
94
130
  Run `devklean history` to see what was removed and when.
95
131
 
96
132
  ### `history`
@@ -135,7 +171,8 @@ Delete 3 directories (~834.0 MB)? (y/N) y
135
171
  ## Platform support
136
172
 
137
173
  `devklean` runs on **Linux, macOS, and Windows**. All core commands — `scan`,
138
- `clean`, `history`, `doctor`, and `restore` — work on every platform.
174
+ `clean`, `analyze`, `explain`, `history`, `doctor`, and `restore` — work on
175
+ every platform.
139
176
 
140
177
  **Known limitation:** interactive mode (`-i` / `--interactive`) is **Linux/macOS
141
178
  only** for now. It is built on Python's `curses` module, which is not available
@@ -161,6 +198,9 @@ exclude = ["node_modules", ".git"]
161
198
  dry_run = false
162
199
  interactive = false
163
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)
164
204
  theme = "default" # "default" or "mono"
165
205
  confirm_threshold = 1073741824 # bytes; deletions >= this require typing DELETE (default 1 GiB)
166
206
  path = "."
@@ -179,6 +219,50 @@ Scalar keys from the project file override the global file; list keys (`exclude`
179
219
 
180
220
  Color follows the `theme` setting and is automatically disabled when output is piped or `NO_COLOR` is set.
181
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
+
182
266
  ## Logs
183
267
 
184
268
  `devklean` writes detailed structured logs (commands, scanned/deleted paths, sizes, errors) to:
@@ -31,16 +31,21 @@ classifiers = [
31
31
  ]
32
32
  dependencies = [
33
33
  "tomli>=2.0.0; python_version < '3.11'",
34
+ "click>=8.1.0",
34
35
  "send2trash>=1.8.2",
35
36
  ]
36
37
 
37
38
  [project.optional-dependencies]
39
+ zstd = [
40
+ "zstandard>=0.21",
41
+ ]
38
42
  dev = [
39
43
  "pytest>=7.0",
40
44
  "pytest-cov>=4.0",
41
45
  "ruff>=0.6",
42
46
  "mypy>=1.8",
43
47
  "build>=1.0",
48
+ "zstandard>=0.21",
44
49
  ]
45
50
 
46
51
  [project.scripts]
@@ -1,4 +1,4 @@
1
- from devklean.cli import main
1
+ from devklean.cli.main import main
2
2
 
3
3
  if __name__ == "__main__":
4
4
  main()
@@ -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.1"
8
+ __version__ = "1.1.0"
@@ -0,0 +1,11 @@
1
+ from __future__ import annotations
2
+
3
+ from importlib import import_module
4
+
5
+ __all__ = ["main"]
6
+
7
+
8
+ def __getattr__(name: str):
9
+ if name == "main":
10
+ return import_module("devklean.cli.main").main
11
+ raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
@@ -0,0 +1,13 @@
1
+ from __future__ import annotations
2
+
3
+ from importlib import import_module
4
+
5
+ __all__ = ["run_clean", "run_scan"]
6
+
7
+
8
+ def __getattr__(name: str):
9
+ if name == "run_clean":
10
+ return import_module("devklean.cli.commands.clean").run_clean
11
+ if name == "run_scan":
12
+ return import_module("devklean.cli.commands.scan").run_scan
13
+ raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
@@ -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,12 +8,18 @@ from devklean.cli.confirmation import (
8
8
  confirm_large_deletion,
9
9
  exceeds_threshold,
10
10
  )
11
- from devklean.config.models import AppConfig
12
- from devklean.deletion import SafetyValidator, delete_items
11
+ from devklean.config.models import DEFAULT_COMPRESS_FORMAT, DEFAULT_COMPRESS_MIN_SIZE, AppConfig
12
+ from devklean.deletion.safety import SafetyValidator
13
13
  from devklean.models import CleanableItem
14
14
  from devklean.output.base import Renderer
15
15
 
16
16
 
17
+ def delete_items(*args, **kwargs):
18
+ from devklean.deletion import delete_items as _delete_items
19
+
20
+ return _delete_items(*args, **kwargs)
21
+
22
+
17
23
  def _confirm_deletion(
18
24
  renderer: Renderer,
19
25
  count: int,
@@ -39,6 +45,9 @@ def run_standard(
39
45
  dry_run: bool,
40
46
  validator: SafetyValidator | None = None,
41
47
  *,
48
+ compress: bool = False,
49
+ compress_min_size: int = DEFAULT_COMPRESS_MIN_SIZE,
50
+ compress_format: str = DEFAULT_COMPRESS_FORMAT,
42
51
  default_yes: bool = False,
43
52
  confirm_threshold: int = DEFAULT_LARGE_THRESHOLD,
44
53
  ) -> None:
@@ -52,7 +61,14 @@ def run_standard(
52
61
  renderer.aborted()
53
62
  return
54
63
 
55
- 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
+ )
56
72
  renderer.deletion_result(result)
57
73
 
58
74
 
@@ -70,6 +86,12 @@ def run_clean(
70
86
  defaults = config.defaults
71
87
  default_yes = getattr(args, "yes", False) or getattr(defaults, "default_yes", False)
72
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)
73
95
 
74
96
  if args.interactive:
75
97
  # Interactive mode relies on curses, which is unavailable on Windows.
@@ -91,6 +113,9 @@ def run_clean(
91
113
  found,
92
114
  args.dry_run,
93
115
  validator,
116
+ compress=compress,
117
+ compress_min_size=compress_min_size,
118
+ compress_format=compress_format,
94
119
  confirm_threshold=confirm_threshold,
95
120
  )
96
121
  else:
@@ -99,6 +124,9 @@ def run_clean(
99
124
  found,
100
125
  args.dry_run,
101
126
  validator,
127
+ compress=compress,
128
+ compress_min_size=compress_min_size,
129
+ compress_format=compress_format,
102
130
  default_yes=default_yes,
103
131
  confirm_threshold=confirm_threshold,
104
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
 
@@ -2,6 +2,8 @@ from __future__ import annotations
2
2
 
3
3
  import sys
4
4
 
5
+ import click
6
+
5
7
  from devklean.cli.dispatcher import dispatch
6
8
  from devklean.cli.parser import build_parser, resolve_bare_invocation
7
9
  from devklean.config import ConfigManager
@@ -62,5 +64,5 @@ def main() -> None:
62
64
  sys.exit(exit_code)
63
65
  except KeyboardInterrupt:
64
66
  # 130 is the Unix convention for a SIGINT-terminated process (128 + 2).
65
- print("\nAborted.", file=sys.stderr)
67
+ click.echo("\nAborted.", file=sys.stderr)
66
68
  sys.exit(130)