Repository navigation
Description
Problem
Repository commands can fail with misleading compiler or runtime errors when an existing node_modules tree predates package.json or package-lock.json changes.
Observed in the current checkout:
node_moduleswas last updated on July 13;@types/semverwas added on July 14;package-lock.jsonchanged again on July 16;- the installed MCP client/server SDKs were
2.0.0-beta.3, while the repository requires2.0.0-beta.4; @types/[email protected]was declared in both package and lock files but absent locally;npm ls --depth=0reported missing, invalid-version, and extraneous dependencies.
npm run build then failed at Upgrade.ts with a missing semver declaration error. The declaration was not missing from the repository; the local installation was stale. This can misdirect maintainers and agents into changing correct source or dependency declarations.
Expected behavior
Developer verification commands should detect an out-of-sync dependency tree before compilation and print one exact remediation:
Installed dependencies do not match package-lock.json. Run `npm ci`, then retry.
The check must be non-mutating. build, test, and check must not automatically run npm ci or otherwise install dependencies.
Automatic refresh would be inappropriate because it can:
- delete and recreate
node_modules; - require network access;
- execute dependency lifecycle scripts;
- mutate a workspace during an otherwise local build;
- make builds slower and less deterministic;
- recurse through npm lifecycle hooks such as
prepare.
Design direction
Add a lightweight repository-owned dependency-state preflight. Possible implementations include:
- compare a deterministic lockfile digest recorded after successful installation;
- compare root package requirements with installed package identities without network access;
- wrap an npm-provided local-tree check while normalizing its output to one concise remediation.
Avoid relying only on mtimes: branch switches, rebases, archives, and restored caches can preserve misleading timestamps. Avoid treating every optional transitive package as a root mismatch.
The check should distinguish:
- missing required root dependency;
- installed root version different from the lockfile;
- stale lock/install identity;
- harmless optional/transitive state that does not invalidate the repository environment.
Acceptance criteria
- A missing required dependency is detected before TypeScript compilation.
- An installed root dependency at the wrong version is detected before tests or runtime verification.
- The failure names
npm cias the exact remediation. - The preflight does not access the network or mutate
node_modules, package files, hooks, or generated output. - A dependency name or version mismatch is reported without dumping unrelated package-tree noise.
- A clean
npm ciinstallation passes the preflight. - Tests cover missing, wrong-version, stale-lock, aligned, optional, and extraneous-only cases.
- CI still installs with
npm ci; the preflight is not treated as a replacement for installation. - Contributor documentation explains that pulling lockfile changes requires rerunning
npm ci. - Packaged consumer commands do not depend on repository-only lockfile state.
Non-goals
- Automatically installing or upgrading dependencies from build/test commands.
- Committing
node_modules. - Replacing
npm ciin CI or clean-checkout setup. - Rejecting harmless package-manager implementation details that do not alter required root dependencies.
Relationship
The stale local SDK means exact serialized MCP schema-size measurements in #264 should be refreshed after an aligned npm ci; the source-level contract findings remain independently valid.
Activity
morluto commentedon Jul 16, 2026
Dependency-freshness slice implemented: network-free deps:check compares every direct production/dev package version in package-lock.json with node_modules/.package-lock.json, ignores unrelated extraneous/transitive state, and emits one npm ci remediation. It runs before build/check/pack/publish; tests cover aligned, wrong-version, missing direct dev dependency, and extraneous-only installs.