Metadata-Version: 2.5
Name: sweepito
Version: 0.2.0
Summary: Safely clean generated project artifacts across languages, frameworks, game engines, data and infrastructure tooling.
Project-URL: Homepage, https://github.com/coldsofttech/Sweepito
Project-URL: Issues, https://github.com/coldsofttech/Sweepito/issues
Project-URL: Support, https://github.com/coldsofttech/Sweepito/blob/main/SUPPORT.md
Author: coldsofttech
License: MIT License
        
        Copyright (c) 2026 coldsofttech
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Keywords: build,cache,cleanup,developer-tools,pre-commit
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Software Development
Classifier: Topic :: Utilities
Requires-Python: >=3.11
Requires-Dist: pathspec>=0.12
Requires-Dist: rich>=13
Description-Content-Type: text/markdown

# Sweepito

[![CI](https://github.com/coldsofttech/Sweepito/actions/workflows/ci.yml/badge.svg)](https://github.com/coldsofttech/Sweepito/actions/workflows/ci.yml)
[![Release](https://img.shields.io/github/v/release/coldsofttech/Sweepito?logo=github)](https://github.com/coldsofttech/Sweepito/releases)
[![PyPI](https://img.shields.io/pypi/v/sweepito?logo=pypi&logoColor=white)](https://pypi.org/project/sweepito/)
[![Python 3.11+](https://img.shields.io/badge/python-3.11%2B-blue?logo=python&logoColor=white)](https://www.python.org/downloads/)
[![License](https://img.shields.io/github/license/coldsofttech/Sweepito)](LICENSE)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit)](https://github.com/pre-commit/pre-commit)

Safely clean generated project artifacts (caches, build output, test reports and tool
leftovers) across languages, frameworks, game engines, data and infrastructure tooling.

Sweepito is a command-line tool: you install it and run `sweepito`. It is not a Python
library and has no Python API to import.

## Why Sweepito?

Every ecosystem leaves its own clutter behind: `__pycache__/`, `.next/`, Cargo `target/`,
Gradle `build/`, `.terraform/`, `.ipynb_checkpoints/`, and many more. Cleaning them by hand
means remembering each tool's quirks, and the usual shortcuts are risky: `rm -rf build`
happily deletes a committed `build/` folder, and `git clean -fdx` removes everything
untracked, including your `.env`.

Sweepito is one tool for all of it, built around a simple rule: **it only removes paths that
Git already ignores and does not track, and only when the project's own marker files prove
what the folder is.** A `build/` directory is a candidate beside a `CMakeLists.txt` or
`pom.xml`, never because of its name alone.

## What you get

- **29 technology profiles and 142 rules**, detected automatically from marker files
  (`Cargo.toml`, `pom.xml`, `package.json`, ...). Repositories with several technologies and
  nested projects are handled per project.
- **Conservative by default.** Only `safe` caches are cleaned. Build output is opt-in, and
  dependency directories such as `node_modules/` need an explicit flag as well.
- **Previews you can trust.** `scan` shows exactly what `clean` would remove, with sizes and
  the reclaimable total.
- **One config format for every language**, with custom cleanup rules and profiles.
- **Git hooks**: post-commit cleanup through the `pre-commit` framework or a native hook,
  silent when there is nothing to do.
- **Machine-readable output** (`--json`) and meaningful exit codes for automation.
- **Small and cross-platform**: it runs on Linux, macOS and Windows, and works on any project in
  any language as long as the project is a Git repository.

## Safety model

| Guarantee | How |
|---|---|
| Tracked files are never deleted | Candidates come from Git's own ignore list, and tracked paths are re-checked right before deleting |
| Nothing outside the project | Paths are resolved and confined to the project root; absolute paths and `..` are rejected |
| Links are not followed | Symlinks and Windows junctions are removed as links, never traversed |
| `.git/` is untouched | It is never a candidate |
| A name alone is not enough | A rule needs its marker file, and generic names are anchored beside it |
| Risky rules are opt-in | `high-impact` rules (dependencies, environments) never run unless you ask: `--enable RULE` or `--risk high-impact` |
| Not a Git repo? Refuse | Override only with `--no-git-check`, which counts as high impact |
| Failures are reported | Locked or protected files are listed and the run exits with code 1; nothing is forced |

Built-in rules never target application data, infrastructure state (`*.tfstate`), secrets
(`.env*`) or IDE settings.

## Install

Requires Python 3.11 or later and [Git](https://git-scm.com/). Because Sweepito is a program
rather than a library, [pipx](https://pipx.pypa.io/) and [uv](https://docs.astral.sh/uv/) are the
best fit: they keep it out of your project environments, and your project does not need to be
a Python project.

```bash
pipx install sweepito          # or: uv tool install sweepito
uvx sweepito scan              # run once without installing
```

Check the install with `sweepito --version`, and your setup with `sweepito doctor`.

No Python? Download a native installer from the
[releases](https://github.com/coldsofttech/Sweepito/releases): a `setup.exe` for Windows, and a `.deb`
or `.rpm` for Linux. See [Packaging](docs/packaging.md).

## Quick start

```bash
sweepito scan                              # what would be removed (safe rules only)
sweepito scan --risk configurable          # include build output
sweepito clean                             # remove, asking first
sweepito clean --enable rust.target --yes  # also remove Cargo target/, no prompt
sweepito rules                             # list every rule and its risk
sweepito init                              # write a starter sweepito.toml
```

Example:

```
$ sweepito scan --risk configurable
Project: /home/dev/myapp   profiles: common, node, python, rust
                    Cleanup candidates
┌────────────────┬──────────────────┬──────────┬──────────────┐
│ Rule           │ Path             │     Size │ Risk         │
├────────────────┼──────────────────┼──────────┼──────────────┤
│ python.pytest  │ .pytest_cache/   │   3.2 KB │ safe         │
│ python.pycache │ src/__pycache__/ │  87.8 KB │ safe         │
│ node.next      │ web/.next/       │ 210.0 MB │ configurable │
│ rust.target    │ engine/target/   │   1.8 GB │ configurable │
└────────────────┴──────────────────┴──────────┴──────────────┘
4 candidate(s), 2.0 GB reclaimable.
Nothing deleted. Run 'sweepito clean' to remove them.
```

Output is rendered with [Rich](https://github.com/Textualize/rich) (tables, panels, colour).
Add `--json` for plain machine-readable output, or `--no-color` to turn colour off.

## Profiles

Sweepito covers web and Node.js tooling, Python, JVM languages, .NET, Go, Rust, C and C++, PHP,
Ruby, Dart and Flutter, Swift, Elixir, R and Jupyter, Terraform, Docker, data engineering, game
engines (Unity, Unreal, Godot), and OS and editor junk that is always cleaned. Every profile, with
its markers, targets and risk levels, is listed in [docs/profiles.md](docs/profiles.md).

### Risk levels

| Level | Behaviour |
|---|---|
| `safe` | On by default: well-identified caches that regenerate automatically |
| `configurable` | Opt-in: build output and other things that are slow to rebuild or mildly valuable |
| `high-impact` | Opt-in with `--enable RULE` or `--risk high-impact`: dependencies, environments, experiment data |
| `custom` | Rules you write yourself: always on, since you chose them. `--risk custom` runs only these |

## Use

Selection options work the same for `scan`, `clean`, `check` and `report`:

```bash
sweepito clean -p python -p node                       # only these profiles
sweepito clean --risk configurable -x dist/            # build output, but keep dist/
sweepito clean --enable node.modules
sweepito clean --disable python.hypothesis
sweepito scan --json | jq '.total_bytes'               # for scripts
sweepito check --quiet                                 # exit 1 if anything is left
```

## Configuration

Create `sweepito.toml` (or a `[tool.sweepito]` table in `pyproject.toml`). The format is the
same for every language, so non-Python projects need no `pyproject.toml`.

```toml
[defaults]
profiles = ["auto"]            # or ["python", "node"]
risk = "safe"                  # custom | safe | configurable | high-impact

[clean]
enable  = ["rust.target", "node.next"]
disable = ["python.hypothesis"]
exclude = ["dist/", "build/keep-me/"]   # gitignore syntax; always wins

[hook]                         # applies to hook runs only
quiet = true

[[rule]]                       # custom cleanup
id = "custom.test-output"
paths = ["test-results/", "tmp/e2e/**"]
```

Rules you write yourself always run and are shown as `custom`, so there is no risk level to
choose. Precedence is command line, then config file, then profile defaults, then built-in defaults.
Custom rules follow the same safety gates, so a target must still be inside the project,
untracked and git-ignored (or opt out of the ignore check per rule with
`allow_untracked = true`, which never applies to tracked files). Details are in
[docs/guides/configuration.md](docs/guides/configuration.md).

## Command line

| Command | Purpose |
|---|---|
| `scan` | List cleanup candidates with sizes (never deletes) |
| `clean` | Delete candidates (`-n` dry run, `-y` skip the prompt, `--non-interactive` for automation) |
| `check` | Like `scan`, but exits 1 if candidates exist |
| `report` | Reclaimable space by profile, rule and risk |
| `profiles` | List the supported technologies and what detects them (`--explain NAME` for one) |
| `rules` | List every cleanup rule and its risk (`--explain RULE` for one) |
| `config show` / `validate` | Show the effective settings or validate the file |
| `init` | Write a starter `sweepito.toml` |
| `hook install` / `uninstall` / `status` | Manage the native Git hook (`--stage post-commit` or `pre-commit`) |
| `doctor` | Check Git, the project, the config and hooks (changes nothing) |

Run `sweepito <command> --help` for every option, or read the
[command line guide](docs/guides/cli.md), which also covers file patterns, JSON output,
recipes and troubleshooting.

## Git hook setup

With the [pre-commit](https://pre-commit.com) framework, add to `.pre-commit-config.yaml`:

```yaml
repos:
  - repo: https://github.com/coldsofttech/Sweepito
    rev: v0.2.0
    hooks:
      - id: sweepito-clean     # post-commit cleanup
      # - id: sweepito-scan    # report-only at pre-commit
```

```bash
pre-commit install --hook-type post-commit
```

Without the framework, run `sweepito hook install` (add `--stage pre-commit` for the report-only
variant). It writes `.git/hooks/post-commit`, appends to an existing hook instead of replacing
it, and `sweepito hook uninstall` removes only its own block.

Hooks read the same `sweepito.toml` and honour the `[hook]` section. A post-commit hook cannot
fail a commit; if cleanup fails, it prints a message to stderr.

## Output, logs and exit codes

Sweepito does not write log files. Results go to standard output and problems to standard
error, so you can redirect them yourself.

- `--json` prints one JSON document with the candidates, skipped paths (and why), removed and
  failed items, and freed bytes.
- `-v` explains why paths were skipped, and `-q` prints nothing unless something needs
  attention. Hook runs are quiet when there is nothing to clean.
- `sweepito doctor` shows the environment, the config in use and installed hooks.

| Code | Meaning |
|---|---|
| 0 | Success, including "nothing to clean" |
| 1 | Some items failed or were skipped (for `check`: candidates exist) |
| 2 | Usage or configuration error |
| 3 | Unexpected error |
| 4 | Safety refusal (not a Git repo, high-impact without the flag, no consent) |
| 130 | Interrupted |

## Documentation

[CLI](docs/guides/cli.md) · [Configuration](docs/guides/configuration.md) · [Profiles and rules](docs/profiles.md) ·
[Packaging](docs/packaging.md) · [Architecture](docs/architecture.md) · [Development](docs/development.md) · [Changelog](CHANGELOG.md)

See [docs/README.md](docs/README.md) for an overview, and [SUPPORT.md](SUPPORT.md) if you need help.

## Contributing

Contributions are welcome, especially new technologies and rules. Please read
[CONTRIBUTING.md](CONTRIBUTING.md) first; every change keeps the safety invariants and comes
with tests. To work on the code, see [docs/development.md](docs/development.md). Everyone taking part is expected to follow the [Code of Conduct](CODE_OF_CONDUCT.md).

## Security

Because Sweepito deletes files, a bug that removes tracked files, anything outside the project
or follows a symlink is a security issue. Please report it privately as described in
[SECURITY.md](SECURITY.md) and do not open a public issue.

## License

[MIT](LICENSE)
