Repository navigation
fix(app): stage the CLI closure without anchoring on the checkout's absolute path (UUID-safe) - #1473
Merged
iamtoruk merged 3 commits intoSep 18, 2026
Conversation
…heckout's absolute path npm 12 redacts UUID-shaped path segments to *** in npm ls --parseable output, so the absolute <root>/node_modules/ prefix match staged an empty closure on any checkout under a UUID directory (CI runners, scratch worktrees) and packaging aborted with the misleading 'is the root npm installed?' (getagentseal#1466). The top-level package name is now read by position - after the N-th /node_modules occurrence, where N is counted off the real root path the redaction cannot move - extracted into a pure, unit-tested module following the windows-installer-paths .mjs/.d.mts precedent. Nested transitive paths still map to their top-level ancestor, a checkout that itself lives inside a node_modules directory resolves one segment deeper, Windows separators normalize on both sides, and a bare truncated scope is refused rather than copied whole. Also stop swallowing a missing npm_execpath into the empty-closure message: it now fails with its own instruction. Verified against genuine npm 12.0.2 output from a UUID-path checkout (new logic resolves the package, the old prefix match finds none), by the new fixture suite, and by a full end-to-end npm run stage-cli (160 packages staged, Electron launch smoke green).
ozymandiashh
force-pushed
the
fix/1466-stage-cli-uuid-path
branch
from
September 18, 2026 11:43
098c0b4 to
4ca4ee7
Compare
…pm version
The two hand-rolled scanners do what split('/node_modules/') already does.
npm 11.19.0 redacts UUID segments too, so the npm 12 attribution was wrong.
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.
Fixes #1466.
app/scripts/stage-cli.mjsresolved the CLI's production dependency closure by matching eachnpm ls --parseableline against the checkout's absolute<root>/node_modules/prefix. npm 12 redacts UUID-shaped path segments to***in that output, so on any checkout under a UUID directory (CI runners, scratch worktrees) the match found nothing and packaging aborted with the misleading "is the root npm installed?".The fix
The top-level package name is now read by position: after the N-th
/node_modulesoccurrence in the line, where N is counted off the real (unredacted) root path. The redaction renames segments but cannot move an occurrence, so redacted shapes resolve exactly like plain ones. The extraction lives in a new pure moduleapp/scripts/stage-cli-packages.mjswith a.d.mtsdeclaration, following the existingwindows-installer-paths.mjs/.d.mtsprecedent, unit-tested under the app vitest gate (scripts/**/*.test.ts).Kept from the old behaviour and pinned by tests:
.../node_modules/react-dom/node_modules/scheduler) still maps to its top-level ancestor (react-dom), which is what the stage copies;node_modulesdirectory resolves one segment deeper (a naive first-occurrence parser would read the checkout's directory name off every line);Two adjacent hardenings in the same script: a missing
npm_execpathnow fails with its own message instead of degrading into the empty-closure one (the try/catch that exists so a non-zeronpm lsexit still yields its stdout was also swallowing it), and a truncated line ending in a bare@scopeis refused rather than copied as the whole scope directory.Proof
/tmp/1a2b3c4d-1111-2222-3333-444455556666/probe-29473—[email protected] ls --omit=dev --all --parseableprints/private/tmp/***/probe-29473/node_modules/lodash. Fed that literal output to old vs new: the absolute-prefix match finds 0 packages, the position-based extractor findslodash.npm --prefix app run stage-clion this repo (non-UUID path): builds the CLI, stages 160 production packages, and the Electron launch smoke (models --help+ a full serve ready frame) passes.app/scripts/stage-cli-packages.test.ts, 6 tests — the literal redacted npm-12 shape, the nested-checkout shape, transitive→ancestor mapping, Windows separators, root-line/blank/bare-scope skipping. Runs undercd app && npm test(scripts/**/*.test.tsin app/vitest.config.ts), same gate asverify-windows-installer.test.ts.tsc --noEmit -p app/tsconfig.jsonclean.