Repository navigation
feat(javascript): resolve exact package import aliases - #1862
Conversation
Resolve exact #alias specifiers against the importer's enclosing package.json imports map using the shared condition, array, and null target selection. Nested packages keep their own maps; missing keys, explicit nulls, and out-of-scope aliases report a precise reason. Wildcard, recursive, and external-package import targets remain unresolved.
Bound nested #alias requires produce application-graph require edges from the enclosing package. Node reports MODULE_NOT_FOUND when a nested package.json has no imports field, without inheriting the ancestor map.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 208c40463c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
From the #1838 author's side: this implements the sketched boundary faithfully, including the part I expected to be the subtle one — the enclosing-package walk stopping at |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5492780737
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5603a4d842
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: cfc07f6cc5
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e4ccc23402
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Summary
Static JavaScript application analysis now resolves exact package-private
#aliasspecifiers against the importer's enclosingpackage.jsonimportsmap. Inventoried local files become resolved application-graph edges instead of external unknowns, and missing, blocked, or out-of-scope aliases keep an unresolved edge with a precise reason.Fixes #1838
Demo
The sample is a generated local application, not third-party code.
Problem and expected behavior
A package that declares
{"imports":{"#config":"./config.cjs"}}and requires#configleaves a real dependency out of the static application graph. On0b4ce836, that specifier isresolved_path: null,resolution_status: "external", with the limitation "The bare specifier is a Node builtin, package import map, or invalid package name." Node's resolver selectsconfig.cjs.The graph should resolve exact
#aliaskeys through the nearest enclosing same-containerpackage.json, stopping at anode_modulesdirectory so a nested package cannot inherit an ancestor's map. Selected targets are package-local./files with no extension or index fallback. A missing key, explicit null, or out-of-scope alias reports that reason and does not fall through to files, indexes, or another package's map.Change and scope
Domain lookup classifies
#specifiers and exactimportskeys. Application path resolution walks the importer's enclosing package scope, then reuses the existing condition, array, and null target selection. Shared CLI and MCP adapters already thread those resolver outcomes intoanalyze-javascript-application/analyze_javascript_applicationgraphs; no new tool is added.#aliaskeys resolve relative to the owning package root.node_modulespackages use their ownimportsmap.#configis treated as an import alias, not a URL fragment.#internal/*), recursive#targets, and external-package import targets remain unresolved with that limitation.Out of scope: wildcard expansion, recursive alias chasing, external-package targets, TypeScript
paths, browser import maps, package installation, network access, and target execution.Contract and boundary impact
src/domain/javascript/javascriptPackageImportAliases.ts, then applicationJavaScriptArtifactPathResolution, before graph relationship construction.analyze_javascript_application/analyze-javascript-applicationschemas, names, and adapters are unchanged; resolution outcomes flow through the currentresolution_status/resolved_path/ limitations fields.docs/public/product-catalog.json), package, or installation impact (CI generates and validates ignored catalogs andskills/; edit authored instructions in.agents/skills/reverse-engineer-anything/and never commit build outputs): authored skill referencejavascript-applications.mdanddocs/javascript-artifact-reconstruction.mdupdated. Catalog is regenerated by the repo build and is not committed.Evidence and regression coverage
#, and foreign-container refusals; Node import/require oracle comparisons including nested packages without animportsfield; compiled CLI and stdio MCP graphs on an owned fixture.0b4ce836,#configagainst the fixture above is external with the builtin/import-map limitation. After this change the same specifier isresolved_path: "config.cjs",resolution_status: "resolved".#config→config.cjs(resolved); nestednode_modules/fixture#config→node_modules/fixture/local.cjs(resolved);#missing→resolved_path: null,resolution_status: "external", limitation "Package metadata package.json does not define package import alias #missing; it declares #config."For evidence-bearing changes:
Validation performed
npm ci— pass (377 packages added, 378 audited, 0 vulnerabilities)npm run test:focused -- src/domain/javascript/javascriptPackageImportAliases.test.ts src/application/javascript/JavaScriptArtifactPathResolution.test.ts tests/boundary/javascript/packageImportAliases.test.ts tests/acceptance/applications/packageImportAliasesCli.test.ts— pass (4 files, 111 tests; CLI 1255 ms, stdio MCP 3863 ms)npm run check:fast— passnpm run check— pass (typecheck, lint, format:check, knip, metadata:check; 6/6 turbo tasks; architecture guards across 1138 source files; lint 753 warnings, 0 errors)npm run docs:check— passnpm run verify:test-discovery— pass (“Discovered all 839 test files exactly once.”)Compatibility, safety, and release
#specifiers that previously stayed external now resolve when an exact enclosingimportskey selects an inventoried./file; unsupported forms remain unresolved.Review checklist
type(scope): outcome.