Skip to content

fix(scripts): recognize npm-shrinkwrap.json - #3820

Merged
haelyra merged 1 commit into
affaan-m:mainfrom
shoyann:fix/detect-npm-shrinkwrap
Nov 16, 2026
Merged

haelyra merged 1 commit into
affaan-m:mainfrom
shoyann:fix/detect-npm-shrinkwrap

Conversation

@shoyann

@shoyann shoyann commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

What Changed

Recognize npm-shrinkwrap.json through npm's existing lockFileAliases support.

Why This Change

A project can use npm-shrinkwrap.json instead of package-lock.json. ECC currently misses that lockfile, so a global pnpm preference causes it to select pnpm and recommend pnpm install for an npm project.

This makes shrinkwrap follow the same detection priority as package-lock.json. Explicit project configuration still takes precedence.

Testing Done

  • Added two regression tests: both fail before the fix; all 119 package-manager tests pass afterward.
  • Verified selection over a global pnpm preference, the resulting install command, and the higher priority of an explicit packageManager field.
  • Ran the real npm shrinkwrap --ignore-scripts --offline command in an isolated project; ECC selects npm from the lockfile both before and after conversion.
  • npm test: 8,294 passed, 0 failed across 456 files.
  • Changed-file ESLint: no errors; the test runner retains its complexity warning.
  • Package-manager coverage: 100% statements, branches, functions, and lines.

Type of Change

  • fix: Bug fix

Security & Quality Checklist

  • No secrets or API keys committed; added lines checked.
  • No sensitive data exposed in logs or output.
  • Follows conventional commits format.

@shoyann
shoyann requested a review from affaan-m as a code owner October 30, 2026 13:34
@ecc-tools

ecc-tools Bot commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

ECC Tools / Security Evidence

Commit: f8b9a404363e5a6575b852f81637425d320bd48e

Security evidence gate passed (success)

No security-sensitive scanner-evidence gap detected.

Mode: enforce

Scanned 2 changed file(s). No missing scanner-evidence signal was detected.

Check publication was denied or unavailable. An app owner must enable Checks: read and write, and the installation owner must approve the updated permission.

@ecc-tools

ecc-tools Bot commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

ECC Tools / PR Risk Taxonomy

Commit: f8b9a404363e5a6575b852f81637425d320bd48e

PR taxonomy review recommended (neutral)

Detected 1 PR taxonomy bucket(s): CI/CD Recommendation.

Scanned 2 changed file(s).

Roadmap taxonomy buckets:

CI/CD Recommendation

CI, dependency, coverage, and contract signals should be routed into follow-up checks or verification work.

Signals:

  • 1 CI or workflow path(s) changed

Paths:

  • tests/lib/package-manager.test.js

Check publication was denied or unavailable. An app owner must enable Checks: read and write, and the installation owner must approve the updated permission.

@ecc-tools

ecc-tools Bot commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

ECC Tools / Reference Set Readiness

Commit: f8b9a404363e5a6575b852f81637425d320bd48e

Reference set readiness gaps detected (neutral)

Reference evidence present for 0/7 areas (0%) across 2 changed file(s).

This check is based on files changed in this PR. Repository-level readiness is still reported by /ecc-tools analyze comments and generated manifests.

Area Status Evidence / Next Step
Deep analyzer corpus Missing Add analyzer fixture, golden, benchmark, or reference-set files that can catch analyzer regressions.
RAG/evaluator comparison Missing Add retrieval or evaluator reference-set comparison fixtures with expected ranking behavior.
PR salvage/review corpus Missing Add stale-PR, review-thread, reopen-flow, or salvage reference cases for queue cleanup automation.
Discussion triage corpus Missing Add public discussion triage fixtures, golden cases, or reference sets for informational, answered, and no-response classifications.
Harness compatibility Missing Add cross-harness, adapter-compliance, or harness-audit evidence for Claude, Codex, OpenCode, Zed, dmux, and agent surfaces.
Security evidence Missing Attach security evidence such as SBOMs, SARIF, audit reports, or AgentShield evidence packs.
CI failure-mode evidence Missing Add captured CI failure logs, dry-run fixtures, or troubleshooting docs for common workflow failure modes.

Check publication was denied or unavailable. An app owner must enable Checks: read and write, and the installation owner must approve the updated permission.

@ecc-tools

ecc-tools Bot commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

ECC Tools / Hosted Promotion Readiness

Commit: f8b9a404363e5a6575b852f81637425d320bd48e

Hosted promotion readiness passed (success)

No hosted promotion evidence gaps detected across 2 changed file(s); 0 corpus scenarios had matching evidence.

This check compares PR file changes against the evaluator/RAG promotion corpus in src/analyzers/fixtures/evaluator-rag-corpus.ts.
Hosted output scoring inspected 0 completed cached hosted job results.

No evaluator corpus scenarios matched this PR.

Check publication was denied or unavailable. An app owner must enable Checks: read and write, and the installation owner must approve the updated permission.

@coderabbitai

coderabbitai Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: affaan-m/ECC
  • Branch: main
  • File: .coderabbit.yaml
  • Commit: b38be6a
  • Layers: Repository YAML
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 88202959-df6d-4083-9385-fd7ab0da514c
Commits

Reviewing files that changed from the base of the PR and between b38be6a and f8b9a40.

Files selected for processing: 2
  • scripts/lib/package-manager.js
  • tests/lib/package-manager.test.js

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

Recent review details
Context from checks skipped due to timeout: 2
  • GitHub Check: CodeRabbit
  • GitHub Check: Greptile Review
Additional context used
Code guidelines: 8
.cursor/rules/typescript-security.md — auto-discovered
.cursor/rules/typescript-coding-style.md — auto-discovered
.claude/rules/node.md — auto-discovered
.cursor/rules/common-patterns.md — auto-discovered
.cursor/rules/kotlin-testing.md — auto-discovered
.cursor/rules/python-coding-style.md — auto-discovered
.cursor/rules/swift-patterns.md — auto-discovered
.cursor/rules/common-testing.md — auto-discovered
Path-based instructions: 9
Focus on command injection, unsafe subprocess usage, path traversal, SSRF, secret exposure, and missing tests for new CLI behavior.

CodeRabbit configuration file

Files:

  • scripts/lib/package-manager.js
Source excerpt:

CodeRabbit inference engine (.cursor/rules/typescript-security.md)

Files:

  • scripts/lib/package-manager.js
  • tests/lib/package-manager.test.js
Source excerpt: Use spread operator for immutable updates: Source excerpt: Use async/await with try-catch: Source excerpt: Use Zod for schema-based validation: Source excerpt: No `console.log` statements in production code Source excerpt: U...

CodeRabbit inference engine (.cursor/rules/typescript-coding-style.md)

Files:

  • scripts/lib/package-manager.js
  • tests/lib/package-manager.test.js
Source excerpt: New scripts in `scripts/lib/` require a matching test in `tests/lib/`

CodeRabbit inference engine (.claude/rules/node.md)

Files:

  • scripts/lib/package-manager.js
Source excerpt: Encapsulate data access behind a consistent interface: Define standard operations: findAll, findById, create, update, delete Concrete implementations handle storage details (database, API, file, etc.) Business logic depends...

CodeRabbit inference engine (.cursor/rules/common-patterns.md)

Files:

  • scripts/lib/package-manager.js
  • tests/lib/package-manager.test.js
Source excerpt: Use **Kotest** with spec styles (StringSpec, FunSpec, BehaviorSpec) and **MockK** for mocking.

CodeRabbit inference engine (.cursor/rules/kotlin-testing.md)

Files:

  • scripts/lib/package-manager.js
  • tests/lib/package-manager.test.js
Source excerpt: Follow **PEP 8** conventions Source excerpt: Use **type annotations** on all function signatures Source excerpt: Prefer immutable data structures: Source excerpt: **black** for code formatting Source excerpt: **isort** for i...

CodeRabbit inference engine (.cursor/rules/python-coding-style.md)

Files:

  • scripts/lib/package-manager.js
  • tests/lib/package-manager.test.js
Source excerpt: Define small, focused protocols.

CodeRabbit inference engine (.cursor/rules/swift-patterns.md)

Files:

  • scripts/lib/package-manager.js
  • tests/lib/package-manager.test.js
Source excerpt: Test Types (ALL required): **Unit Tests** - Individual functions, utilities, components **Integration Tests** - API endpoints, database operations **E2E Tests** - Critical user flows (framework chosen per language)

CodeRabbit inference engine (.cursor/rules/common-testing.md)

Files:

  • scripts/lib/package-manager.js
  • tests/lib/package-manager.test.js
ast-grep (0.50.0)
tests/lib/package-manager.test.js

[warning] 122-122: Filesystem path is not a string literal; a request-/variable-derived path can enable path traversal. Validate and normalize the path before use.
Context: fs.writeFileSync(path.join(testDir, 'npm-shrinkwrap.json'), '{}')
Note: [CWE-22] Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal').

(detect-non-literal-fs-filename)

[warning] 318-318: Filesystem path is not a string literal; a request-/variable-derived path can enable path traversal. Validate and normalize the path before use.
Context: fs.writeFileSync(path.join(projectDir, 'npm-shrinkwrap.json'), '{}')
Note: [CWE-22] Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal').

(detect-non-literal-fs-filename)

[warning] 319-319: Filesystem path is not a string literal; a request-/variable-derived path can enable path traversal. Validate and normalize the path before use.
Context: fs.writeFileSync(path.join(projectDir, 'package.json'), '{}')
Note: [CWE-22] Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal').

(detect-non-literal-fs-filename)

[warning] 325-325: Filesystem path is not a string literal; a request-/variable-derived path can enable path traversal. Validate and normalize the path before use.
Context: fs.writeFileSync(path.join(projectDir, 'package.json'), JSON.stringify({ packageManager: 'yarn@4.0.0' }))
Note: [CWE-22] Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal').

(detect-non-literal-fs-filename)

📝 Summary

Summary by CodeRabbit

  • Bug Fixes
    • npm projects using npm-shrinkwrap.json are now correctly detected as npm when no higher-priority lock file is present.
    • Detection respects project configuration and lock-file precedence when choosing an install command.

npm lock-file detection now recognizes npm-shrinkwrap.json. Tests cover direct detection and precedence relative to a saved package-manager preference and an explicit packageManager field.

Changes: npm Shrinkwrap Detection

Layer / File(s) Summary
Shrinkwrap detection and precedence
scripts/lib/package-manager.js, tests/lib/package-manager.test.js
The npm configuration recognizes npm-shrinkwrap.json as a lock-file alias. Tests verify direct detection, selection over a saved pnpm preference, and precedence of an explicit packageManager field.

Priority: Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Possibly related PRs

  • affaan-m/ECC#3806: Adds isolated-home tests for saved package-manager preferences in the same test area.

Suggested reviewers: affaan-m

Merge Risk: Minimal · up to f8b9a

The change is mergeable with no supported current-head risk identified.

Pre-merge checks: Passed 5
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: recognizing npm-shrinkwrap.json as an npm lockfile.
Description check Passed The description directly explains the lockfile detection change, its purpose, precedence behavior, and regression testing.
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 1 functions across 2 files.

Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@greptile-apps

greptile-apps Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] Safe to merge within the reviewed scope. Shrinkwrap selects npm ahead of a global preference without overriding explicit project settings.

Summary

Adds npm-shrinkwrap.json as an npm lockfile alias.

  • Projects with npm-shrinkwrap.json are detected as npm projects.

No actionable issues found. The change is safe to merge within the reviewed scope.

T-Rex validation blocked

Evidence upload only: execution completed, but no artifact-upload facility, upload endpoint, or publication credentials were available, including on retry. Executed sources and captured output remain local; no uploaded evidence references are available.

Reviews (1) · Last reviewed commit: "fix(scripts): recognize npm-shrinkwrap.j..." · Reviewed by Greptile

@coderabbitai coderabbitai Bot mentioned this pull request Nov 3, 2026
6 of 26 tasks
@contacto332

Copy link
Copy Markdown

Thanks for the reviews. Here's how I've handled each automated report on f8b9a404:

  • Greptile (5/5, no actionable issues): Nothing to change.
  • CodeRabbit (no actionable comments): Nothing to change. The four ast-grep detect-non-literal-fs-filename (CWE-22) warnings in tests/lib/package-manager.test.js are false positives, so I'm leaving them as they are. Each path is path.join() of a temp directory the test creates (createTestDir() / withIsolatedHome) and a hard-coded filename (npm-shrinkwrap.json, package.json). No request or user input reaches these paths. The existing lockfile tests in this file use the same pattern.
  • ECC Tools / Security Evidence and Hosted Promotion Readiness: Both passed. No action needed.
  • ECC Tools / PR Risk Taxonomy (CI/CD bucket): This flags tests/lib/package-manager.test.js as a CI/workflow path, but it is a unit test file. No workflow or CI configuration changed, so there's nothing to follow up.
  • ECC Tools / Reference Set Readiness (0/7, neutral): The areas it lists (analyzer corpus, RAG, harness compatibility, and so on) don't apply to a one-line lockfile alias. The change is covered by two regression tests instead, so I'm not adding reference-set artifacts here.

I re-ran node tests/lib/package-manager.test.js on the current head: 119 passed, 0 failed. No code changes were needed, and there are no inline review threads left to resolve.

@haelyra
haelyra merged commit ee1ec55 into affaan-m:main Nov 16, 2026
4 checks passed
@haelyra

haelyra commented Nov 16, 2026

Copy link
Copy Markdown
Collaborator

Thank you for contributing fix(scripts): recognize npm-shrinkwrap.json. Your complete reviewed head is preserved with attribution in maintainer integration #3945.

The delivered main commit now passes CI, CodeQL and a fresh Supply-Chain Watch after the focused coverage-report and dependency recovery in #3947. We appreciate your patience and your help improving ECC.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants