@tukuyomil032/broom 1.0.0

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 (51) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +554 -0
  3. package/dist/commands/analyze.js +371 -0
  4. package/dist/commands/backup.js +257 -0
  5. package/dist/commands/clean.js +255 -0
  6. package/dist/commands/completion.js +714 -0
  7. package/dist/commands/config.js +474 -0
  8. package/dist/commands/doctor.js +280 -0
  9. package/dist/commands/duplicates.js +325 -0
  10. package/dist/commands/help.js +34 -0
  11. package/dist/commands/index.js +22 -0
  12. package/dist/commands/installer.js +266 -0
  13. package/dist/commands/optimize.js +270 -0
  14. package/dist/commands/purge.js +271 -0
  15. package/dist/commands/remove.js +184 -0
  16. package/dist/commands/reports.js +173 -0
  17. package/dist/commands/schedule.js +249 -0
  18. package/dist/commands/status.js +468 -0
  19. package/dist/commands/touchid.js +230 -0
  20. package/dist/commands/uninstall.js +336 -0
  21. package/dist/commands/update.js +182 -0
  22. package/dist/commands/watch.js +258 -0
  23. package/dist/index.js +131 -0
  24. package/dist/scanners/base.js +21 -0
  25. package/dist/scanners/browser-cache.js +111 -0
  26. package/dist/scanners/dev-cache.js +64 -0
  27. package/dist/scanners/docker.js +96 -0
  28. package/dist/scanners/downloads.js +66 -0
  29. package/dist/scanners/homebrew.js +82 -0
  30. package/dist/scanners/index.js +126 -0
  31. package/dist/scanners/installer.js +87 -0
  32. package/dist/scanners/ios-backups.js +82 -0
  33. package/dist/scanners/node-modules.js +75 -0
  34. package/dist/scanners/temp-files.js +65 -0
  35. package/dist/scanners/trash.js +90 -0
  36. package/dist/scanners/user-cache.js +62 -0
  37. package/dist/scanners/user-logs.js +53 -0
  38. package/dist/scanners/xcode.js +124 -0
  39. package/dist/types/index.js +23 -0
  40. package/dist/ui/index.js +5 -0
  41. package/dist/ui/monitors.js +345 -0
  42. package/dist/ui/output.js +304 -0
  43. package/dist/ui/prompts.js +270 -0
  44. package/dist/utils/config.js +133 -0
  45. package/dist/utils/debug.js +119 -0
  46. package/dist/utils/fs.js +283 -0
  47. package/dist/utils/help.js +265 -0
  48. package/dist/utils/index.js +6 -0
  49. package/dist/utils/paths.js +142 -0
  50. package/dist/utils/report.js +404 -0
  51. package/package.json +87 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026, tukuyomil032 All Rights Reserved.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,554 @@
1
+ # ๐Ÿงน Broom
2
+
3
+ A powerful macOS disk cleanup CLI written in TypeScript. Inspired by [Mole](https://github.com/tw93/Mole).
4
+
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
6
+ [![TypeScript](https://img.shields.io/badge/TypeScript-5.0-blue)](https://www.typescriptlang.org/)
7
+ [![Node.js](https://img.shields.io/badge/Node.js-18+-green)](https://nodejs.org/)
8
+
9
+ ## ๐Ÿ“‹ Table of Contents
10
+
11
+ - [Features](#features)
12
+ - [Installation](#installation)
13
+ - [Quick Start](#quick-start)
14
+ - [Commands](#commands)
15
+ - [Usage Examples](#usage-examples)
16
+ - [Cleanup Categories](#cleanup-categories)
17
+ - [Configuration](#configuration)
18
+ - [Documentation](#documentation)
19
+ - [Tech Stack](#tech-stack)
20
+ - [License](#license)
21
+
22
+ ## โœจ Features
23
+
24
+ - **๐Ÿงน Deep Cleaning** - Remove caches, logs, trash, browser data, and dev artifacts
25
+ - **๐Ÿ—‘๏ธ Smart Uninstall** - Completely remove apps and their leftover files
26
+ - **โšก System Optimization** - Flush DNS, rebuild Spotlight, purge memory
27
+ - **๐Ÿ“Š Disk Analysis** - Visualize disk usage with interactive drill-down
28
+ - **๐Ÿ’ป System Monitoring** - Real-time CPU, memory, disk, and network dashboard
29
+ - **๐Ÿ”ฅ Project Purge** - Clean build artifacts (node_modules, target, dist, etc.)
30
+ - **๐Ÿ“ฆ Installer Cleanup** - Find and remove old installer files
31
+ - **๐Ÿ” Duplicate Finder** - Locate and remove duplicate files
32
+ - **๐Ÿ“ˆ HTML Reports** - Generate detailed cleanup reports with charts
33
+ - **โš™๏ธ Configuration** - Whitelist/blacklist paths, customize safety levels
34
+ - **๐Ÿฉบ Health Check** - Run system diagnostics
35
+ - **๐Ÿ’พ Backup & Restore** - Safe file backup before cleanup
36
+ - **โฐ Scheduler** - Automate cleanup tasks
37
+ - **๐Ÿ‘๏ธ Directory Watch** - Monitor directory sizes
38
+ - **๐Ÿ‘† Touch ID** - Sudo authentication with Touch ID
39
+ - **๐Ÿ“ Shell Completion** - Tab completion for Bash, Zsh, Fish
40
+
41
+ ## ๐Ÿš€ Installation
42
+
43
+ ```bash
44
+ # Clone the repository
45
+ git clone https://github.com/your-username/broom.git
46
+ cd broom
47
+
48
+ # Install dependencies
49
+ bun install # or npm install
50
+
51
+ # Build the project
52
+ bun run build # or npm run build
53
+
54
+ # Link globally (optional)
55
+ bun link
56
+
57
+ # Run projects
58
+ broom <command> <option>
59
+
60
+ # or
61
+ bun run dev <command> <option>
62
+
63
+ # or
64
+ bun dist/index.js <command> <option>
65
+
66
+ # CLI help windows
67
+ broom --help
68
+ ```
69
+
70
+ ## ๐ŸŽฏ Usage
71
+
72
+ ```bash
73
+ # Interactive cleanup - scan and select categories
74
+ broom clean
75
+
76
+ # Preview mode - see what would be cleaned
77
+ broom clean --dry-run
78
+
79
+ # Clean all safe categories automatically
80
+ broom clean --all --yes
81
+
82
+ # Generate HTML report after cleanup
83
+ broom clean --report --open
84
+
85
+ # Analyze disk usage
86
+ broom analyze
87
+
88
+ # System status dashboard
89
+ broom status --watch
90
+
91
+ # Complete uninstall of an app
92
+ broom uninstall
93
+ ```
94
+
95
+ ## ๐Ÿ“š Commands
96
+
97
+ ### Core Commands
98
+
99
+ | Command | Description | Key Options |
100
+ | ----------- | -------------------------- | --------------------------------------------------------------- |
101
+ | `clean` | Deep system cleanup | `--dry-run`, `--all`, `--yes`, `--unsafe`, `--report`, `--open` |
102
+ | `analyze` | Disk space analysis | `--path <path>`, `--depth <n>`, `--limit <n>` |
103
+ | `status` | System resource monitoring | `--watch`, `--interval <ms>` |
104
+ | `uninstall` | Remove apps completely | `--dry-run`, `--yes` |
105
+ | `optimize` | System maintenance | `--dry-run`, `--yes`, `--all` |
106
+
107
+ ### Utility Commands
108
+
109
+ | Command | Description | Key Options |
110
+ | ------------ | ----------------------- | ----------------------------------------------------- |
111
+ | `purge` | Clean project artifacts | `--dry-run`, `--yes`, `--path <path>` |
112
+ | `installer` | Remove installer files | `--dry-run`, `--yes` |
113
+ | `duplicates` | Find duplicate files | `--path <path>`, `--min-size <size>`, `--interactive` |
114
+ | `reports` | Manage cleanup reports | `list`, `clean`, `open`, `--yes` |
115
+ | `backup` | Create file backups | `--path <path>`, `--tag <name>` |
116
+ | `restore` | Restore from backup | `--tag <name>`, `--path <path>` |
117
+
118
+ ### Configuration Commands
119
+
120
+ | Command | Description | Subcommands |
121
+ | ------------ | ------------------- | -------------------------------------------- |
122
+ | `config` | Manage settings | `show`, `set <key> <value>`, `reset`, `path` |
123
+ | `touchid` | Touch ID for sudo | `enable`, `disable`, `status` |
124
+ | `completion` | Shell completion | `bash`, `zsh`, `fish`, `install` |
125
+ | `doctor` | System diagnostics | - |
126
+ | `schedule` | Automate cleanups | `add`, `remove`, `list` |
127
+ | `watch` | Monitor directories | `--add`, `--remove`, `--list`, `--check` |
128
+
129
+ ### System Commands
130
+
131
+ | Command | Description | Options |
132
+ | -------- | --------------- | ----------- |
133
+ | `update` | Update broom | - |
134
+ | `remove` | Uninstall broom | `--yes` |
135
+ | `help` | Display help | `[command]` |
136
+
137
+ ## ๐Ÿ’ก Usage Examples
138
+
139
+ ### Cleanup Operations
140
+
141
+ ```bash
142
+ # Interactive cleanup with category selection
143
+ broom clean
144
+
145
+ # Dry run - preview without deleting
146
+ broom clean --dry-run
147
+
148
+ # Clean all safe categories without prompts
149
+ broom clean --all --yes
150
+
151
+ # Include risky categories (downloads, trash)
152
+ broom clean --unsafe --yes
153
+
154
+ # Generate HTML report with charts
155
+ broom clean --report --open
156
+
157
+ # Clean specific categories interactively
158
+ broom clean # then select from menu
159
+ ```
160
+
161
+ ### Disk Analysis
162
+
163
+ ```bash
164
+ # Analyze home directory
165
+ broom analyze
166
+
167
+ # Analyze specific path with depth
168
+ broom analyze --path ~/Library --depth 3
169
+
170
+ # Show top 20 largest items
171
+ broom analyze --limit 20
172
+
173
+ # Analyze entire disk
174
+ broom analyze --path / --depth 2
175
+ ```
176
+
177
+ ### System Monitoring
178
+
179
+ ```bash
180
+ # Show current system status
181
+ broom status
182
+
183
+ # Live monitoring dashboard
184
+ broom status --watch
185
+
186
+ # Custom refresh interval (500ms)
187
+ broom status --watch --interval 500
188
+ ```
189
+
190
+ ### App Management
191
+
192
+ ```bash
193
+ # Uninstall app with interactive selection
194
+ broom uninstall
195
+
196
+ # Preview uninstall without deleting
197
+ broom uninstall --dry-run
198
+
199
+ # Uninstall without confirmation
200
+ broom uninstall --yes
201
+ ```
202
+
203
+ ### System Optimization
204
+
205
+ ```bash
206
+ # Run all optimization tasks
207
+ broom optimize --all
208
+
209
+ # Preview optimization tasks
210
+ broom optimize --dry-run
211
+
212
+ # Tasks include:
213
+ # - Flush DNS cache
214
+ # - Rebuild Spotlight index
215
+ # - Purge memory cache
216
+ # - Verify disk
217
+ # - Repair permissions
218
+ ```
219
+
220
+ ### Project Cleanup
221
+
222
+ ```bash
223
+ # Clean current directory
224
+ broom purge
225
+
226
+ # Clean specific project
227
+ broom purge --path ~/projects/myapp
228
+
229
+ # Preview what would be cleaned
230
+ broom purge --dry-run
231
+
232
+ # Cleans: node_modules, target, dist, build, .next, etc.
233
+ ```
234
+
235
+ ### Duplicate Files
236
+
237
+ ```bash
238
+ # Find duplicates in home directory
239
+ broom duplicates
240
+
241
+ # Scan specific path with size filter
242
+ broom duplicates --path ~/Documents --min-size 1MB
243
+
244
+ # Interactive mode to choose what to keep
245
+ broom duplicates --interactive
246
+
247
+ # Custom hash algorithm
248
+ broom duplicates --hash md5
249
+ ```
250
+
251
+ ### Reports Management
252
+
253
+ ```bash
254
+ # List all generated reports
255
+ broom reports
256
+ broom reports list
257
+
258
+ # Delete all reports
259
+ broom reports clean
260
+
261
+ # Delete without confirmation
262
+ broom reports clean --yes
263
+
264
+ # Open latest report in browser
265
+ broom reports open
266
+ ```
267
+
268
+ ### Backup & Restore
269
+
270
+ ```bash
271
+ # Backup important files
272
+ broom backup --path ~/Documents --tag "before-cleanup"
273
+
274
+ # List backups
275
+ broom backup --list
276
+
277
+ # Restore from backup
278
+ broom restore --tag "before-cleanup"
279
+
280
+ # Restore to different location
281
+ broom restore --tag "backup-001" --path ~/restored
282
+ ```
283
+
284
+ ### Configuration
285
+
286
+ ```bash
287
+ # Show current configuration
288
+ broom config show
289
+
290
+ # Set safety level (safe, moderate, aggressive)
291
+ broom config set safetyLevel moderate
292
+
293
+ # Add path to whitelist
294
+ echo ~/important-folder >> ~/.config/broom/whitelist
295
+
296
+ # View config file location
297
+ broom config path
298
+
299
+ # Reset to defaults
300
+ broom config reset
301
+ ```
302
+
303
+ ### Shell Completion
304
+
305
+ ```bash
306
+ # Install for current shell (auto-detect)
307
+ broom completion install
308
+
309
+ # Generate for specific shell
310
+ broom completion bash > /usr/local/etc/bash_completion.d/broom
311
+ broom completion zsh > ~/.zsh/completions/_broom
312
+ broom completion fish > ~/.config/fish/completions/broom.fish
313
+
314
+ # Zsh manual setup
315
+ broom completion zsh > ~/.zsh/completions/_broom
316
+ # Add to ~/.zshrc: fpath=(~/.zsh/completions $fpath)
317
+ ```
318
+
319
+ ### Touch ID Setup
320
+
321
+ ```bash
322
+ # Enable Touch ID for sudo
323
+ broom touchid enable
324
+
325
+ # Check status
326
+ broom touchid status
327
+
328
+ # Disable Touch ID
329
+ broom touchid disable
330
+ ```
331
+
332
+ ### Scheduling
333
+
334
+ ```bash
335
+ # Schedule weekly cleanup
336
+ broom schedule add --weekly
337
+
338
+ # Schedule daily at 2 AM
339
+ broom schedule add --daily --time 02:00
340
+
341
+ # List scheduled tasks
342
+ broom schedule list
343
+
344
+ # Remove schedule
345
+ broom schedule remove <id>
346
+ ```
347
+
348
+ ### Directory Watch
349
+
350
+ ```bash
351
+ # Add directory to watch
352
+ broom watch --add --path ~/Downloads --threshold 1GB
353
+
354
+ # List watched directories
355
+ broom watch --list
356
+
357
+ # Check all watches now
358
+ broom watch --check
359
+
360
+ # Remove watch
361
+ broom watch --remove ~/Downloads
362
+ ```
363
+
364
+ ## ๐Ÿ—‚๏ธ Cleanup Categories
365
+
366
+ ## ๐Ÿ—‚๏ธ Cleanup Categories
367
+
368
+ ### โœ… Safe (Default)
369
+
370
+ Always safe to clean without risk of data loss:
371
+
372
+ - **User Cache** - `~/Library/Caches` (app caches)
373
+ - **User Logs** - `~/Library/Logs` (application logs)
374
+ - **Browser Cache** - Chrome, Safari, Firefox, Edge, Brave, Arc
375
+ - **Temporary Files** - `/tmp`, `/var/folders`
376
+
377
+ ### โš ๏ธ Moderate (Safe with review)
378
+
379
+ Generally safe but review before cleaning:
380
+
381
+ - **Development Cache** - npm, yarn, pip, cargo, gradle, Maven
382
+ - **Xcode Cache** - DerivedData, Archives, DeviceSupport
383
+ - **Homebrew Cache** - Downloaded packages
384
+ - **Docker Cache** - Build cache, unused images
385
+ - **Node Modules** - In workspace (check before deleting)
386
+ - **iOS Simulator** - Simulator data
387
+
388
+ ### ๐Ÿšจ Risky (Requires `--unsafe`)
389
+
390
+ May contain important files - review carefully:
391
+
392
+ - **Trash** - `~/.Trash` (deleted files)
393
+ - **Downloads** - `~/Downloads` (old files)
394
+ - **iOS Backups** - iPhone/iPad backups
395
+ - **Installer Packages** - `.dmg`, `.pkg` files
396
+
397
+ ## โš™๏ธ Configuration
398
+
399
+ ### Config Location
400
+
401
+ - Config directory: `~/.config/broom/`
402
+ - Main config: `~/.config/broom/config.json`
403
+ - Whitelist: `~/.config/broom/whitelist`
404
+ - Reports: `~/.broom/reports/`
405
+
406
+ ### Whitelist Example
407
+
408
+ Create `~/.config/broom/whitelist`:
409
+
410
+ ```
411
+ # Protected paths (one per line)
412
+ ~/Documents/important-project
413
+ ~/Library/Application Support/MyApp
414
+ /Volumes/External/backup
415
+ ```
416
+
417
+ ### Config Options
418
+
419
+ ```json
420
+ {
421
+ "safetyLevel": "safe", // safe, moderate, aggressive
422
+ "dryRun": false,
423
+ "confirmBeforeDelete": true,
424
+ "excludePaths": [],
425
+ "scanDepth": 3
426
+ }
427
+ ```
428
+
429
+ ### Global Options
430
+
431
+ All commands support these options:
432
+
433
+ | Option | Description |
434
+ | --------------- | ------------------------ |
435
+ | `-v, --version` | Display version number |
436
+ | `-h, --help` | Display help information |
437
+ | `--debug` | Enable debug logging |
438
+
439
+ ## ๐Ÿ“– Documentation
440
+
441
+ Detailed documentation available in the `docs/` directory:
442
+
443
+ - **[COMMANDS.md](docs/COMMANDS.md)** - Complete command reference
444
+ - **[HTML_REPORT.md](docs/HTML_REPORT.md)** - HTML report features
445
+ - **[SCANNERS.md](docs/SCANNERS.md)** - Scanner implementation details
446
+ - **[MIGRATION.md](docs/MIGRATION.md)** - Migration from Mole
447
+ - **[README.md](docs/README.md)** - Full project documentation (Japanese)
448
+
449
+ ## ๐Ÿ› ๏ธ Tech Stack
450
+
451
+ ### Core Dependencies
452
+
453
+ - **TypeScript** - Type-safe development
454
+ - **Node.js 18+** - Runtime environment
455
+ - **Commander.js** - CLI framework and argument parsing
456
+ - **@inquirer/prompts** - Interactive prompts and menus
457
+ - **chalk** - Terminal string styling
458
+ - **ora** - Elegant terminal spinners
459
+
460
+ ### Utilities
461
+
462
+ - **systeminformation** - System monitoring and hardware info
463
+ - **fast-glob** - Fast file pattern matching
464
+ - **handlebars** - HTML template engine for reports
465
+ - **cli-progress** - Beautiful progress bars
466
+
467
+ ### Development
468
+
469
+ - **ESLint** - Code linting
470
+ - **Prettier** - Code formatting
471
+ - **tsup** - TypeScript bundler
472
+ - **bun** - Fast package manager (optional)
473
+
474
+ ## ๐Ÿ—๏ธ Project Structure
475
+
476
+ ```
477
+ broom/
478
+ โ”œโ”€โ”€ src/
479
+ โ”‚ โ”œโ”€โ”€ commands/ # Command implementations
480
+ โ”‚ โ”‚ โ”œโ”€โ”€ clean.ts
481
+ โ”‚ โ”‚ โ”œโ”€โ”€ analyze.ts
482
+ โ”‚ โ”‚ โ”œโ”€โ”€ status.ts
483
+ โ”‚ โ”‚ โ””โ”€โ”€ ...
484
+ โ”‚ โ”œโ”€โ”€ scanners/ # File scanners
485
+ โ”‚ โ”‚ โ”œโ”€โ”€ base.ts
486
+ โ”‚ โ”‚ โ”œโ”€โ”€ browser-cache.ts
487
+ โ”‚ โ”‚ โ””โ”€โ”€ ...
488
+ โ”‚ โ”œโ”€โ”€ ui/ # User interface
489
+ โ”‚ โ”‚ โ”œโ”€โ”€ output.ts # Formatted output
490
+ โ”‚ โ”‚ โ””โ”€โ”€ prompts.ts # Interactive prompts
491
+ โ”‚ โ”œโ”€โ”€ utils/ # Utility functions
492
+ โ”‚ โ”‚ โ”œโ”€โ”€ fs.ts # File system utilities
493
+ โ”‚ โ”‚ โ”œโ”€โ”€ config.ts # Configuration
494
+ โ”‚ โ”‚ โ””โ”€โ”€ report.ts # HTML report generator
495
+ โ”‚ โ”œโ”€โ”€ types/ # TypeScript types
496
+ โ”‚ โ””โ”€โ”€ index.ts # Entry point
497
+ โ”œโ”€โ”€ docs/ # Documentation
498
+ โ”œโ”€โ”€ dist/ # Compiled output
499
+ โ””โ”€โ”€ package.json
500
+ ```
501
+
502
+ ## ๐Ÿงช Development
503
+
504
+ ```bash
505
+ # Install dependencies
506
+ bun install
507
+
508
+ # Development mode with auto-reload
509
+ bun run dev
510
+
511
+ # Build for production
512
+ bun run build
513
+
514
+ # Run tests
515
+ bun test
516
+
517
+ # Lint code
518
+ bun run lint
519
+
520
+ # Format code
521
+ bun run format
522
+
523
+ # Type check
524
+ bun run typecheck
525
+ ```
526
+
527
+ ## ๐Ÿค Contributing
528
+
529
+ Contributions are welcome! Please feel free to submit a Pull Request.
530
+
531
+ 1. Fork the repository
532
+ 2. Create your feature branch (`git checkout -b feature/amazing-feature`)
533
+ 3. Commit your changes (`git commit -m 'Add some amazing feature'`)
534
+ 4. Push to the branch (`git push origin feature/amazing-feature`)
535
+ 5. Open a Pull Request
536
+
537
+ ## ๐Ÿ“ License
538
+
539
+ MIT License - see the [LICENSE](LICENSE) file for details.
540
+
541
+ ## ๐Ÿ™ Acknowledgments
542
+
543
+ - Inspired by [Mole](https://github.com/tw93/Mole) by [Tw93](https://github.com/tw93)
544
+ - Built with modern TypeScript and Node.js ecosystem
545
+
546
+ ## ๐Ÿ”— Links
547
+
548
+ - [GitHub Repository](https://github.com/tukuyomil032/broom)
549
+ - [Issue Tracker](https://github.com/tukuyomil032/issues)
550
+ - [Documentation](docs/README.md)
551
+
552
+ ---
553
+
554
+ Made with โค๏ธ by the Broom team