# Exclusions

Three keys decide what a run looks at:

- **`exclude-folders`:** prunes directories from detection.
- **`exclude-packages`:** drops packages from reports, independently of `exclude-folders`.
- **[`include-hidden`](#include-hidden):** widens detection to named dot-directories, which it otherwise skips.

The two exclude lists live under the flag-default sections — `[global]`, a `[<command>]` override, or `[tool.<name>]` for one ecosystem — and a plain array **adds** to what the other sections and config files contribute (a prune set, so order is irrelevant; see [Clearing or replacing an inherited list](#clearing-or-replacing-an-inherited-list) for the other merge modes).

They belong in the repo-root `cooldown.toml`, the global config, or a `--config` file, and an exclude list in a nested `cooldown.toml` is a config error. A nested file still sets policy and the per-tool keys `[tool.cargo] edge-policy`, `[tool.cargo] generated-members` and `[tool.pnpm] single-copy`, but its `[global]` and `[<command>]` sections are ignored.

Every pattern is compiled when the config is loaded, so a bad glob is a **config error** (exit `2`), not a surprise mid-scan.

```toml
[global]
exclude-folders = ["examples", "/build", "third_party/grammars"]
exclude-packages = ["internal-*"]

[outdated]
exclude-folders = ["fixtures"]      # adds to the global set, for `outdated` only

[tool.npm]
exclude-folders = ["e2e"]           # per-ecosystem folder excludes
exclude-packages = ["@scope/*"]     # package-name format differs per ecosystem
```

## Package-manager trees

Detection never enters a directory a package manager fetches dependencies or builds into, whether or not anything ignores it, since the manifests and locks of the projects copied there are not yours to check or upgrade:

- `node_modules/`
- Mix's `deps/` and `_build/` beside a `mix.exs`
- the crates `cargo package` unpacks into `target/package/`, and the dependencies a Maven build unpacks into `target/dependency/`
- a Go `vendor/` holding `modules.txt`
- Bundler's `vendor/bundle/` and `vendor/cache/` beside a `Gemfile` or `gems.rb`

A relocated or linked tree, such as a custom Mix `deps_path`, `CARGO_TARGET_DIR` or a `deps` that links elsewhere, is recognized only where it sits on disk; list it in `exclude-folders`. Running a project command, such as `check` or `upgrade`, from inside one of the trees listed here is a usage error; a directory `exclude-folders` lists is only pruned from the walk, so naming it with `-C` still scans it.

## `exclude-folders`

Prunes directories from project detection (in addition to `.gitignore`), and also drops a dependency whose declaring workspace members all sit under an excluded path — handy when one root lockfile covers a whole monorepo.

It uses the **same `.gitignore` semantics** the scan already honors, so there is one model to learn:

| Pattern | Matches |
|---|---|
| `target` | every `target/` directory, at **any depth** |
| `target/` | identical — a trailing slash is allowed and ignored |
| `/build` | only the top-level `build/` (a leading slash anchors to the scan root) |
| `third_party/grammars` | the root-relative path `third_party/grammars` (an interior slash anchors) |
| `**/snapshots` | every `snapshots/` at any depth (explicit, same as the bare name) |

## `exclude-packages`

Drops a workspace member from reports when its **package name** matches a glob. It matches member names, not dependency names: a dependency drops out only when every member that declares it is excluded. The globs use the same flavor as the `[package."…"]` [selector](https://romnn.github.io/cooldown/docs/configuration/selectors/). `*` is always a wildcard (no registry permits `*` in a package name, so nothing needs escaping) and crosses `/`, so `@scope/*` covers a whole npm scope and `serde_*` a crate family.

Because names differ per ecosystem (`my-pkg` vs `@scope/my-pkg`), reach for `[tool.<name>].exclude-packages` when a pattern is ecosystem-specific; a `[global]` entry applies to every tool.

## `include-hidden`

Detection never enters a directory whose name starts with `.` — `.git`, `.venv`, `.cache`, and every other dot-directory — which also hides real projects kept in one, such as tooling scripts under `.github/scripts`. `include-hidden` opts named dot-directories back in:

```toml
[global]
include-hidden = [".agents", ".github"]
```

- Patterns take the [`exclude-folders`](#exclude-folders) semantics (a bare name at any depth, `/name` anchored to the scan root, an interior slash root-relative) and are matched against the **dot-directory itself**. Below a matched directory the walk proceeds as anywhere else, except that a dot-directory nested inside it (`.github/scripts/.venv`) stays skipped unless a pattern matches it too. A dot-directory below another one is reached only when the outer one is included as well.
- **`.git` is never scanned**, whatever the patterns match (`.*` included).
- **`exclude-folders` still wins**: it prunes an included directory, or anything below one, exactly as it would an ordinary directory. `.gitignore` handling is unchanged, so a gitignored path stays skipped.
- It lives under `[global]` or a `[<command>]` table only — which dot-directories hold projects is a property of the repository, not of one ecosystem, so there is no `[tool.*]` form — and, like the exclude lists, only in the repo-root `cooldown.toml`, the global config, or a `--config` file. It merges across sections and files the same way (below).

Without `include-hidden` nothing changes: no dot-directory is scanned unless the run [selects one](#running-from-an-excluded-directory).

## Clearing or replacing an inherited list

Lists layer across files (the global config → the repo-root `cooldown.toml` → `--config`) and across sections (`[global]` → `[<command>]`), and a plain array **adds** to what it inherits. To undo an inherited list, name the merge mode instead:

| Form | Effect on the inherited list |
|---|---|
| `exclude-folders = ["a"]` | adds `a` |
| `exclude-folders = []` | **clears** it |
| `exclude-folders = { replace = ["a"] }` | **replaces** it with `a` |
| `exclude-folders = { extend = ["a"] }` | adds `a` (the explicit spelling of the plain array) |

Each key merges on its own. A `[tool.cargo]` replacement swaps only the inherited `[tool.cargo]` list — the `[global]` list is a different key and is still combined with it at scan time — and a `[outdated]` replacement shadows `[global]` for `outdated` alone. A later layer's plain array adds to a replacement rather than reviving what it dropped. `exclude-packages` and `include-hidden` merge the same way, and a misspelt merge key is a config error.

Within one file the sections resolve first — `[global]`, then the `[<command>]` override — and only then do the files fold, lowest precedence first. A repo-root `[outdated]` replacement therefore drops everything the global config contributed for `outdated`, its `[global]` and `[outdated]` lists alike, and a plain array in a later `--config` file adds to that result.

Two spellings are rejected because they cannot mean what they say:

- **`{ extend = [] }`:** changes nothing (write `[]` to clear).
- **Alias tables that set the same list:** two alias tables of one tool (`[tool.rust]` beside `[tool.cargo]`) that both set the same list in the same file would leave the winner to table order. One setting `exclude-folders` beside one setting `exclude-packages` is fine.

```toml
# ~/.config/cooldown/config.toml — the org-wide default
[tool.cargo]
exclude-folders = ["vendor"]
```

```toml
# cooldown.toml — this repo audits its vendored crates
[tool.cargo]
exclude-folders = []                            # drop the inherited per-tool list

[outdated]
exclude-folders = { replace = ["fixtures"] }    # for `outdated`, ignore [global] and prune only fixtures
```

## Running from an excluded directory

The excludes trim the *default* scan; naming a directory outranks them. `cooldown -C incubator check` — or `cd incubator && cooldown check` — never prunes `incubator` or the directories on the way to it (dot-directories included), even when the repo root lists it in `exclude-folders`, and the workspace member containing the selected directory is exempt from `exclude-folders` and `exclude-packages` alike. Members below the selection (`-C crates` in a workspace whose members live under `crates/`) are in scope, and a glob that matches them *below* the selection still drops them. Dependencies the tool attributes to no member (a Go module's, or the transitive rows of tools that attribute only direct dependencies) stay in scope for every command, so a selection never hides a transitive from the gate, and `fix`/`upgrade` under `-C <member>` may move one that only a sibling member needs, since a shared lock cannot change for one member alone. Without this rule a run pointed at an excluded subtree would check nothing and report a clean result.

A selection the run cannot honor is a usage error (exit `2`) rather than an empty result:

- **One the run's own `--exclude-folders` names:** drop one of the two.
- **One a `.gitignore`/`.ignore` rule hides:** the scan never reaches it, so pass `--no-gitignore` to enter it.

A selection nothing covers (no project or workspace member under it, or none with dependencies) evaluates zero dependencies and says so with a config warning.

## On the command line

All three lists have a CLI form, each repeatable:

- `--exclude-folders <glob>`
- `--exclude-packages <glob>`
- `--include-hidden <glob>`

A CLI list **replaces** the `[global]` / `[<command>]` config lists for that run (per-tool `[tool.*]` excludes still apply). CLI globs are validated the same way, so a malformed pattern is a config error, and so is a `--exclude-folders` glob that names the `-C` directory:

```sh
cooldown outdated --exclude-folders 'e2e' --exclude-folders '/vendor'
cooldown check --include-hidden '.github'
```

> [!NOTE]
> `exclude-folders` is about **where** to look; `exclude-packages` is about **what** to report. A dependency can be dropped by either — its folder being pruned from detection, or its name matching a package exclude.
