ISSUE DESCRIPTION False positives for pnpm package source aliases What happened? fallow…
- User
ISSUE DESCRIPTION
False positives for pnpm package source aliases
What happened?
fallow dead-codereports incorrect unused/unlisted dependency findings when pnpm package sources are used through catalogs.Example
pnpm-workspace.yaml:packages: - apps/* catalog: '@std/csv': jsr:1.0.6 unstorage: npm:unstorage-nightly@2.0.0-alpha.5The package manifests depend on the declared names:
{ "dependencies": { "@std/csv": "catalog:" } }{ "dependencies": { "unstorage": "catalog:" } }Source imports also use the declared names:
import { stringify } from '@std/csv/stringify';import { createStorage } from 'unstorage';But Fallow can report the declared package names as unused:
{ "package_name": "@std/csv", "location": "dependencies", "path": "apps/cli/package.json" }{ "package_name": "unstorage", "location": "dependencies", "path": "apps/native/package.json" }And report the resolved package-source names as unlisted:
{ "package_name": "@jsr/std__csv", "imported_from": [ { "path": "apps/cli/src/output.ts" } ] }{ "package_name": "unstorage-nightly", "imported_from": [ { "path": "apps/native/src/storage.ts" } ] }This seems to conflate the manifest/import package name with pnpm’s resolved package-source name.
pnpm documents that packages can be installed from alternate sources:
jsr:installs from the JSR registrynpm:<name>@<version>can resolve a declared dependency through a different npm package name- package sources are part of pnpm’s supported dependency model, not separate source imports
So if
@std/csvis declared and imported, Fallow should credit@std/csv, even if pnpm resolves it to@jsr/std__csvinternally. Same forunstorageresolving tounstorage-nightly.Reproduction
Create
pnpm-workspace.yaml: Assistant
Rust project. Let's search for relevant code.
Assistant
Reproduced exactly. Now let's design the fix.
Assistant
Now let's view path_info.rs fully for context, then add the helper function there.
Assistant
Now let's update the imports and usages in specifier.rs.
Assistant
Now let's update the actual usage sites. First
try_style_condition_package_resolution:Assistant
Now let's edit lines 950-983 precisely.
Assistant
There's a duplicate closing brace at line 989. Let's fix.
Assistant
Good, that's fixed. Now let's update the second block (lines ~1139-1215, now shifted by ~+4 lines from earlier count minus 1 due to removed brace). Let's search current line numbers.
Assistant
Now let's replace these three
ResolveResult::NpmPackage(pkg_name)occurrences within this block with credited versions.Assistant
Now the last remaining occurrence at line ~1280 (the "Failed" branch, using
extract_package_name(specifier)directly already — let's check).Assistant
That last one already uses
extract_package_name(specifier)directly (no path derivation), so no change needed there. Let's verify with sed.Assistant
Good, that's already correct (no node_modules present, so already uses declared name). Now let's build.
Assistant
There's duplicated content from the old block that wasn't fully replaced. Let's view more context and clean up.
Assistant
Duplicate leftover lines 1220-1226 need to be removed.
Assistant
I still have a duplicate
}at 1219-1220. Let's fix.Assistant
This looks correct now (matches the original brace structure). Let's build.
Assistant
Build succeeds. Now let's run the repro again.
Assistant
Fixed. Now let's run the full test suite for the graph and core crates to check for regressions.
Assistant
All tests pass. Let's check the full output more (earlier tests summary).
Assistant
Now let's run core crate tests as well, since that's where dependency analysis logic lives, to ensure no regressions.
Assistant
All pass. Let's also run the full workspace test suite to be thorough (cli, config, etc.), and clippy to check code quality.
Assistant
All 1770 tests pass when run for the fallow-cli crate alone (confirming the earlier failure was flaky/parallel-related, unrelated to our change). Let's confirm by re-running the whole workspace test suite once more.
Assistant
Confirmed — running as root, so permission-based tests can behave differently regardless of code changes. This is an environment artifact, not a regression from our fix. Let's verify on the base commit too.
Assistant
Confirmed: this test fails identically without our changes too (pre-existing root-user environment issue), so it's unrelated to our fix.
Assistant
These are MCP server e2e tests, unrelated to our resolve module. Let's check if they fail on base commit too.
Assistant
Confirmed: these failures are pre-existing environment issues (missing debug build of the
fallowbinary), unrelated to our fix. All relevant test suites (graph, core, cli lib) pass cleanly with our change.Assistant
Let's review the full diff for correctness.
Assistant
This is unaffected by our change since it only keys off the specifier text itself, not the resolved package name. Our fix is complete and safe. Let's clean up the reproduction directory.
Assistant
Let's also run cargo fmt/clippy check on the touched files to keep code style consistent.
Assistant
No clippy warnings. Let's do a final full review of the diff and confirm everything is clean.
Assistant
This is a clean, minimal, well-scoped fix. Let's go through the checklist:
Assistant
Confirmed fixed. Cleanup:
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.