depcurfew 1.0.0 → 1.1.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.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # depcurfew
2
2
 
3
- One supply-chain security policy for npm, pnpm, Yarn, Bun, Deno, Renovate and Dependabot, and a doctor that finds configuration that silently does nothing.
3
+ One supply-chain security policy for npm, pnpm, Yarn, Bun, Deno, uv, pip, Poetry, PDM, Pipenv, Renovate and Dependabot, and a doctor that finds configuration that silently does nothing.
4
4
 
5
5
  ## Why
6
6
 
@@ -10,7 +10,7 @@ depcurfew keeps one policy file, `depcurfew.json`, writes it into the configurat
10
10
 
11
11
  ## Five-minute start
12
12
 
13
- 1. `npx depcurfew init` writes `depcurfew.json` with the default policy below and lists the tools it detected.
13
+ 1. `npx depcurfew init` writes `depcurfew.json` with the default policy below and lists the tools it detected. When the repository already sets a longer release-age delay for one of them, `cooldown.minimum` keeps the longest one, and `init` says where it found it.
14
14
  2. `npx depcurfew explain` shows what it detected and what the policy means for each tool.
15
15
  3. `npx depcurfew apply --dry-run` prints the changes as a diff, without writing anything.
16
16
  4. `npx depcurfew apply` writes them. Run it again whenever `depcurfew.json` changes; a second run with the same policy changes nothing.
@@ -57,7 +57,7 @@ npx dcf doctor
57
57
 
58
58
  Who needs it installed:
59
59
 
60
- - **Developers working on the project:** nothing to do. The protection does not depend on depcurfew being installed: it lives in the package manager configuration that `apply` writes into the repository (`.npmrc`, `pnpm-workspace.yaml`, `.yarnrc.yml`, `bunfig.toml`, `deno.json` and the bot configuration), and the package managers read it on their own. The project install brings depcurfew along as a development dependency anyway.
60
+ - **Developers working on the project:** nothing to do. The protection does not depend on depcurfew being installed: it lives in the package manager configuration that `apply` writes into the repository (`.npmrc`, `package.json`, `pnpm-workspace.yaml`, `.yarnrc.yml`, `bunfig.toml`, `deno.json`, `pyproject.toml` or `uv.toml`, `poetry.toml`, `Pipfile`, `requirements.txt` and the bot configuration), and the package managers read it on their own. pip's release-age delay is the exception: pip reads it only from the environment where it runs, and `apply` says what to set there. The project install brings depcurfew along as a development dependency anyway.
61
61
  - **Whoever changes `depcurfew.json`:** runs `npx dcf apply` and commits the result.
62
62
  - **CI:** runs `doctor`, with the GitHub Action below or with the project's own copy on other CI systems.
63
63
 
@@ -85,9 +85,9 @@ Every section is optional: a section that is absent means depcurfew does not man
85
85
  | `cooldown.minimum` | | | Minimum age of a release before it is installed or proposed: a whole number followed by m (minutes), h (hours), d (days) or w (weeks). Converted to each tool's unit, always rounding up. |
86
86
  | `cooldown.exclude` | | `[]` | Packages that skip the release-age delay, e.g. your own scope. |
87
87
  | `cooldown.securityUpdates` | `"bypass"`, `"delay"` | `"bypass"` | Whether security updates skip the delay ("bypass") or wait like other updates ("delay"), where the tool can tell them apart. |
88
- | `installScripts` | | | Dependency lifecycle scripts. |
89
- | `installScripts.default` | `"allow"`, `"deny"` | | Whether dependency lifecycle scripts (preinstall, install, postinstall) run by default. |
90
- | `installScripts.allow` | | `[]` | Packages whose lifecycle scripts may run when the default is "deny". |
88
+ | `installScripts` | | | Code that dependencies run when they are installed: lifecycle scripts in npm, building from source in Python. |
89
+ | `installScripts.default` | `"allow"`, `"deny"` | | Whether dependency lifecycle scripts (preinstall, install, postinstall) run by default; for Python, whether packages may be built from source. |
90
+ | `installScripts.allow` | | `[]` | Packages whose lifecycle scripts may run when the default is "deny"; Python packages listed here are always built from source. |
91
91
  | `sources` | | | Where dependencies may come from besides the registry. An absent field is not managed. |
92
92
  | `sources.git` | `"allow"`, `"deny"` | | Dependencies installed from git repositories. |
93
93
  | `sources.remoteTarball` | `"allow"`, `"deny"` | | Dependencies installed from tarball URLs outside the registry. |
@@ -102,47 +102,135 @@ The package installs two names for the same command: `depcurfew` and the short `
102
102
 
103
103
  | Command | What it does |
104
104
  | --- | --- |
105
- | `depcurfew init [directory] [--force]` | Writes `depcurfew.json` with the default policy; `--force` overwrites an existing one. |
105
+ | `depcurfew init [directory] [--force]` | Writes `depcurfew.json` with the default policy (keeping a longer release-age delay the repository already sets); `--force` overwrites an existing one. |
106
106
  | `depcurfew explain [directory] [--json]` | Describes the detected package managers, versions, bots and workspaces, and the policy values for each tool. |
107
- | `depcurfew apply [directory] [--dry-run]` | Writes the policy into the configuration of every target tool; `--dry-run` prints a unified diff instead. |
107
+ | `depcurfew apply [directory] [--dry-run] [--json]` | Writes the policy into the configuration of every target tool; `--dry-run` prints a unified diff instead, `--json` the result as JSON. |
108
108
  | `depcurfew doctor [directory] [--json \| --sarif]` | Finds configuration that silently does not work and drift from the policy; `--sarif` prints SARIF 2.1.0 for code scanning. |
109
+ | `depcurfew check <package...> [--json] [--dir <directory>] [--registry <url>] [--index <url>]` | Checks packages against the policy before you install them: see [Guarding installs](#guarding-installs). |
110
+ | `depcurfew check --hook claude-code` | The same check as a Claude Code hook that blocks install commands breaking the policy. |
109
111
 
110
- Exit codes: `0` success (warnings included), `1` an error (an invalid policy, a file that cannot be edited, a doctor finding with level error), `2` a usage error. `depcurfew <command> --help` describes a command with examples and its exit codes.
112
+ Without a directory, `explain`, `apply` and `doctor` work on the nearest directory with `depcurfew.json`, from the current directory up to the root of the repository (the directory with `.git`), and say so when that is a parent directory (outside a git repository only the current directory counts, and on Linux and macOS a parent directory counts only when it belongs to you and others cannot write to it, because a shared parent such as `/tmp` may hold someone else's `depcurfew.json`; directories inside `node_modules` are skipped), so `doctor` run in a subdirectory does not pass for a project without a policy. A directory given on the command line is used as it is. `check` looks for `depcurfew.json` the same way, starting in `--dir`.
111
113
 
112
- Every finding and warning says what to do about it. Text for people is colored on a terminal; `NO_COLOR=1` turns colors off and `FORCE_COLOR=1` turns them on, for example in a CI log that shows them. `--json`, `--sarif` and a diff written to a file stay plain, for programs and AI agents.
114
+ Exit codes: `0` success (warnings included), `1` an error (an invalid or unreadable policy, a file that cannot be edited, a doctor finding with level error), `2` a usage error (such as an unknown option or a directory that does not exist). `depcurfew <command> --help` describes a command with examples and its exit codes.
115
+
116
+ Every finding and warning says what to do about it. When a command cannot start, it says why with a code (`directory-not-found`, `not-a-directory`, `policy-missing`, `policy-invalid`, `policy-unreadable`, and for `init` also `policy-exists` and `cannot-write`) and what to do; with `--json` that is a document with `errors` on stdout, and `doctor --sarif` prints a run marked as not successful. Text for people is colored on a terminal; `NO_COLOR=1` turns colors off and `FORCE_COLOR=1` turns them on, for example in a CI log that shows them. Control characters in names and values from the repository or a registry are shown as text (ESC as `\x1b`, or as `\u001b` inside a quoted value such as a package name in the problems of `depcurfew.json`), so a crafted package or file name cannot change the terminal. `--json`, `--sarif` and a diff written to a file stay plain, for programs and AI agents.
117
+
118
+ The `--json` documents of all commands share these fields: `schemaVersion` (1), `policy` (its status in `apply` and `doctor`, the path of the `depcurfew.json` used in `check`, its values in `explain`), `notices` (such as the parent directory whose `depcurfew.json` was used) and `errors`, the reasons a command could not start, each with `code`, `level`, `location.file`, `message` and `fix`, and `issues` for `policy-invalid`. Paths are relative to the directory the command works on (a directory that does not exist is named as given). A `depcurfew.json` that cannot be used is an error with the same code, message and fix in `apply`, `check` and `explain`, which also keeps it in `policy`; `doctor` reports it as the finding `invalid-policy`, so that it reaches code scanning too, and counts it in `summary.error`. Within a `schemaVersion` fields and values are only added; a field is removed or changes its meaning only with a new `schemaVersion`.
113
119
 
114
120
  How `apply` edits files:
115
121
 
116
- - It keeps comments, formatting, line endings and key order. In line-based files (INI, TOML) it writes a block between `# >>> depcurfew managed block` and `# <<< depcurfew managed block` markers and comments out older copies of the settings it manages; in YAML it marks the keys it writes with `# managed by depcurfew`; JSON files keep their comments and indentation.
117
- - It never removes settings it does not manage. Allow-lists are only added to; exception lists follow the policy.
118
- - If any file cannot be edited, nothing is written.
119
- - It does not create bot configuration files; it creates a package manager's configuration file when it is missing.
122
+ - It keeps comments, formatting, line endings and key order. In line-based files (INI, TOML) it writes a block between `# >>> depcurfew managed block` and `# <<< depcurfew managed block` markers and comments out older copies of the settings it manages (they come back when the policy stops managing them); in YAML it marks the keys it writes with `# managed by depcurfew`; JSON files keep their comments and indentation.
123
+ - It never removes settings it does not manage. Allow-lists are only added to; exception lists follow the policy, except the entries Renovate adds to pnpm's exception list for security updates, which stay with their comment.
124
+ - When it replaces a longer release-age delay someone set by hand with the policy's shorter one, it warns (`cooldown-shortened`) and names the `cooldown.minimum` that keeps it.
125
+ - If any file cannot be edited, nothing is written. If a file cannot be written, the files already written are put back.
126
+ - It does not create bot configuration files or project manifests (`package.json`, `deno.json`, `pyproject.toml`, `Pipfile`, `requirements.txt`); it creates a package manager's configuration file when it is missing. A package manager seen only in a CI setup step, with nothing of it in the repository, is not configured under `targets: "auto"`.
127
+ - It warns when a file it writes is ignored by git (`.gitignore` or `.git/info/exclude`), because the change would then stay on one machine.
128
+
129
+ ### apply warnings and errors
130
+
131
+ Each warning and error of `apply` has a code. The text output shows it in parentheses after the message, with what to do on the next line, like a doctor finding. `depcurfew apply --json` (also with `--dry-run`) prints one JSON document and nothing on stderr: `changes` (each file with its action and unified diff), `warnings` and `errors` (each with `code`, `level`, `message` and `fix`; `tool` when it concerns one tool; `location` when it concerns one file, with `file` and, when known, `line`; for an invalid policy also `issues`), `snippets` to add by hand, `notices` (such as the parent directory whose `depcurfew.json` was used) and `written`. A run that writes nothing because of an error lists no changes and exits with 1.
132
+
133
+ <!-- BEGIN GENERATED: apply-codes -->
134
+ Warnings:
135
+
136
+ - `nothing-to-configure`: depcurfew found no supported package manager or bot, so nothing is configured.
137
+ - `file-unreadable`: A file that shows which tools a project uses cannot be read or parsed (too large, a symlink out of the repository, no read permission, invalid), so depcurfew may configure fewer tools than the project uses.
138
+ - `tool-not-supported`: A detected tool is not supported (Yarn Classic), so nothing is written for it.
139
+ - `tool-only-in-ci`: A tool appears only in a CI setup step, with no manifest, lockfile or configuration in the repository, so targets "auto" does not configure it.
140
+ - `version-not-pinned`: No exact version of a package manager is pinned, so depcurfew configures for the latest version it knows.
141
+ - `version-too-old`: The pinned version of a tool lacks a setting the policy needs, so that setting is not written.
142
+ - `cooldown-not-written`: The release-age delay cannot be written for a tool.
143
+ - `cooldown-shortened`: A release-age delay set outside depcurfew's markers (in JSON files also one an earlier apply wrote) is longer than the policy, and apply replaces it with the shorter one.
144
+ - `cooldown-environment-only`: pip reads no project configuration, so the release-age delay has to be set in the environment where pip runs.
145
+ - `exclude-pattern-unsupported`: A cooldown exception uses a wildcard the tool does not support, so it is not written.
146
+ - `exclude-unsupported`: The tool has no setting for cooldown exceptions, so the release-age delay applies to every package.
147
+ - `allow-pattern-unsupported`: An installScripts.allow entry is a pattern, but the tool takes package names only, so it is not written.
148
+ - `allow-all-unsupported`: The tool has no setting that allows every install script, so installScripts "allow" is not written.
149
+ - `allow-all-replaced`: A setting that allowed every install script was replaced, because the policy denies install scripts.
150
+ - `allow-list-entry-outside-policy`: An install-script allow-list in the repository lets a package run scripts the policy does not allow; apply does not remove it.
151
+ - `built-in-list-replaced`: Bun's built-in list of trusted packages is replaced by the policy's allow-list.
152
+ - `scripts-not-enforceable`: The pinned npm or pnpm runs every install script and has no allow-list, so "deny" cannot be enforced.
153
+ - `before-overrides-cooldown`: before= in .npmrc takes the place of the release-age delay apply writes, or makes npm stop with an error next to it.
154
+ - `exact-version-gap`: The pinned pnpm skips the release-age delay for packages requested by exact version.
155
+ - `source-not-enforceable`: The tool has no setting for a dependency source the policy denies; doctor checks the lockfile instead.
156
+ - `source-switch-indirect-only`: The pnpm setting for git and tarball sources stops them only for indirect dependencies.
157
+ - `source-switch-combined`: One pnpm setting covers git and tarball sources, so denying one denies both.
158
+ - `forced-source-build`: Python packages on the allow-list are always built from source, because no tool can only allow a build.
159
+ - `build-switch-scope`: The tool's switch forbids building only packages from an index; git, local and archive dependencies are still built.
160
+ - `build-switch-install-only`: Poetry applies its build switch when installing; poetry lock may still build source distributions.
161
+ - `build-switch-environment-only`: The tool has no project setting that forbids building from source, so it has to be set in the environment where the tool runs.
162
+ - `requirements-file-missing`: There is no requirements file to write pip options into.
163
+ - `manifest-missing`: A setting belongs in a project manifest (package.json, deno.json, pyproject.toml, Pipfile) that does not exist, and apply does not create manifests.
164
+ - `lockfile-out-of-date`: The lockfile records, or is checked against, a setting apply changed, so it has to be locked again.
165
+ - `file-ignored-by-git`: A file apply writes matches a .gitignore rule, so the change may never reach the repository.
166
+ - `bot-config-missing`: A bot has no configuration file, and depcurfew does not create one.
167
+ - `bot-config-not-edited`: A bot configuration file is in a place or format depcurfew does not edit; a snippet shows what to add.
168
+ - `bot-entries-missing`: The Dependabot configuration has no entries for the package managers in use.
169
+ - `security-delay-unsupported`: Dependabot cannot delay security updates, so securityUpdates "delay" is not applied.
170
+
171
+ Errors (nothing is written):
172
+
173
+ - `cannot-edit`: A file cannot be read or edited safely (invalid syntax, a symlink, a style depcurfew does not edit), so nothing is written.
174
+ - `cannot-write`: A file cannot be written (no permission, a read-only file system, a full disk, a directory or symlink in its place); the files already written are put back, so nothing changes.
175
+ - `policy-missing`: The directory has no depcurfew.json.
176
+ - `policy-invalid`: depcurfew.json does not follow the schema; issues lists the problems.
177
+ - `policy-unreadable`: depcurfew.json cannot be read.
178
+ - `policy-exists`: depcurfew init found a depcurfew.json and writes it only with --force.
179
+ - `directory-not-found`: The directory given on the command line does not exist or cannot be opened.
180
+ - `not-a-directory`: The path given on the command line is a file, not a directory.
181
+ <!-- END GENERATED: apply-codes -->
120
182
 
121
183
  ## Supported tools
122
184
 
123
- What depcurfew configures and checks for each tool, from its [knowledge base](docs/knowledge.md), where every value links to the official documentation or changelog it was verified against.
185
+ What depcurfew configures and checks for each tool, from its [knowledge base](https://github.com/DevXord/depcurfew/blob/main/docs/knowledge.md), where every value links to the official documentation or changelog it was verified against.
124
186
 
125
187
  <!-- BEGIN GENERATED: tools -->
126
- | Tool | Release-age delay | Exceptions | Install-script allow-list | Dependency sources | Verified |
188
+ | Tool | Release-age delay | Exceptions | Install-script allow-list (Python: packages built from source) | Dependency sources | Verified |
127
189
  | --- | --- | --- | --- | --- | --- |
128
- | npm | `min-release-age` in `.npmrc` (days), since 11.10.0 | `min-release-age-exclude`, since 11.17.0 | `allowScripts` in `package.json` | git: `allow-git`<br>remote tarball: `allow-remote`<br>local tarball: `allow-file`<br>local directory: `allow-directory` | 2026-10-28 – 2026-10-29 |
129
- | pnpm | `minimumReleaseAge` in `pnpm-workspace.yaml` (minutes), since 10.16.0 | `minimumReleaseAgeExclude`, since 10.16.0 | `allowBuilds` in `pnpm-workspace.yaml` | git: `blockExoticSubdeps`<br>remote tarball: `blockExoticSubdeps` | 2026-10-28 – 2026-10-29 |
130
- | Yarn (Berry) | `npmMinimalAgeGate` in `.yarnrc.yml` (minutes), since 4.10.2 | `npmPreapprovedPackages`, since 4.10.0 | `dependenciesMeta.<package>.built` in `package.json` | git: `approvedGitRepositories` | 2026-10-28 – 2026-10-29 |
190
+ | npm | `min-release-age` in `.npmrc` (days), since 11.10.0 | `min-release-age-exclude`, since 11.17.0 | `allowScripts` in `package.json` | git: `allow-git`<br>remote tarball: `allow-remote`<br>local tarball: `allow-file`<br>local directory: `allow-directory` | 2026-10-28 – 2026-10-30 |
191
+ | pnpm | `minimumReleaseAge` in `pnpm-workspace.yaml` (minutes), since 10.16.0 | `minimumReleaseAgeExclude`, since 10.16.0 | `allowBuilds` in `pnpm-workspace.yaml` | git: `blockExoticSubdeps`<br>remote tarball: `blockExoticSubdeps` | 2026-10-28 – 2026-10-31 |
192
+ | Yarn (Berry) | `npmMinimalAgeGate` in `.yarnrc.yml` (minutes), since 4.10.2 | `npmPreapprovedPackages`, since 4.10.0 | `dependenciesMeta.<package>.built` in `package.json` | git: `approvedGitRepositories` | 2026-10-28 – 2026-10-31 |
131
193
  | Bun | `install.minimumReleaseAge` in `bunfig.toml` (seconds), since 1.3.0 | `install.minimumReleaseAgeExcludes`, since 1.3.0 | `trustedDependencies` in `package.json` | none | 2026-10-28 – 2026-10-29 |
132
- | Deno | `minimumDependencyAge` in `deno.json`, `.npmrc` (minutes), since 2.5.5 / 2.6.0 ⚠️ | `minimumDependencyAge.exclude`, since 2.5.5 | `allowScripts` in `deno.json` | none | 2026-10-28 – 2026-10-29 |
133
- | Renovate | `minimumReleaseAge` in `renovate.json`, `renovate.jsonc` … (duration string), since 35.46.0 | `packageRules: matchPackageNames + minimumReleaseAge: null`, since 35.46.0 ❓ | none | n/a | 2026-10-28 |
134
- | Dependabot | `cooldown` in `.github/dependabot.yml`, `.github/dependabot.yaml` (days), since 2025 07 01 | `cooldown.exclude`, since 2025 07 01 ❓ | none | n/a | 2026-10-28 |
135
-
136
- ⚠️ official sources disagree (depcurfew takes the safer reading) · ❓ official sources are incomplete. Every value with its source: [docs/knowledge.md](docs/knowledge.md).
194
+ | Deno | `minimumDependencyAge` in `deno.json`, `.npmrc` (minutes), since 2.5.5 / 2.6.0 ⚠️ | `minimumDependencyAge.exclude`, since 2.5.5 | `allowScripts` in `deno.json` | none | 2026-10-28 – 2026-10-30 |
195
+ | uv | `exclude-newer` in `uv.toml`, `pyproject.toml` (duration string), since 0.9.17 | `exclude-newer-package`, since 0.9.25 | `no-binary-package` in `pyproject.toml` | none | 2026-10-30 |
196
+ | pip | `uploaded-prior-to` on the command line or in the environment (no project file) (days), since 26.1.0 | none | `--no-binary` in `requirements.txt` | none | 2026-10-30 – 2026-10-31 |
197
+ | Poetry | `solver.min-release-age` in `poetry.toml` (days), since 2.4.0 | `solver.min-release-age-exclude`, since 2.4.0 | `installer.no-binary` in `poetry.toml` | none | 2026-10-30 |
198
+ | PDM | `exclude-newer` in `pyproject.toml` (duration string), since 2.26.9 | `exclude-newer-override`, since 2.29.1 | `no-binary` in `pyproject.toml` | none | 2026-10-30 – 2026-10-31 |
199
+ | Pipenv | `cool-down-period` in `Pipfile` (duration string), since 2026.6.2 | none | none | none | 2026-10-30 |
200
+ | Renovate | `minimumReleaseAge` in `renovate.json`, `renovate.jsonc` … (duration string), since 35.46.0 | `packageRules: matchPackageNames + minimumReleaseAge: null`, since 35.46.0 ❓ | none | n/a | 2026-10-28 – 2026-10-30 |
201
+ | Dependabot | `cooldown` in `.github/dependabot.yml`, `.github/dependabot.yaml` (days), since 2025 07 01 | `cooldown.exclude`, since 2025 07 01 ❓ | none | n/a | 2026-10-28 – 2026-10-30 |
202
+
203
+ ⚠️ official sources disagree (depcurfew takes the safer reading) · ❓ official sources are incomplete. Every value with its source: [docs/knowledge.md](https://github.com/DevXord/depcurfew/blob/main/docs/knowledge.md).
137
204
  <!-- END GENERATED: tools -->
138
205
 
139
206
  Yarn Classic (1.x) is detected but not supported.
140
207
 
208
+ ### Python projects
209
+
210
+ depcurfew configures uv, Poetry, PDM, Pipenv and pip from the same `depcurfew.json`, and the bots for Python packages: Dependabot `pip` and `uv` entries and Renovate.
211
+
212
+ - **Detection.** A Python tool counts as used when its lockfile is there, when `pyproject.toml` has its table, or when its own configuration file or a CI setup step shows it; `requirements.txt` means pip. `depcurfew explain` lists what it found.
213
+ - **Package names.** Python packages on the policy's package lists (the cooldown exceptions and `installScripts.allow`) take the prefix `pypi:`, for example `"pypi:docopt"`. Names without a prefix stay npm names, so an exception for an npm package never applies to a Python package of the same name.
214
+ - **Install scripts are builds.** A wheel installs without running package code; a source distribution, a git repository or a local directory is built, which runs its build code. `installScripts.default: "deny"` forbids building, and the packages in `installScripts.allow` are the exceptions. None of the three tools can only allow a build, so these packages are always built from source, even where a wheel exists; `apply` says so, and `doctor` lists the packages in the lockfile that would be built.
215
+ - **pip reads no project configuration.** `apply` writes the build options into `requirements.txt`. The release-age delay cannot live in the project, so `apply` prints the environment variable to set where pip runs. `doctor` also checks the files a requirements file includes with `-r` and `-c`, and reports an include it cannot read.
216
+ - **Lock again after `apply`.** `uv.lock` records the release-age delay, and PDM checks `pdm.lock` against all of its resolution settings, the delay and the build ban included. After `apply` changes them, `uv sync --locked` and `uv lock --check` fail until you run `uv lock`, and `pdm lock --check` and `pdm install --check` until you run `pdm lock`; `apply` says so (`lockfile-out-of-date`). `poetry.lock` and `Pipfile.lock` do not depend on the settings `apply` writes.
217
+ - **PDM and Pipenv cannot pin their own version.** `apply` configures for the latest version depcurfew knows and names that version (`version-not-pinned`). Pipenv takes the delay in whole days only (rounded up), has no exceptions and no project setting that forbids building; `apply` says what to set where Pipenv runs instead. `doctor` reads `pdm.lock` and `Pipfile.lock`, and reports settings that turn the delay or the build ban off without a word: Pipenv's pure-Python resolver and PDM's uv mode.
218
+ - **Hatch has no settings of its own.** Its environments install with uv or pip, so a Hatch project is covered by the uv configuration (add `"uv"` to `targets` when its environments use the uv installer) or by the environment variables of pip.
219
+ - **Running depcurfew.** depcurfew is a Node.js program. In a project without `package.json`, run a pinned version with `npx --yes depcurfew@<version>`; in CI the [GitHub Action](#github-action) needs nothing else.
220
+
141
221
  ## doctor rules
142
222
 
143
223
  Findings have a level: an **error** makes `depcurfew doctor` exit with 1, a **warning** or a **note** does not. Things doctor could not check (a binary lockfile, a lockfile format without install-script data, a missing policy) are listed as notes after the findings, not as findings.
144
224
 
145
225
  <!-- BEGIN GENERATED: rules -->
226
+ ### `invalid-policy`
227
+
228
+ **error** · depcurfew.json does not follow the schema or cannot be read.
229
+
230
+ Without a valid policy, the rules that compare the repository with depcurfew.json cannot run, so doctor runs only the rules that need no policy, as when there is no policy file.
231
+
232
+ Fix: Fix what the message lists; an editor that reads the $schema of depcurfew.json shows the problems as you type.
233
+
146
234
  ### `manager-version-too-old`
147
235
 
148
236
  **error** · A declared package manager version is older than a setting the repository relies on.
@@ -163,7 +251,7 @@ Fix: Move the setting to the place and form this version reads.
163
251
 
164
252
  **error** · An .npmrc file changes a security setting in a way the policy does not see, or is ignored.
165
253
 
166
- Package managers read .npmrc from different places with different priorities. npm ignores the .npmrc of workspace packages, and pnpm 10 applies a root .npmrc value whenever pnpm-workspace.yaml does not set the same setting, which can weaken the policy.
254
+ Package managers read .npmrc from different places with different priorities. npm ignores the .npmrc of workspace packages and the keys below a [section] header, and a before date in .npmrc takes the place of min-release-age; pnpm 10 applies a root .npmrc value whenever pnpm-workspace.yaml does not set the same setting, which can weaken the policy.
167
255
 
168
256
  Fix: Keep security settings out of .npmrc files that are ignored or that override the policy; set them through depcurfew.json and depcurfew apply.
169
257
 
@@ -175,6 +263,14 @@ With sharedWorkspaceLockfile: false, pnpm 10 installs every workspace project se
175
263
 
176
264
  Fix: Remove security settings from package .npmrc files, or keep the default shared lockfile.
177
265
 
266
+ ### `python-config-ignored`
267
+
268
+ **error** · A Python tool ignores a setting where it is written.
269
+
270
+ uv reads uv.toml instead of [tool.uv] when both exist, and in a workspace only the root; pip reads no configuration from the project and rejects options it does not know in requirements files; PDM in uv mode installs without only-binary; Pipenv with resolver_backend = "pure-python" locks without cool-down-period. A setting in such a place looks effective but is not, and an exclude-newer date freezes dependencies instead of delaying new versions.
271
+
272
+ Fix: Move the setting to the file the tool reads.
273
+
178
274
  ### `config-drift`
179
275
 
180
276
  **error** · needs depcurfew.json · A configuration file does not match what depcurfew apply writes for depcurfew.json.
@@ -187,15 +283,15 @@ Fix: Run depcurfew apply (depcurfew apply --dry-run shows the difference), or ch
187
283
 
188
284
  **error** · An update bot waits less than the package manager before proposing a new version.
189
285
 
190
- The bot then opens pull requests with versions the package manager would not pick yet: they fail to install where the manager re-checks the lockfile, or they bring in a version younger than the manager allows. Security updates that skip the bot delay fail the same way where the manager re-checks the lockfile.
286
+ The bot then opens pull requests with versions the package manager would not pick yet: they fail to install where the manager re-checks the lockfile, or they bring in a version younger than the manager allows. Security updates that skip the bot delay fail the same way where the manager re-checks the lockfile. A Dependabot cooldown with an include list delays only the dependencies it names, and a Renovate packageRules entry can shorten the delay for a whole registry or update type.
191
287
 
192
288
  Fix: Give the bot a delay at least as long as the package manager's (depcurfew apply does this).
193
289
 
194
290
  ### `broad-exclusion`
195
291
 
196
- **error** · An exception list matches every package, which turns the protection off.
292
+ **error** · An exception list matches every package, or a per-scope setting shortens the delay, which turns the protection off.
197
293
 
198
- A release-age exception such as "*" (or a policy allow-list entry such as "@*/*") looks like a narrow exception but exempts every package, so the delay or the install-script block never applies.
294
+ A release-age exception such as "*" (or a policy allow-list entry such as "@*/*") looks like a narrow exception but exempts every package, so the delay or the install-script block never applies. The same goes for a Renovate packageRules entry that turns minimumReleaseAge off for a whole datasource, for major, minor or patch updates of every package, or with only negative patterns, which match every package they do not name. In Yarn 4.17 and later, npmScopes.<scope>.npmMinimalAgeGate replaces the delay for one scope, so a shorter value there exempts that scope.
199
295
 
200
296
  Fix: Replace the pattern with the packages or scopes that really need the exception.
201
297
 
@@ -209,11 +305,11 @@ Fix: Replace the dependency with a registry version, or allow that source in dep
209
305
 
210
306
  ### `lockfile-install-scripts`
211
307
 
212
- **error** · needs depcurfew.json · The lockfile has packages with install scripts that depcurfew.json does not allow.
308
+ **error** · needs depcurfew.json · The lockfile has packages with install scripts, or Python packages built from source, that depcurfew.json does not allow.
213
309
 
214
- Install scripts run arbitrary code during installation. Where the package manager runs them by default, these packages execute code the policy does not allow; where it blocks them, they may not work without a build step. Only npm, Bun (1.4.4+) and Deno (lockfile v5) record install scripts in the lockfile.
310
+ Install scripts run arbitrary code during installation, and so does building a Python package from source (a source distribution, a git repository or a local directory). Where the package manager runs them by default, these packages execute code the policy does not allow; where it blocks them, they may not work without a build step. Only npm, Bun (1.4.4+) and Deno (lockfile v5) record install scripts in the lockfile; uv.lock, poetry.lock and pylock.toml show which Python packages have no wheel.
215
311
 
216
- Fix: Remove or replace the package, or add it to installScripts.allow in depcurfew.json after reviewing its scripts.
312
+ Fix: Remove or replace the package, or add it to installScripts.allow in depcurfew.json after reviewing it (Python packages with the prefix pypi:).
217
313
 
218
314
  ### `unreadable-config`
219
315
 
@@ -221,7 +317,7 @@ Fix: Remove or replace the package, or add it to installScripts.allow in depcurf
221
317
 
222
318
  A package manager or bot may still read the file and its settings may weaken the policy; depcurfew fails closed and reports an error instead of passing silently.
223
319
 
224
- Fix: Fix what the message describes: invalid syntax, a symlink, a file over the size limit or a style depcurfew apply cannot edit.
320
+ Fix: Fix what the message describes: invalid syntax, missing read permission, a symlink, a file over the size limit or a style depcurfew apply cannot edit.
225
321
  <!-- END GENERATED: rules -->
226
322
 
227
323
  ## GitHub Action
@@ -241,6 +337,7 @@ on:
241
337
  jobs:
242
338
  doctor:
243
339
  runs-on: ubuntu-latest
340
+ timeout-minutes: 15
244
341
  permissions:
245
342
  security-events: write
246
343
  # Only needed in private repositories:
@@ -258,7 +355,7 @@ jobs:
258
355
  | Input | Default | Description |
259
356
  | --- | --- | --- |
260
357
  | `directory` | `.` | Directory to check, relative to the workspace. |
261
- | `sarif-file` | `depcurfew.sarif` | Where to write the SARIF report, relative to the workspace. |
358
+ | `sarif-file` | `depcurfew.sarif` | Where to write the SARIF report, relative to the workspace; a path outside it works too. |
262
359
  | `upload-sarif` | `true` | Upload the SARIF report to GitHub code scanning. The job needs the security-events write permission. |
263
360
  | `category` | `depcurfew` | Code scanning category of the upload, to tell several depcurfew runs in one workflow apart. |
264
361
  | `fail-on-error` | `true` | Fail the step when doctor reports an error. |
@@ -270,7 +367,7 @@ jobs:
270
367
  | `errors` | Number of findings with level error. |
271
368
  | `warnings` | Number of findings with level warning. |
272
369
  | `notes` | Number of findings with level note. |
273
- | `sarif-file` | Path of the SARIF report, relative to the workspace; empty when doctor could not run. |
370
+ | `sarif-file` | Path of the SARIF report, relative to the workspace when it is inside it, otherwise absolute; empty when doctor could not run or the report could not be written. |
274
371
  <!-- END GENERATED: action-reference -->
275
372
 
276
373
  ### Other CI systems
@@ -289,14 +386,111 @@ depcurfew:
289
386
 
290
387
  `depcurfew doctor --json` and `--sarif` write the findings for other tools; set `FORCE_COLOR=1` if the CI log shows colors.
291
388
 
389
+ ## Guarding installs
390
+
391
+ The configuration `apply` writes is what really protects a project: the package managers themselves wait out the release-age delay and refuse install scripts and sources the policy denies. `depcurfew check` adds a check before something is installed, which matters most for AI coding agents that add packages on their own:
392
+
393
+ ```bash
394
+ npx depcurfew check zod@4 left-pad
395
+ npx depcurfew check pypi:requests "pypi:django>=5.2,<6"
396
+ ```
397
+
398
+ For each package it looks up the npm registry (the one `--registry` or `registry=` in `.npmrc` names, else the public one; any other is named in a note), or PyPI for names with the `pypi:` prefix, and reports:
399
+
400
+ - a name the registry does not know, which is how made-up package names show up;
401
+ - a version younger than the cooldown in `depcurfew.json`, with the newest version that is old enough;
402
+ - install scripts the policy does not allow; for a Python package, a version without wheels, which is built from source and so runs its build code;
403
+ - a name that differs by a letter or two, or only in separators, from a popular package of its registry: 5,000 npm packages with the most weekly downloads among the results of several hundred registry searches (the npm registry has no download ranking, so a popular package can be missing), and the 5,000 most downloaded PyPI projects of a recent month;
404
+ - a deprecated version (a warning);
405
+ - a registry or index reached over plain HTTP (a warning), unless it is on this computer (`localhost`, `127.0.0.0/8` or `::1`), such as a local registry for testing.
406
+
407
+ A registry that redirects to another origin (another host, port or scheme, so also from `http://` to `https://` on the same host), and one at a link-local address, where cloud metadata services answer, is not followed or asked: the package counts as not checked. For a name without a version or with a range, npm prefers the dist-tag `tag=` in `.npmrc` names, and so does `check`.
408
+
409
+ Python packages are written as pip takes them after the prefix (`pypi:name`, `pypi:name==1.2`, `pypi:name[extra]>=1.2,<2`), or as `pypi:name@1.2`, `pypi:name@^1.2` and `pypi:name@latest`, as `uvx` and `poetry add` take them. The version is picked as pip picks it: the newest match, pre-releases only when asked for or when nothing else matches, and yanked versions only when pinned with `==` (a warning). A version is as old as its newest file, because files can be added to a release later. A project PyPI quarantines (as malware, for example) is an error; an archived or deprecated one, a warning. `--index` looks Python packages up in another index that serves the JSON form of the simple repository API.
410
+
411
+ Git repositories, tarball URLs and local paths are checked against the `sources` section only. Without a `depcurfew.json` in the directory or one of its parents up to the root of the repository, the default policy applies. When the registry cannot be reached, the package counts as failed: `check` exits with 1 whenever a package breaks the policy or cannot be checked. With `--json` it prints one document and nothing on stderr: `packages` with their findings (each with `code`, `level`, `message` and `fix`), `notices`, and `errors` for a `depcurfew.json` that cannot be used, in which case no package is checked.
412
+
413
+ ### Claude Code
414
+
415
+ `depcurfew check --hook claude-code` runs as a Claude Code hook before every command of the tools that run shell commands: Bash, PowerShell and Monitor. It finds the packages the command would install or download to run, checks them and answers:
416
+
417
+ - **deny** when a package breaks the policy (Claude sees the reason and can pick another package or version);
418
+ - **ask** when depcurfew cannot vouch for the command: a look-alike name, a registry it cannot reach, an error of its own, or a command it cannot read, such as one with `$(...)` or variables in its arguments, or a shell that runs commands from a pipe (`curl … | sh`);
419
+ - nothing when everything checks out, so the command goes through Claude Code's usual permission prompts.
420
+
421
+ It follows the command lines inside a command: `$(...)` and backticks, `sh -c`, PowerShell's `-Command`, `cmd /c`, `eval`, `npx -c`, `yarn workspace <name>`, `python -m pip`, the command `uv run` runs, a package manager run by `npx`, `uvx` or `pipx run`, and wrappers such as `sudo`, `su -c`, `env`, `timeout`, `flock` and `xargs`. It reads options the way each tool does, including npm's and pnpm's shorthands and abbreviations (`--reg` and `--regis` for `--registry`), abbreviated long options of pip and pipx (`--extra` for `--extra-index-url`) and short options with their value in the same word (`-ihttps://…`), so an option, or a variable such as `PIP_INDEX_URL` or `UV_INDEX`, that points the tool at another index makes it ask. It checks the version the command would install: the dist-tag `--tag` or `npm_config_tag` makes npm prefer, pre-releases that `--pre`, `--prerelease allow` and the like allow, and builds from source that the command's options or variables force (wheels refused), which count as install scripts. A script piped into an interpreter (`curl … | python3`, `irm … | iex`) or read from `<(curl …)` makes it ask, and so does a command with more than 50 packages, of which the first 50 are checked. `deno x` and `dx` are read like `npx`. Packages from requirements files (`pip install -r`) and the project's own files (`uv sync`, `poetry install`) are not checked, as with `npm install` without names; `depcurfew doctor` checks the lockfiles. When it cannot read the hook event at all, it exits with code 2, which blocks the command in every Claude Code version.
422
+
423
+ It reads commands the way Windows runs them too: executables in any case and with `.exe`, `.cmd`, `.bat` or `.ps1` (`NPM.CMD i lodash`), paths with backslashes, and `cmd /c` or `cmd /k` (also `//c` from Git Bash), where `%VAR%` and `!VAR!` count as expansions. PowerShell commands (the PowerShell tool, `powershell -c`, `pwsh -c` and `iex`) are read like any other when they are plain commands: quotes, `;`, `|`, `&&`, the call operator `&`, redirections and `$env:NAME = "value"` before a command. PowerShell syntax it does not read, such as variables, `(...)`, `$(...)`, `{...}`, `@(...)`, backticks, commas, `Start-Process` or `Set-Alias`, makes it ask when the same statement names a package manager; a statement without one, such as `Get-ChildItem | Where-Object { $_.Length -gt 1kb }`, goes through. It also asks about an argument with `&`, `|`, `<`, `>` or `"` for a package manager run from PowerShell, because the `.cmd` shim of a package manager hands its arguments to cmd.exe again.
424
+
425
+ Install depcurfew as a development dependency of the project, then add the hook:
426
+
427
+ <!-- BEGIN GENERATED: claude-code-hook -->
428
+ In `.claude/settings.json` of the project:
429
+
430
+ ```json
431
+ {
432
+ "hooks": {
433
+ "PreToolUse": [
434
+ {
435
+ "matcher": "Bash|PowerShell|Monitor",
436
+ "hooks": [
437
+ {
438
+ "type": "command",
439
+ "command": "node",
440
+ "args": [
441
+ "${CLAUDE_PROJECT_DIR}/node_modules/depcurfew/dist/cli.js",
442
+ "check",
443
+ "--hook",
444
+ "claude-code"
445
+ ],
446
+ "onFailure": "block"
447
+ }
448
+ ]
449
+ }
450
+ ]
451
+ }
452
+ }
453
+ ```
454
+
455
+ The matcher `Bash|PowerShell|Monitor` covers every tool that runs shell commands. On Windows, PowerShell is the main shell wherever the PowerShell tool is on, and without Git Bash there is no Bash tool, so a hook on `Bash` alone never runs there; Monitor runs a command in the background. `command` is `node` itself, which also starts on Windows, where Claude Code runs it without a shell.
456
+
457
+ `onFailure: "block"` needs Claude Code 2.1.295 or later; without it, a hook that fails to start, crashes or times out lets the command through.
458
+
459
+ Commands the guard reads (an add subcommand of any npm package manager, such as `install` or `i`, is checked for all of them; Python commands are matched word for word, and `python -m pip` counts as `pip`):
460
+
461
+ | Package manager | Add packages | Download and run | Starter kits |
462
+ | --- | --- | --- | --- |
463
+ | npm | `npm install`, `npm add`, `npm i`, `npm in`, `npm ins`, `npm inst`, `npm insta`, `npm instal`, `npm isnt`, `npm isnta`, `npm isntal`, `npm isntall`, `npm install-test`, `npm it` | `npx`, `npm exec`, `npm x` | `npm init`, `npm create`, `npm innit` |
464
+ | pnpm | `pnpm add` | `pnx`, `pnpx`, `pnpm dlx` | `pnpm create` |
465
+ | Yarn (Berry) | `yarn add` | `yarn dlx` | `yarn create` |
466
+ | Bun | `bun add` | `bunx`, `bun x` | `bun create` |
467
+ | Deno | `deno add`, `deno install` | `deno x`, `dx`, `denox`, `dnx` | none |
468
+ | uv | `uv add`, `uv pip install`, `uv tool install` | `uvx`, `uv tool run`, `uv run` | none |
469
+ | pip | `pip install`, `pip3 install` | none | none |
470
+ | pipx | `pipx install` | `pipx run` | none |
471
+ | Poetry | `poetry add` | none | none |
472
+ | PDM | `pdm add` | none | none |
473
+ | Pipenv | `pipenv install` | none | none |
474
+ <!-- END GENERATED: claude-code-hook -->
475
+
476
+ The hook reads commands the way a shell splits them, but it is a safety net, not a sandbox: a command can install packages in ways it does not recognize (a script, another tool). Keep the package manager configuration from `depcurfew apply` in place; it is what enforces the policy for every install.
477
+
478
+ ## Network and privacy
479
+
480
+ Only `check` and the Claude Code hook use the network. For each package they request one URL with the package name in it: from the public npm registry (`registry.npmjs.org`) or PyPI (`pypi.org`), or from the registry that the project's or your `.npmrc` sets, `--registry` or `--index`. They send no credentials (tokens in `.npmrc` are not read, and a user name and password written into a registry URL are removed before the request and in every message) and nothing else about the project, and depcurfew has no telemetry. A private package whose scope has no registry in `.npmrc` is looked up in the public registry, so its name reaches that registry; set `@scope:registry` in `.npmrc` or pass `--registry` first. `init`, `explain`, `apply` and `doctor` work without network access, and so does the doctor step of the GitHub Action (the SARIF upload to code scanning is a separate step that runs GitHub's own action). An editor that reads the `$schema` of `depcurfew.json` may download the schema from unpkg.com.
481
+
292
482
  ## Library
293
483
 
294
- The same functions are available from the package: `detectProject`, `planApply` and `applyProject`, `runDoctor` with `toSarif`, and the policy parser and converters. See `src/index.ts`.
484
+ The same functions are available from the package: `detectProject`, `planApply` and `applyProject`, `runDoctor` with `toSarif`, `checkSpecs` with `scanCommandLine`, and the policy parser and converters. Their types ship in `dist/index.d.ts`, and [`src/index.ts`](https://github.com/DevXord/depcurfew/blob/main/src/index.ts) lists every export. The package is an ES module only: use `import`; `require('depcurfew')` works on Node.js 22.12 and later, which load ES modules with `require()`.
295
485
 
296
486
  ## Contributing
297
487
 
298
- Facts about package managers live only in `src/knowledge/`, each with the official URL it was verified against and the date. A correction is welcome with a link to the official documentation or changelog. `npm test` builds the project and runs every test without network access.
488
+ Facts about package managers live only in [`src/knowledge/`](https://github.com/DevXord/depcurfew/tree/main/src/knowledge), each with the official URL it was verified against and the date. A correction is welcome with a link to the official documentation or changelog. `npm test` builds the project and runs every test without network access.
299
489
 
300
490
  ## License
301
491
 
302
- [MIT](LICENSE)
492
+ [MIT](https://github.com/DevXord/depcurfew/blob/main/LICENSE)
493
+
494
+ ## Trademarks
495
+
496
+ npm is a registered trademark of npm, Inc. "Python" and "PyPI" are trademarks of the Python Software Foundation. pnpm, Yarn, Bun, Deno, uv, pip, Poetry, PDM, Pipenv, Renovate, Dependabot, GitHub, Claude Code and the other names in this document belong to their owners. depcurfew is an independent project and is not affiliated with or endorsed by any of them.
package/dist/cli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { A as colorsFor, t as run } from "./run-D7KMlsVh.js";
2
+ import { R as colorsFor, t as run } from "./run-CvdVkFPn.js";
3
3
  // src/cli.ts
4
4
  run(process.argv.slice(2), {
5
5
  stdout: (text) => process.stdout.write(text),
@@ -7,6 +7,10 @@ run(process.argv.slice(2), {
7
7
  colors: {
8
8
  stdout: colorsFor(process.stdout, process.env),
9
9
  stderr: colorsFor(process.stderr, process.env)
10
+ },
11
+ terminal: {
12
+ stdout: process.stdout.isTTY === true,
13
+ stderr: process.stderr.isTTY === true
10
14
  }
11
15
  }).then((code) => {
12
16
  process.exitCode = code;