Repository navigation
fix(pacquet): pin saved node runtime version and preserve package.json formatting - #12948
Conversation
…picked version `pnpm runtime set node 26` (and `pnpm add node@runtime:26`) wrote the requested range verbatim into the manifest, so `devEngines.runtime.version` recorded `26` instead of the resolved `26.5.0`. The TypeScript CLI rewrites the manifest after resolution with the node resolver's normalized specifier; pacquet decides the saved specifier before the install, so that normalization never ran and the daily update-lockfile PR (#12802) regressed from exact pins to a bare major. Expose the normalization as `NodeResolver::resolve_save_specifier` — the shared parse/mirror/pick-version path without the platform asset fetch — and call it from `Add::run` for explicit `node@runtime:` requests. Deno and bun are unchanged: both stacks normalize those to the requested spec, which the verbatim save path already produces. Co-Authored-By: Claude Fable 5 <[email protected]>
…p saves Match the TypeScript project-manifest reader/writer contract when writing package.json: - Keep the source file's final-newline state (new manifests get one). Saves previously always dropped the trailing newline, which showed up as churn in the update-lockfile PR (#12802). - Detect the indentation unit at read and reuse it on save; a single-line document round-trips back to its compact form. - Normalize dependency fields on write: sort entries by name and drop a field that holds no entries, so a reification-only `devDependencies: {}` never lands on disk. - Skip the write entirely when the file already encodes the same manifest, so a no-op save never churns formatting or mtime. This turns `save` into a `&mut self` method (it tracks the on-disk baseline). Co-Authored-By: Claude Fable 5 <[email protected]>
The perfectionist dylint rejects string literals whose escapes a raw string would avoid. 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 (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughThe PR centralizes Node runtime version selection, pins ChangesNode runtime resolution
Package manifest round-tripping
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant Add
participant NodeResolver
participant Mirror
participant PackageManifest
Add->>NodeResolver: Resolve node@runtime selector
NodeResolver->>Mirror: Fetch release index
Mirror-->>NodeResolver: Return available versions
NodeResolver-->>Add: Return pinned runtime specifier
Add->>PackageManifest: Save updated dependency
PackageManifest-->>Add: Write normalized package.json
Possibly related PRs
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 QodoPin saved node@runtime version and preserve package.json formatting on save
AI Description
Diagram
High-Level Assessment
Files changed (6)
|
Code Review by Qodo
Context used✅ Compliance rules (platform):
18 rules 1.
|
Micro-Benchmark ResultsLinux |
PR Code Suggestions ✨Latest suggestions up to 9e28953 Warning
Previous suggestionsSuggestions up to commit fff9710
|
||||||||||||||||||
Confidence Score: 5/5Safe to merge — the changes are well-scoped, the new code paths are covered by targeted tests, and the formatting changes are transparent to callers. The two bug fixes are straightforward: resolve_save_specifier is a thin wrapper around the existing pick_node_version path with no new network calls beyond what resolve() already makes, and the manifest formatting logic is isolated behind the PackageManifest API boundary. Previously flagged concerns (implicit write_to_file/serialize_with_indent coupling; unnormalized on_disk baseline for new manifests) are both addressed in this revision. The test suite covers all new code paths including offline mode, no-match errors, operator forwarding, indent detection edge cases, and the no-op save guard. No files require special attention. Reviews (2): Last reviewed commit: "fix(package-manifest): cap the indentati..." | Re-trigger Greptile |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
pnpm/crates/package-manifest/src/lib.rs (1)
109-114: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winDuplicated pretty-print logic diverges from
DEFAULT_INDENT/serialize_with_indent.
write_to_filehardcodesserde_json::to_string_prettywhileself.indentis separately set toDEFAULT_INDENT. They currently agree only becauseto_string_pretty's built-in default happens to be two spaces. IfDEFAULT_INDENTis ever changed, scaffolded files would be written with one indent while the manifest's cachedindent(used later byserialize_with_indenton subsequent saves) claims another, producing an inconsistent re-serialization after the first save.♻️ Proposed fix to use a single source of truth for indentation
fn write_to_file(path: &Path) -> Result<(Value, String), PackageManifestError> { let manifest = PackageManifest::init_value_for(path); - let contents = serde_json::to_string_pretty(&manifest)?; + let contents = serialize_with_indent(&manifest, DEFAULT_INDENT)?; fs::write(path, format!("{contents}\n"))?; // TODO: forbid overwriting existing files Ok((manifest, contents)) }🤖 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/package-manifest/src/lib.rs` around lines 109 - 114, Update write_to_file to serialize the initialized manifest through the existing serialize_with_indent path using DEFAULT_INDENT, rather than serde_json::to_string_pretty, so file output and the manifest’s cached indentation share one source of truth. Preserve the existing trailing newline and return values.
🤖 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/package-manifest/src/lib.rs`:
- Around line 109-114: Update write_to_file to serialize the initialized
manifest through the existing serialize_with_indent path using DEFAULT_INDENT,
rather than serde_json::to_string_pretty, so file output and the manifest’s
cached indentation share one source of truth. Preserve the existing trailing
newline and return values.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: c83fc3ca-310c-40f2-a14e-fdeb9232d19a
📒 Files selected for processing (6)
pnpm/crates/engine-runtime-node-resolver/src/node_resolver.rspnpm/crates/engine-runtime-node-resolver/src/node_resolver/tests.rspnpm/crates/package-manager/src/add.rspnpm/crates/package-manager/src/add/tests.rspnpm/crates/package-manifest/src/lib.rspnpm/crates/package-manifest/src/tests.rs
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #12948 +/- ##
==========================================
+ Coverage 85.57% 85.65% +0.07%
==========================================
Files 475 475
Lines 74718 74920 +202
==========================================
+ Hits 63940 64172 +232
+ Misses 10778 10748 -30 ☔ 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": 3.8571183045800006,
"stddev": 0.192939956333595,
"median": 3.75291266158,
"user": 3.61351212,
"system": 3.45793752,
"min": 3.71779075058,
"max": 4.2397822645800005,
"times": [
4.2397822645800005,
3.87213364558,
3.71845454158,
3.72715062258,
4.15698161658,
3.72274456758,
3.71779075058,
3.7402331485799998,
3.7655921745799996,
3.91031971358
]
},
{
"command": "pacquet@main",
"mean": 3.7371212431800003,
"stddev": 0.02957257896852061,
"median": 3.74301211558,
"user": 3.6102463199999995,
"system": 3.4378284199999998,
"min": 3.70081967358,
"max": 3.7723214825799998,
"times": [
3.75232592058,
3.7689372845799998,
3.7723214825799998,
3.70081967358,
3.76562419358,
3.70410379458,
3.75779029658,
3.73369831058,
3.70566660158,
3.70992487358
]
},
{
"command": "pnpr@HEAD",
"mean": 2.0834786538799994,
"stddev": 0.09879684749137715,
"median": 2.05786349558,
"user": 2.70297022,
"system": 3.04555702,
"min": 1.9838837875800002,
"max": 2.26437627858,
"times": [
2.07618842558,
2.26437627858,
1.9929130645800002,
2.03953856558,
2.0843168515799997,
2.00759952758,
1.9838837875800002,
2.20240119858,
2.0052414435799997,
2.1783273955799998
]
},
{
"command": "pnpr@main",
"mean": 2.11156666528,
"stddev": 0.10439487197322467,
"median": 2.08467530708,
"user": 2.6544410199999993,
"system": 3.01711462,
"min": 2.0106375105799996,
"max": 2.33450242358,
"times": [
2.02750706858,
2.2515797915799998,
2.08572753658,
2.1400162945799996,
2.0902659785799997,
2.0360812135799997,
2.05572575758,
2.33450242358,
2.0106375105799996,
2.08362307758
]
}
]
}Scenario: Isolated linker: fresh restore, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.6571309831400001,
"stddev": 0.011185224337997297,
"median": 0.65738901604,
"user": 0.38329660000000004,
"system": 1.3420353199999997,
"min": 0.64318664304,
"max": 0.67340393504,
"times": [
0.64452263304,
0.64906938604,
0.6712987190399999,
0.66208290404,
0.66311284404,
0.67340393504,
0.66489526304,
0.64704237604,
0.64318664304,
0.65269512804
]
},
{
"command": "pacquet@main",
"mean": 0.64771367614,
"stddev": 0.009673166068253955,
"median": 0.65208527704,
"user": 0.3791241,
"system": 1.32828892,
"min": 0.62880245904,
"max": 0.6609460390399999,
"times": [
0.65354050804,
0.6609460390399999,
0.65111518104,
0.63872043604,
0.65381090604,
0.62880245904,
0.6530553730399999,
0.64018587504,
0.65393200704,
0.64302797704
]
},
{
"command": "pnpr@HEAD",
"mean": 0.75036933374,
"stddev": 0.1428783678894957,
"median": 0.70837265704,
"user": 0.4058198999999999,
"system": 1.3660294199999998,
"min": 0.68590236504,
"max": 1.1554859820399999,
"times": [
0.69160681804,
0.70253735204,
0.71299105204,
0.68590236504,
0.72457014604,
0.69376408004,
0.7078843620399999,
0.72009022804,
0.70886095204,
1.1554859820399999
]
},
{
"command": "pnpr@main",
"mean": 0.73368375164,
"stddev": 0.10014053754590194,
"median": 0.70660828504,
"user": 0.4022398,
"system": 1.3719338200000002,
"min": 0.6836525220399999,
"max": 1.0171994470399999,
"times": [
0.69439958704,
0.71137630804,
0.71438116804,
0.70624041904,
0.70643996804,
0.68779722104,
0.70857427404,
0.70677660204,
1.0171994470399999,
0.6836525220399999
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + cold store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 4.29087933396,
"stddev": 0.04795526265622508,
"median": 4.30310465126,
"user": 3.7994803599999996,
"system": 3.4280009599999994,
"min": 4.22657836176,
"max": 4.35137411276,
"times": [
4.22789498876,
4.22657836176,
4.29569230476,
4.25175123576,
4.35137411276,
4.25003842576,
4.31051699776,
4.34169672176,
4.31686836076,
4.33638182976
]
},
{
"command": "pacquet@main",
"mean": 4.306188337959999,
"stddev": 0.07609447202924531,
"median": 4.30304762726,
"user": 3.76730696,
"system": 3.4664546599999992,
"min": 4.20192274476,
"max": 4.49152560576,
"times": [
4.25472587376,
4.28698130076,
4.33323308676,
4.20192274476,
4.30692362876,
4.29917162576,
4.25284558976,
4.3162166507599995,
4.31833727276,
4.49152560576
]
},
{
"command": "pnpr@HEAD",
"mean": 2.3355453817600003,
"stddev": 0.11678261289283118,
"median": 2.35577055026,
"user": 2.5938992599999997,
"system": 3.0223982599999997,
"min": 2.12796161076,
"max": 2.46242326876,
"times": [
2.37084755476,
2.20883196176,
2.4111870607599997,
2.12796161076,
2.28187814476,
2.24103857776,
2.4528737717599998,
2.46242326876,
2.3406935457599998,
2.4577183207599997
]
},
{
"command": "pnpr@main",
"mean": 2.1759610395599998,
"stddev": 0.13491026611917395,
"median": 2.1028457987599998,
"user": 2.5650522600000003,
"system": 3.0383583599999993,
"min": 2.07225741876,
"max": 2.43384628276,
"times": [
2.07809674176,
2.0747817727599998,
2.43384628276,
2.11328816876,
2.20919279476,
2.08034146176,
2.3847065917599997,
2.09240342876,
2.22069573376,
2.07225741876
]
}
]
}Scenario: Isolated linker: fresh install, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 1.4641670854200002,
"stddev": 0.009988650719456415,
"median": 1.46632182592,
"user": 1.4152042799999998,
"system": 1.7772444199999995,
"min": 1.44772416942,
"max": 1.47729707342,
"times": [
1.45986621742,
1.47729707342,
1.44772416942,
1.47488793042,
1.46987862442,
1.46704684742,
1.4655968044199998,
1.4685472204199999,
1.46270493942,
1.44812102742
]
},
{
"command": "pacquet@main",
"mean": 1.42825328592,
"stddev": 0.04437186863436105,
"median": 1.42712532392,
"user": 1.36992078,
"system": 1.7508735199999996,
"min": 1.36904147242,
"max": 1.52559644842,
"times": [
1.52559644842,
1.44445119742,
1.45774023442,
1.4139953454199998,
1.38238019942,
1.36904147242,
1.39446717842,
1.42617253742,
1.4406101354199998,
1.42807811042
]
},
{
"command": "pnpr@HEAD",
"mean": 0.7289687476200001,
"stddev": 0.09007099973851024,
"median": 0.7026366299200001,
"user": 0.37555478,
"system": 1.3184634199999998,
"min": 0.6788683884200001,
"max": 0.9821431394200001,
"times": [
0.6788683884200001,
0.6835558954200001,
0.9821431394200001,
0.7055798474200001,
0.70027854042,
0.69236970342,
0.71596603142,
0.7267448414200001,
0.7049947194200001,
0.6991863694200001
]
},
{
"command": "pnpr@main",
"mean": 0.71024054932,
"stddev": 0.040776338447567256,
"median": 0.6991498059200001,
"user": 0.36907848,
"system": 1.3153967199999999,
"min": 0.6696103854200001,
"max": 0.8115129124200001,
"times": [
0.6899480214200001,
0.70155455042,
0.7005583634200001,
0.6696103854200001,
0.6873071504200001,
0.7469141114200001,
0.6977412484200001,
0.68914923642,
0.8115129124200001,
0.7081095134200001
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 3.1601495736799996,
"stddev": 0.08333522115908573,
"median": 3.14988424348,
"user": 1.8675037799999998,
"system": 2.05256624,
"min": 3.05804040548,
"max": 3.36925460348,
"times": [
3.1959599554800002,
3.05804040548,
3.11280045748,
3.14988741148,
3.14715938648,
3.15963404648,
3.14988107548,
3.36925460348,
3.16522533048,
3.09365306448
]
},
{
"command": "pacquet@main",
"mean": 3.19994000258,
"stddev": 0.02967735035841914,
"median": 3.19370022798,
"user": 1.8799570799999998,
"system": 2.0860682399999995,
"min": 3.16653231448,
"max": 3.24174763948,
"times": [
3.21014398248,
3.19362460948,
3.16653231448,
3.23504201448,
3.24174763948,
3.23706931848,
3.18595857848,
3.19377584648,
3.16663258248,
3.16887313948
]
},
{
"command": "pnpr@HEAD",
"mean": 0.6862915066800002,
"stddev": 0.007627259747216782,
"median": 0.6858116229800001,
"user": 0.35658848,
"system": 1.3075754400000001,
"min": 0.6775783004800001,
"max": 0.7009927544800001,
"times": [
0.6785326434800001,
0.6864386494800001,
0.7009927544800001,
0.6824553814800001,
0.6775783004800001,
0.6863487964800001,
0.68527444948,
0.6903578694800001,
0.6792143264800001,
0.6957218954800001
]
},
{
"command": "pnpr@main",
"mean": 0.6955537733800001,
"stddev": 0.027753321698592775,
"median": 0.68773776748,
"user": 0.35556237999999996,
"system": 1.32006004,
"min": 0.6621121454800001,
"max": 0.7671562074800001,
"times": [
0.6870111934800001,
0.6884643414800001,
0.6896918444800001,
0.6853097854800001,
0.68297864748,
0.6621121454800001,
0.6846029814800001,
0.7671562074800001,
0.7043531854800001,
0.7038574014800001
]
}
]
}Scenario: Isolated linker: fresh resolve, hot cache, offline
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.67192750708,
"stddev": 0.010324348720874586,
"median": 0.67156711258,
"user": 0.6407092799999999,
"system": 0.15338005999999998,
"min": 0.65520850208,
"max": 0.69363372108,
"times": [
0.66065356008,
0.67436473208,
0.65520850208,
0.69363372108,
0.67850023208,
0.67546506408,
0.66857098608,
0.67290768508,
0.66974404808,
0.67022654008
]
},
{
"command": "pacquet@main",
"mean": 0.67546995308,
"stddev": 0.011707279399103184,
"median": 0.67151583108,
"user": 0.6423363799999999,
"system": 0.15310875999999998,
"min": 0.66132838308,
"max": 0.6984824750799999,
"times": [
0.67300640108,
0.66704614408,
0.6984824750799999,
0.67815093108,
0.67833789408,
0.66838333708,
0.66132838308,
0.69203556508,
0.67002526108,
0.66790313908
]
},
{
"command": "pnpr@HEAD",
"mean": 0.11058715967999999,
"stddev": 0.002424240959952362,
"median": 0.11105663608000002,
"user": 0.027779280000000003,
"system": 0.021243219999999997,
"min": 0.10715096408,
"max": 0.11388976708000001,
"times": [
0.10807497608,
0.10842001408000002,
0.10715096408,
0.10814646108,
0.10789799208,
0.10821153308,
0.10790454708,
0.10861663708,
0.10792487108000001,
0.10833729308000001,
0.10853594308,
0.11333366808,
0.11353675308,
0.11314315808,
0.11251713908,
0.11225231508,
0.11388976708000001,
0.11277504008,
0.11266079608000001,
0.11283650608000001,
0.11275217708000002,
0.11211089308,
0.11346434908,
0.11105663608000002,
0.10912856208000002
]
},
{
"command": "pnpr@main",
"mean": 0.11043507600000002,
"stddev": 0.009510696527858116,
"median": 0.10825820108,
"user": 0.02778556,
"system": 0.02127734,
"min": 0.10643959308,
"max": 0.15549153208000002,
"times": [
0.10847176408,
0.10763391408,
0.10816501508000001,
0.11235686608,
0.10788218308,
0.10928395508,
0.11237397908000002,
0.10743642208000001,
0.10862863908,
0.10886762008,
0.11156257408,
0.10859727008,
0.10650863808,
0.10939807008000002,
0.10643959308,
0.10791056508000002,
0.10832707808,
0.10821186308,
0.10825820108,
0.10753742608,
0.10777146908000002,
0.10792248008,
0.10888812908,
0.10695165308000001,
0.15549153208000002
]
}
]
}Scenario: Isolated linker: fresh restore, cold cache + cold store + cold pnpr
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 6.9595586765199995,
"stddev": 0.2359603785916582,
"median": 7.00667058242,
"user": 3.9802611799999994,
"system": 3.8119454,
"min": 6.6639151529200005,
"max": 7.32408788692,
"times": [
7.08306861992,
6.6639151529200005,
6.97713352492,
7.08635524892,
7.23386090092,
7.03620763992,
6.70154230892,
6.67704296792,
7.32408788692,
6.812372513920001
]
},
{
"command": "pacquet@main",
"mean": 6.806347343520001,
"stddev": 0.14552178602868937,
"median": 6.77349484642,
"user": 3.9441682799999995,
"system": 3.7946988,
"min": 6.61690156292,
"max": 7.1059115019200005,
"times": [
6.73472099592,
6.92994214292,
6.83980912892,
6.72242612392,
6.81226869692,
6.674616679920001,
6.91065933592,
6.71621726592,
7.1059115019200005,
6.61690156292
]
},
{
"command": "pnpr@HEAD",
"mean": 5.11569635972,
"stddev": 0.12471759898476091,
"median": 5.100967773920001,
"user": 2.84757828,
"system": 3.2918952,
"min": 4.91374734992,
"max": 5.34067035592,
"times": [
4.91374734992,
5.11370026592,
4.98707680192,
5.08429784892,
5.34067035592,
5.2155388379200005,
5.23860332192,
5.08823528192,
5.04484301592,
5.13025051692
]
},
{
"command": "pnpr@main",
"mean": 5.029275162219999,
"stddev": 0.11145865701074754,
"median": 4.98111340042,
"user": 2.80402648,
"system": 3.2994091999999995,
"min": 4.90711734292,
"max": 5.2346224369200005,
"times": [
5.09778742592,
5.19882031892,
5.2346224369200005,
4.90711734292,
4.9521232919200004,
4.98462335392,
4.9498636009200006,
5.02686678392,
4.97760344692,
4.96332361992
]
}
]
} |
|
| Branch | pr/12948 |
| 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,335.55 ms |
| isolated-linker.fresh-install.cold-cache.hot-store | 📈 view plot | 686.29 ms |
| isolated-linker.fresh-install.hot-cache.hot-store | 📈 view plot | 728.97 ms |
| isolated-linker.fresh-resolve.hot-cache.offline | 📈 view plot | 110.59 ms |
| isolated-linker.fresh-restore.cold-cache.cold-store | 📈 view plot | 2,083.48 ms |
| isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr | 📈 view plot | 5,115.70 ms |
| isolated-linker.fresh-restore.hot-cache.hot-store | 📈 view plot | 750.37 ms |
…rialization Address review feedback on the manifest formatting round-trip: - Cap the preserved indentation unit at 10 characters on write - the cap JSON.stringify applies to its space argument, which the TypeScript writer serializes through - so a pathologically indented source file cannot amplify the output. - Serialize the init scaffold through serialize_with_indent with DEFAULT_INDENT instead of serde_json's own pretty default, so the scaffold and every subsequent save share one serialization path. - Read the scaffold back from disk in create_if_needed instead of assembling the manifest by hand, so the formatting state and the no-op-save baseline are always derived from the file the same way as for a pre-existing manifest. Co-Authored-By: Claude Fable 5 <[email protected]>
|
Response to the two Qodo findings (and Greptile's out-of-diff observation), addressed in 9e28953 where applicable: 1. Indent amplification ( 2. Duplicate Node release-index fetch on 3. Greptile: Written by an agent (Claude Code, claude-fable-5). |
|
Code review by qodo was updated up to the latest commit 9e28953 |
Summary
The daily update-lockfile PR (related to #12802) regressed after the workflow switched to the Rust pnpm:
pnpm runtime set node 26wrotedevEngines.runtime.version: "26"instead of the resolved26.5.0, and package.json lost its trailing newline. Both were pacquet-only divergences from the TypeScript CLI's manifest-write behavior.This PR closes them, plus the remaining manifest-formatting parity gaps:
node@runtime:specifier to the picked version. The TypeScript CLI rewrites the manifest after resolution with the node resolver's normalized specifier; pacquet decides the saved specifier before the install, so that normalization never ran and the requested range was written verbatim. The node resolver now exposesresolve_save_specifier(the shared parse/mirror/pick-version path, without the platform asset fetch), andAdd::runcalls it for explicitnode@runtime:requests. A^/~operator on the previous specifier (or the request) is preserved, exactly like the resolver'snormalized_bare_specifier. Deno and bun are unchanged: both stacks save the requested spec for them.PackageManifestnow records the source file's final-newline state and indentation unit at read and reuses both on save (a single-line document round-trips back to compact form); new manifests get two-space indentation and a final newline. The indentation unit is capped at 10 characters on write — the same capJSON.stringifyapplies to itsspaceargument, which the TypeScript writer serializes through — so a pathologically indented source file can't amplify the output."devDependencies": {}never lands on disk.pnpm addno longer churns formatting or mtime. This turnsPackageManifest::saveinto a&mut selfmethod. A freshly scaffolded manifest reads its baseline back from the file it just wrote, so scaffolds and pre-existing manifests share one code path.Verified end to end with the built binary:
runtime set node 26on a tab-indented project writes"version": "26.5.0"keeping tabs and the final newline, leaves no emptydevDependencies, and a second run leaves the file untouched.Squash Commit Body
Checklist
pnpm/port, or the description notes what still needs porting. (TheTypeScript CLI already behaves this way; this PR brings the Rust port to
parity, so no TypeScript changes are needed.)
Written by an agent (Claude Code, claude-fable-5).
Summary by CodeRabbit
New Features
node@runtime:<version>specifications.package.jsonupdates.Bug Fixes