Diff two package.json/lockfile snapshots
diff_dependenciesCompare two snapshots of a package.json, package-lock.json (v1-v3), yarn.lock (classic or Berry) or pnpm-lock.yaml (e.g. before/after a PR; formats can differ) and report added, removed and changed packages. Lockfiles cover the full resolved graph, so transitive-only changes are caught; npm aliases are followed (actualName). Up to 100 added/changed packages are checked in detail. Ideal for a CI gate.
Per added/changed package:
installScriptIntroduced: a preinstall/install/postinstall script the old version lacked — the shape of a compromised-maintainer release.preparenever runs on a registry install, so it is excluded;installScriptKeysIntroducedlists every new key, prepare included.sourceIntegrityChanged: the same version now resolves to a different tarball URL or hash, or a bump moved to another host (ordinary bumps are not flagged). A same-version swap ischangeType: "source-swap".identityMismatch: the tarball is a different package or version than declared;tarballName/tarballVersionsay what really installs, and the vulnerability fields describe that.vulnerabilityDelta(introduced/fixed/still-vulnerable/still-clean) plus the findings, each with isMalware.
Project-level: projectLifecycleChanges diffs the project's own root install scripts (package.json only; a PR that only adds a root postinstall changes no dependency), and overridesChanges diffs overrides/resolutions/pnpm.overrides, from package.json or between two pnpm-lock.yaml files (removing one can let a vulnerable version back in). Both count toward flaggedCount. Read comparisonNote when the two snapshots differ in format. Install-script checks are presence-only; use analyze_install_script to see what a script does.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| after | Yes | Raw file content of the "after" snapshot — a package.json, package-lock.json (npm v1-v3), yarn.lock (classic v1 or Berry), or pnpm-lock.yaml. Format is auto-detected; before/after may be different formats. | |
| before | Yes | Raw file content of the "before" snapshot — a package.json, package-lock.json (npm v1-v3), yarn.lock (classic v1 or Berry), or pnpm-lock.yaml. Format is auto-detected; before/after may be different formats. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| added | Yes | ||
| changed | Yes | ||
| removed | Yes | ||
| summary | Yes | ||
| truncated | Yes | ||
| totalAdded | Yes | ||
| afterFormat | Yes | ||
| beforeFormat | Yes | ||
| flaggedCount | Yes | ||
| totalChanged | Yes | ||
| totalRemoved | Yes | ||
| comparisonNote | Yes | ||
| enrichmentNote | Yes | ||
| truncationNote | Yes | ||
| overridesChanges | Yes | ||
| projectLifecycleChanges | Yes |