Repository navigation
feat(napi): pass the resolved directory to the readPackage hook - #12936
Conversation
A host that pre-transforms its in-memory project manifests (Bit strips workspace-sibling deps from importer manifests because it wires those links itself) loses the raw manifest by the time the engine resolves the same project as an injected "file:" dependency — the instance then drops deps the host meant to keep, and Bit's component dependency graph loses its component edges. pnpm's TS engine avoids this by keeping raw project manifests and applying the host's hook chain contextually (with the project dir for the importer view, without it for dependency manifests). Give the node-API host the same discrimination: HookContext now carries the lockfile-root-relative directory of a directory resolution, and the napi bridge forwards it as the JS callback's second argument — `(manifest, resolvedDir?) => manifest` — via FnArgs (a bare tuple would serialize into a single JSON array argument). Registry and other non-directory resolutions pass no directory. The `.pnpmfile.cjs` bridge deliberately does not expose it: pnpm's pnpmfile `readPackage(pkg, context)` contract has no directory either. Co-Authored-By: Claude Fable 5 <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
🚧 Files skipped from review as they are similar to previous changes (4)
📝 WalkthroughWalkthrough
ChangesReadPackage resolved-directory flow
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant Resolver
participant HookAdapter
participant JavaScriptHook
Resolver->>HookAdapter: readPackage(manifest, HookContext)
HookAdapter->>JavaScriptHook: (manifest, resolvedDir?)
JavaScriptHook-->>HookAdapter: transformed manifest
HookAdapter-->>Resolver: transformed manifest
Possibly related PRs
Suggested labels: Suggested reviewers: ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
PR Summary by Qodofeat(napi): pass resolved directory to readPackage hook
AI Description
Diagram
High-Level Assessment
Files changed (9)
|
Confidence Score: 5/5Small, additive, backward-compatible change — all callsites updated, the one live path gated on LockfileResolution::Directory, and both bridges receive the correct contract. Safe to merge. All HookContext construction sites compile against the new field. The test pins the exact contract for both directory and registry resolutions. The pnpmfile worker bridge correctly excludes dir from the context it passes to JS hooks. No logic regressions introduced. No files require special attention. Reviews (2): Last reviewed commit: "fix(pacquet): satisfy rustfmt/clippy and..." | Re-trigger Greptile |
Code Review by Qodo
Context used✅ Compliance rules (platform):
18 rules 1.
|
There was a problem hiding this comment.
🧹 Nitpick comments (1)
pnpm/crates/hooks/src/lib.rs (1)
34-43: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueTrim TS engine implementation detail from the
dirrustdoc.Lines 39-40 ("pnpm's TS engine reaches the same effect by keeping raw project manifests and applying its hook chain contextually") describe how the TypeScript pnpm engine works internally. Per the coding guidelines, comments should avoid describing past implementation history, and per
CODE_STYLE_GUIDE.md, doc comments should state the contract once. The contract is already fully covered by the surrounding text (whatdiris, when it's set, how hosts use it, and the.pnpmfile.cjsexception).♻️ Proposed refactor
pub struct HookContext { pub log: Arc<dyn Fn(String) + Send + Sync>, /// Lockfile-root-relative directory of the resolution, set when the /// manifest being transformed was resolved from a local directory (an /// injected workspace project or a `file:` dependency). A host-supplied /// `readPackage` callback uses it to recognize a workspace project's /// dependency instance and substitute the project's raw manifest. - /// — pnpm's TS engine reaches the same effect by keeping raw project - /// manifests and applying its hook chain contextually. Only the - /// node-API bridge forwards it to JS; the `.pnpmfile.cjs` contract - /// (`readPackage(pkg, context)`) has no directory, matching pnpm. + /// Only the node-API bridge forwards it to JS; the `.pnpmfile.cjs` + /// contract (`readPackage(pkg, context)`) has no directory, matching pnpm. pub dir: Option<String>, }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@pnpm/crates/hooks/src/lib.rs` around lines 34 - 43, Trim the rustdoc on the dir field by removing the sentence describing the TypeScript pnpm engine’s internal implementation. Preserve the remaining contract documentation covering what dir represents, when it is set, host usage, and the .pnpmfile.cjs exception.Sources: Coding guidelines, Path instructions
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@pnpm/crates/hooks/src/lib.rs`:
- Around line 34-43: Trim the rustdoc on the dir field by removing the sentence
describing the TypeScript pnpm engine’s internal implementation. Preserve the
remaining contract documentation covering what dir represents, when it is set,
host usage, and the .pnpmfile.cjs exception.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 0b02bde5-2c10-4aa4-9344-c1d0db364f1f
⛔ Files ignored due to path filters (1)
Cargo.lockis excluded by!**/*.lock,!Cargo.lock
📒 Files selected for processing (9)
pnpm/crates/cli/src/config_deps.rspnpm/crates/hooks/src/lib.rspnpm/crates/hooks/tests/node_hooks.rspnpm/crates/napi/src/hooks.rspnpm/crates/package-manager/src/install_with_fresh_lockfile.rspnpm/crates/resolving-deps-resolver/Cargo.tomlpnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree.rspnpm/crates/resolving-deps-resolver/src/tests.rspnpm/npm/napi/index.d.ts
PR Code Suggestions ✨Warning
Explore these optional code suggestions:
|
|||||||||
Micro-Benchmark ResultsLinux |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #12936 +/- ##
==========================================
+ Coverage 85.45% 85.58% +0.12%
==========================================
Files 474 475 +1
Lines 74555 74718 +163
==========================================
+ Hits 63714 63945 +231
+ Misses 10841 10773 -68 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Integrated-Benchmark Report (Linux)Commit: Each scenario reports direct installs and pnpr installs. Bencher consumes pacquet@HEAD and pnpr@HEAD. Scenario: Isolated linker: fresh restore, cold cache + cold store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 4.136408743740001,
"stddev": 0.13747459863330458,
"median": 4.173516725040001,
"user": 3.9348695399999998,
"system": 3.4413608599999996,
"min": 3.9138196455400003,
"max": 4.29322921254,
"times": [
4.29322921254,
4.03294013854,
4.26495412454,
4.19650806154,
4.25541325754,
4.04651421554,
4.24776147454,
3.96242191854,
3.9138196455400003,
4.15052538854
]
},
{
"command": "pacquet@main",
"mean": 4.102285383540001,
"stddev": 0.19623251727248697,
"median": 4.02671345204,
"user": 3.9431406399999993,
"system": 3.4577708599999992,
"min": 3.90948433854,
"max": 4.45982977254,
"times": [
4.01803841354,
4.2567773755400005,
4.03538849054,
4.21086087454,
3.95760154954,
3.90948433854,
3.91764194854,
4.45982977254,
3.9312424735400002,
4.32598859854
]
},
{
"command": "pnpr@HEAD",
"mean": 2.2070192983399997,
"stddev": 0.1690960294058743,
"median": 2.19036619404,
"user": 2.76075284,
"system": 2.93339146,
"min": 2.01208695454,
"max": 2.47236287554,
"times": [
2.34872973854,
2.06258801254,
2.32396018854,
2.10781066154,
2.37561345654,
2.01208695454,
2.27292172654,
2.06340478954,
2.47236287554,
2.03071457954
]
},
{
"command": "pnpr@main",
"mean": 2.19253876794,
"stddev": 0.13318162814160392,
"median": 2.13187647604,
"user": 2.7536162400000004,
"system": 2.9553527599999994,
"min": 2.03464903754,
"max": 2.38164992954,
"times": [
2.06689395954,
2.15167943954,
2.38164992954,
2.10619471454,
2.37784194054,
2.30406067554,
2.2970780465400003,
2.11207351254,
2.09326642354,
2.03464903754
]
}
]
}Scenario: Isolated linker: fresh restore, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.6573994377600001,
"stddev": 0.013622832495791938,
"median": 0.66279410866,
"user": 0.38723904,
"system": 1.3383877800000001,
"min": 0.63179356266,
"max": 0.67405677866,
"times": [
0.64115891166,
0.63179356266,
0.66167492766,
0.6626302966600001,
0.6640466056600001,
0.66547482166,
0.66686556766,
0.67405677866,
0.66295792066,
0.64333498466
]
},
{
"command": "pacquet@main",
"mean": 0.67287311266,
"stddev": 0.035888668831177015,
"median": 0.66204734266,
"user": 0.40337123999999996,
"system": 1.33347788,
"min": 0.63232365566,
"max": 0.76248854566,
"times": [
0.6576930816600001,
0.68106353966,
0.64806237166,
0.63232365566,
0.65224679066,
0.65914228966,
0.68271735966,
0.6649523956600001,
0.76248854566,
0.68804109666
]
},
{
"command": "pnpr@HEAD",
"mean": 0.74440344376,
"stddev": 0.04772971150780814,
"median": 0.72853049916,
"user": 0.4039062400000001,
"system": 1.40085598,
"min": 0.6994629196600001,
"max": 0.8658004796600001,
"times": [
0.71679085866,
0.72801856266,
0.71748920366,
0.6994629196600001,
0.73652961266,
0.7184748496600001,
0.8658004796600001,
0.77210341066,
0.72904243566,
0.76032210466
]
},
{
"command": "pnpr@main",
"mean": 0.7668553078599999,
"stddev": 0.09532904453263889,
"median": 0.74135894016,
"user": 0.42055944,
"system": 1.41585188,
"min": 0.6977222576600001,
"max": 1.02699184766,
"times": [
0.7467701276600001,
0.75274237066,
0.76455697166,
0.73594775266,
0.73333867066,
0.6977222576600001,
0.7167445196600001,
0.78774564966,
1.02699184766,
0.70599291066
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + cold store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 4.37163300714,
"stddev": 0.06580030059006803,
"median": 4.3723859130400005,
"user": 3.8993290000000003,
"system": 3.3573010400000003,
"min": 4.27832394904,
"max": 4.47664849504,
"times": [
4.41963004804,
4.47664849504,
4.37955283704,
4.27832394904,
4.29955243604,
4.41497680204,
4.36521898904,
4.30592271904,
4.33885456304,
4.43764923304
]
},
{
"command": "pacquet@main",
"mean": 4.31205193654,
"stddev": 0.04913226680732316,
"median": 4.30165224154,
"user": 3.8639316,
"system": 3.34188404,
"min": 4.26050883804,
"max": 4.40755703104,
"times": [
4.26337056004,
4.26050883804,
4.40755703104,
4.30421486204,
4.29495498704,
4.27061863704,
4.38360207104,
4.32672836304,
4.3098743950400005,
4.29908962104
]
},
{
"command": "pnpr@HEAD",
"mean": 2.21588217094,
"stddev": 0.12849291000975613,
"median": 2.17377365354,
"user": 2.5989671000000003,
"system": 2.87251004,
"min": 2.06686546404,
"max": 2.42563082604,
"times": [
2.06686546404,
2.18664148104,
2.22741832304,
2.13855190804,
2.38316412104,
2.10710431204,
2.35798491304,
2.42563082604,
2.16090582604,
2.10455453504
]
},
{
"command": "pnpr@main",
"mean": 2.22423291524,
"stddev": 0.14554709876151223,
"median": 2.19656936104,
"user": 2.5991935000000006,
"system": 2.87433744,
"min": 2.03944916604,
"max": 2.48570264804,
"times": [
2.15551663004,
2.37107702104,
2.34237179604,
2.03944916604,
2.12148062104,
2.29029367604,
2.48570264804,
2.23762209204,
2.12802837904,
2.07078712304
]
}
]
}Scenario: Isolated linker: fresh install, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 1.4256090577,
"stddev": 0.03215252366032874,
"median": 1.4168212479,
"user": 1.36357988,
"system": 1.7387381599999998,
"min": 1.3842780044,
"max": 1.4835256444,
"times": [
1.4835256444,
1.4506787764,
1.4569180663999999,
1.4229715024,
1.4458677994,
1.3937427564,
1.4067483194,
1.3842780044,
1.4106709934,
1.4006887144
]
},
{
"command": "pacquet@main",
"mean": 1.4409634936000002,
"stddev": 0.037302219260985654,
"median": 1.4455046773999998,
"user": 1.4114177799999998,
"system": 1.7223012599999996,
"min": 1.3793615844,
"max": 1.5086275454,
"times": [
1.4747932534,
1.5086275454,
1.4542480654,
1.4156690704,
1.4504207524,
1.3793615844,
1.4208164323999999,
1.4046958444,
1.4405886023999999,
1.4604137853999999
]
},
{
"command": "pnpr@HEAD",
"mean": 0.6715345442,
"stddev": 0.00760377737901843,
"median": 0.6715633679000002,
"user": 0.34298298000000005,
"system": 1.27365736,
"min": 0.6585460414000001,
"max": 0.6826972994000001,
"times": [
0.6751325124,
0.6679937164,
0.6798261674000001,
0.6769187714000001,
0.6826972994000001,
0.6711319814000001,
0.6695440694000001,
0.6719947544000001,
0.6585460414000001,
0.6615601284000001
]
},
{
"command": "pnpr@main",
"mean": 0.6836771249000002,
"stddev": 0.012399440426994294,
"median": 0.6842068504000001,
"user": 0.35795878000000003,
"system": 1.29766776,
"min": 0.6626586664000002,
"max": 0.7071330944,
"times": [
0.6841777964000001,
0.6793181794,
0.6777348444000001,
0.6911040634000001,
0.6937103374000001,
0.6862322094000001,
0.7071330944,
0.6842359044000002,
0.6626586664000002,
0.6704661534
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 3.1250486810199996,
"stddev": 0.04873658528682151,
"median": 3.1136300494199998,
"user": 1.8145338600000003,
"system": 2.0275327399999994,
"min": 3.0604621424199996,
"max": 3.1987313984199996,
"times": [
3.1926962884199996,
3.0604621424199996,
3.1143776114199997,
3.09504254142,
3.0644896334199996,
3.11288248742,
3.1352487014199997,
3.1692360804199997,
3.1073199254199997,
3.1987313984199996
]
},
{
"command": "pacquet@main",
"mean": 3.1445634501199997,
"stddev": 0.07136812391532943,
"median": 3.1452746764199997,
"user": 1.8626192599999996,
"system": 2.01861244,
"min": 3.0447261654199997,
"max": 3.2945038644199998,
"times": [
3.2945038644199998,
3.20014482542,
3.0745358914199996,
3.0447261654199997,
3.09948715042,
3.1618310954199997,
3.17726846942,
3.1344284004199996,
3.15612095242,
3.1025876864199997
]
},
{
"command": "pnpr@HEAD",
"mean": 0.6751782264200001,
"stddev": 0.010550368082863306,
"median": 0.6774107649200001,
"user": 0.34122076,
"system": 1.2867403400000001,
"min": 0.6577303254200001,
"max": 0.6857707164200001,
"times": [
0.67000034042,
0.68533878142,
0.6821405314200001,
0.6625585954200001,
0.68421791342,
0.6845868044200001,
0.6857707164200001,
0.6726809984200001,
0.6577303254200001,
0.66675725742
]
},
{
"command": "pnpr@main",
"mean": 0.6939635740199999,
"stddev": 0.017856412997058695,
"median": 0.68885903642,
"user": 0.37172816,
"system": 1.2935088399999999,
"min": 0.6807937634200001,
"max": 0.73903369442,
"times": [
0.6807937634200001,
0.6953330724200001,
0.6921278094200001,
0.6922762424200001,
0.68232470842,
0.68235121342,
0.6855902634200001,
0.6823600484200001,
0.7074449244200001,
0.73903369442
]
}
]
}Scenario: Isolated linker: fresh resolve, hot cache, offline
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.7121171958200001,
"stddev": 0.016104394015990082,
"median": 0.71199371322,
"user": 0.66531422,
"system": 0.1604266,
"min": 0.68859340422,
"max": 0.73887892022,
"times": [
0.7130837762200001,
0.69773140922,
0.71090365022,
0.68859340422,
0.69287379922,
0.7263009462200001,
0.71429739922,
0.73887892022,
0.72866520922,
0.70984344422
]
},
{
"command": "pacquet@main",
"mean": 0.73337844162,
"stddev": 0.01960075097639537,
"median": 0.73308949372,
"user": 0.6886043199999999,
"system": 0.1583428,
"min": 0.69911847222,
"max": 0.75961416922,
"times": [
0.69911847222,
0.71500585522,
0.73124275322,
0.74191197222,
0.75961416922,
0.73493623422,
0.74921282722,
0.7572420562200001,
0.7146210992200001,
0.7308789772200001
]
},
{
"command": "pnpr@HEAD",
"mean": 0.11213991834499999,
"stddev": 0.0006902886851278272,
"median": 0.11216559322000001,
"user": 0.027797561666666665,
"system": 0.02258755833333333,
"min": 0.11054965322000002,
"max": 0.11340190722000001,
"times": [
0.11132951222000001,
0.11054965322000002,
0.11310016222000001,
0.11193257422000001,
0.11149256522,
0.11215531422000001,
0.11198448522000001,
0.11301070222000001,
0.11179355922000002,
0.11270589522000002,
0.11246290122000001,
0.11185524222000001,
0.11204382422000002,
0.11265147422000002,
0.11242169922000002,
0.11236051822000001,
0.11217587222000001,
0.11340190722000001,
0.11287966622000001,
0.11076960622000001,
0.11238554622000001,
0.11164327422000002,
0.11176822222000002,
0.11248386322000001
]
},
{
"command": "pnpr@main",
"mean": 0.11215088109500003,
"stddev": 0.0010775095026914494,
"median": 0.11207094022000001,
"user": 0.027744061666666663,
"system": 0.022898016666666663,
"min": 0.10987917422000001,
"max": 0.11464250522000001,
"times": [
0.11181111622,
0.11166529822000001,
0.11245673322000001,
0.11210131122000001,
0.11204056922000001,
0.11278784822000001,
0.11194717922000001,
0.10997170222000001,
0.11212076022000002,
0.11191374922000001,
0.11278158822,
0.11303305522000001,
0.11330628522000001,
0.11114540422000001,
0.11130652122000001,
0.11225158622000002,
0.11177035522000002,
0.11175783622000002,
0.11276233522000001,
0.11391967322000002,
0.11123716722000002,
0.11301139222,
0.11464250522000001,
0.10987917422000001
]
}
]
}Scenario: Isolated linker: fresh restore, cold cache + cold store + cold pnpr
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 6.820363642779999,
"stddev": 0.1368933937185568,
"median": 6.83236407908,
"user": 4.11505906,
"system": 3.66898866,
"min": 6.64287777908,
"max": 7.107051243080001,
"times": [
6.64287777908,
6.87663521508,
7.107051243080001,
6.86134430608,
6.888701144080001,
6.81350972608,
6.8160741830800005,
6.705791392080001,
6.6429974640800005,
6.84865397508
]
},
{
"command": "pacquet@main",
"mean": 6.8305896732799996,
"stddev": 0.09655098452688392,
"median": 6.81919125808,
"user": 4.1073673600000005,
"system": 3.6874810600000005,
"min": 6.669606644080001,
"max": 6.993976984080001,
"times": [
6.96644059808,
6.85597647308,
6.993976984080001,
6.669606644080001,
6.739392581080001,
6.85242234008,
6.78482163608,
6.80543186908,
6.8048769600800005,
6.8329506470800006
]
},
{
"command": "pnpr@HEAD",
"mean": 4.961797213780001,
"stddev": 0.10627476568034148,
"median": 4.93968939358,
"user": 2.87964656,
"system": 3.13705106,
"min": 4.818770128080001,
"max": 5.11831793208,
"times": [
4.926239216080001,
4.818770128080001,
5.1168242600800005,
4.95313957108,
4.83901125008,
5.03233221208,
4.90595988208,
5.017012855080001,
5.11831793208,
4.89036483108
]
},
{
"command": "pnpr@main",
"mean": 5.099629034980001,
"stddev": 0.17772349955125455,
"median": 5.057052946580001,
"user": 2.89145466,
"system": 3.13789586,
"min": 4.842642152080001,
"max": 5.36786718108,
"times": [
5.280128767080001,
4.95589652708,
5.161224601080001,
4.9590918330800005,
4.987083330080001,
5.07865567708,
5.328250065080001,
4.842642152080001,
5.03545021608,
5.36786718108
]
}
]
} |
|
| Branch | pr/12936 |
| Testbed | pnpr |
⚠️ WARNING: No Threshold found!Without a Threshold, no Alerts will ever be generated.
Click here to create a new Threshold
For more information, see the Threshold documentation.
To only post results if a Threshold exists, set the--ci-only-thresholdsflag.
Click to view all benchmark results
| Benchmark | Latency | milliseconds (ms) |
|---|---|---|
| isolated-linker.fresh-install.cold-cache.cold-store | 📈 view plot | 2,215.88 ms |
| isolated-linker.fresh-install.cold-cache.hot-store | 📈 view plot | 675.18 ms |
| isolated-linker.fresh-install.hot-cache.hot-store | 📈 view plot | 671.53 ms |
| isolated-linker.fresh-resolve.hot-cache.offline | 📈 view plot | 112.14 ms |
| isolated-linker.fresh-restore.cold-cache.cold-store | 📈 view plot | 2,207.02 ms |
| isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr | 📈 view plot | 4,961.80 ms |
| isolated-linker.fresh-restore.hot-cache.hot-store | 📈 view plot | 744.40 ms |
cargo fmt over the HookContext call sites, a type alias for the recorded-calls Arc to satisfy clippy::type_complexity, and doc-comment trims from review: drop the TS-engine rationale from the HookContext.dir rustdoc and shrink the resolver test's doc comment to the non-obvious why. Co-Authored-By: Claude Fable 5 <[email protected]>
|
Code review by qodo was updated up to the latest commit d94a68a |
PR Code Suggestions ✨Warning
No code suggestions found for the PR.
|
Carries the merged readPackage resolvedDir hook (pnpm/pnpm#12936) plus the hoisted-peer range fix (pnpm/pnpm#12932). The resolvedDir hook resolves the injected workspace-sibling failures under BIT_FEATURES=deps-graph — the deps-graph e2e suite drops from 3 failing to 1. The remaining failure is the separate lockfile resolution-reuse gap, not the manifest-injection path. Co-Authored-By: Claude Fable 5 <[email protected]>
When the engine resolves a workspace project as an injected
file:dependency, it feeds the host'sreadPackagecallback that project's manifest as supplied inprojects. A host that pre-transforms its importer manifests (Bit strips workspace-sibling deps there because it wires those links itself) has no way to recognize the call and restore the raw manifest — so the injected instance silently loses dependencies, and Bit's component graph loses its component edges (theBIT_FEATURES=deps-graph"should replace pending version in direct dependency" e2e cluster on teambit/bit#10293).pnpm's TS engine never had this problem: it keeps raw project manifests and applies the host hook chain contextually — with the project dir for the importer view, without it for dependency manifests.
This PR gives the node-API host the same discrimination:
HookContextcarries the lockfile-root-relative directory of a directory resolution (injected workspace projects andfile:deps); other resolutions pass none.(manifest, resolvedDir?) => manifest.FnArgsis required for the two-argument spread — a bare tuple serializes into a single JSON array argument..pnpmfile.cjsbridge deliberately does not expose it, matching pnpm's pnpmfilereadPackage(pkg, context)contract.A unit test pins the contract (directory resolution →
Some(dir), registry →None).Verified end-to-end against Bit with a locally built binding plus the matching lynx change (teambit/bit@9c45e72be): the deps-graph e2e file goes from 7 failing to 3 failing, and the remaining three are the pre-existing lockfile-resolution-reuse gap (
plans/LOCKFILE_RESOLUTION_REUSE.md), unrelated to manifests. Full pacquet suite: 5157/5157 pass.Written by an agent (Claude Code, claude-fable-5).
🤖 Generated with Claude Code
Summary by CodeRabbit
readPackagehooks can now receive an optionalresolvedDirvalue for directory/file-based dependency resolutions.(manifest, resolvedDir?) => manifesthook signature.readPackagefor directory resolutions, while leaving it unset for registry-based resolutions.resolvedDiris provided for directory dependencies and omitted for registry dependencies.