feat(remap): add ordered safe destination mappings - #6
Draft
rafaio1 wants to merge 3 commits into
Draft
Conversation
- Add 'remap' config key accepting ordered {from, to} mappings
- First match wins; collisions report both source paths
- Traversal rejection on configured values AND resulting paths
- stripPrefix becomes sugar for single {from, to: ''} mapping
- Backward compatible: existing stripPrefix configs produce identical packs
- Mutual exclusion: cannot set both stripPrefix and remap
Design credit: @xusuxiang8 (sparepack#3, account deleted)
Traversal-on-configured-values check carries forward from @rafaio1's PR mxx1111#2
Closes #19
… feature - Export applyRemap for direct unit testing - Fix error messages: stripPrefix -> remap in collision/no-match errors - Add 7 new config tests: multiple mappings, ordering, collision with both paths, traversal in from/to, absolute path rejection, no-match error wording, stripPrefix+remap mutual exclusion - Update 2 e2e tests to match corrected error message wording - All 91 tests passing
6 tasks
Author
|
Revalidated the current PR head after a clean dependency install: |
rafaio1
marked this pull request as draft
August 28, 2026 23:41
This was referenced Aug 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this does / 这个 PR 做了什么
Generalizes
stripPrefixinto orderedremap: [{ from, to }]rules whilekeeping
stripPrefixas backward-compatible sugar. It also closes twocollision-safety gaps found during review: every configured rule must actually
win at least one match, and equivalent destination aliases are canonicalized
before collision detection and writing.
The design remains credited to
@xusuxiang8from the now-unreachable PR #3.Traversal-on-configured-values is carried forward from
@rafaio1's PR #2, asrequested by the task.
Acceptance criteria / 验收标准
remapis accepted and validated insrc/config.mjsand registered inKNOWN_KEYS.stripPrefixconfigs produce byte-identical packs to theequivalent single-rule
remapform.orderings, two mapped sources, and canonical aliases.
from/tovalues and in resultingdestination paths.
traversal, unused/shadowed rules, no-match errors, manifests, and
stripPrefixcompatibility.sparepack initdocument the feature.npm testpasses in sparepack.How I verified it / 我是怎么验证的
Validated on the PR head
b825a02df348f668f5b6b7323c6df39a1fa2a7b1in a clean Linux checkout with Node.js 22.23.2:
The executable bit on
bin/sparepack.mjsremains0755. An independentadversarial review reproduced the path-alias overwrite on the earlier head;
the regression cases for
., duplicate separators,./, backslashes, bothsource orderings, and two remapped sources now pass.
Notes for the reviewer / 给审阅者的说明
MANIFEST.jsonrecords canonical post-remap paths.stripPrefixremains supported without a deprecation warning.Attestation / 声明
The technical change has been reviewed and validated by the active Codex
session, but the personal account-owner attestations below are intentionally
left unchecked until the account owner confirms them directly.
Task: mxx1111/spare-cycles#19