[PR #4223] [MERGED] fix(reference): resolve extensionless imports to .mts and .cts files #6135

Closed
opened 2026-10-31 01:12:07 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/4223
Author: @Abishek0070
Created: 10/15/2026
Status: ✅ Merged
Merged: 10/16/2026
Merged by: @morluto

Base: main ← Head: fix/reference-source-mts-cts-resolution


📝 Commits (3)

  • 2fe0064 fix(reference): resolve extensionless imports to .mts and .cts files
  • 5f4d189 Merge branch 'main' into fix/reference-source-mts-cts-resolution
  • e0bfaf8 test(reference): restore regression coverage for extensionless .mts and .cts imports

📊 Changes

2 files changed (+66 additions, -0 deletions)

View changed files

📝 src/application/ReferenceSourceImportEntries.test.ts (+64 -0)
📝 src/application/ReferenceSourceImportEntries.ts (+2 -0)

📄 Description

Summary

Include .mts and .cts extension probe slots in RESOLUTION_SUFFIXES so that extensionless imports and requires targeting ESM and CJS TypeScript files and directory indexes resolve to internal relationships instead of remaining unresolved.

Problem and expected behavior

When analyzing reference sources that employ TypeScript's .mts (ECMAScript module) or .cts (CommonJS) file extensions, extensionless specifiers such as import "./esm" or require("./cjs") (as well as directory imports targeting index.mts or index.cts) were left with resolution: "unresolved".

REA classifies .mts and .cts as "TypeScript" in referenceSourceClassification.ts and parses their AST imports via Babel in referenceSourceImportParsing.ts, but omitted both extensions from RESOLUTION_SUFFIXES. Extensionless specifiers are expected to probe .mts and .cts candidates in TypeScript probe order and resolve matching entries to resolution: "internal".

Change and scope

  • Added [".mts"] and [".cts"] probe slots to RESOLUTION_SUFFIXES directly following [".ts"] in src/application/ReferenceSourceImportEntries.ts, preserving TypeScript-over-JavaScript precedence before probing .js, .mjs, .cjs, .tsx, and .jsx.
  • Preserved REQUIRE_RESOLUTION_SUFFIXES behavior without injecting unwanted JSON fallbacks into .mts/.cts slots.
  • Added regression tests in src/application/ReferenceSourceImportEntries.test.ts covering extensionless imports, requires, and directory index lookups for .mts and .cts.
  • Scope fit: Ordinary fix within existing reference source import resolution boundaries; maintainer scope decision is not applicable.

Contract and boundary impact

  • Semantic owner and earliest changed stage: Reference source import projection (src/application/ReferenceSourceImportEntries.ts).
  • Contribution scope fit and linked maintainer decision: Ordinary fix within existing boundaries; not applicable.
  • CLI and MCP/tool-catalog contract: None (internal reference source import graph relationship resolution).
  • Provider, bridge, target-format, or platform compatibility: Platform-independent.
  • Evidence, artifact, provenance, or reconstruction contract: Preserves exact relative target paths and resolves internal relationships without altering file hashing, classifications, or inventory identities.
  • Target selection, authority, upstream behavior, and cleanup details: Not applicable.
  • Generated metadata (docs/public/product-catalog.json), package, or installation impact: None.

Expected effects:

  • Read existing files or captured data.
  • Launch or attach to a process.
  • Inject instrumentation or run scripts/code.
  • Change process memory, registers, files, or configuration.
  • Contact network services.
  • Recover protected code or work around protections.
  • Documentation or usability only; no target interaction.
  • Not sure yet; investigation or maintainer guidance needed.

Evidence and regression coverage

  • Tests added or updated: Added resolves extensionless imports and requires to .mts and .cts files and directory indexes in src/application/ReferenceSourceImportEntries.test.ts.
  • Base reproduction or other evidence: Before applying the fix, the regression test failed with all 4 relationships (import "./esm", import "./pkg-esm", require("./cjs"), and require("./pkg-cjs")) remaining { resolution: "unresolved" }. With the fix, all 4 resolve to { resolution: "internal" } pointing to src/esm.mts, src/pkg-esm/index.mts, src/cjs.cts, and src/pkg-cjs/index.cts.
  • User-visible CLI/MCP output (if applicable): Not applicable.
  • Remaining proof gaps: None for reference source entry resolution.

For evidence-bearing changes:

  • Observed, derived, and inferred claims remain distinguishable.
  • Artifact identity, source provenance, and failed attempts remain preserved.
  • Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.

Validation performed

  • npm run test:local -- src/application/ReferenceSourceImportEntries.test.ts — 4 passed (1.56s).
  • npm run check:fast — 2 tasks successful (typecheck and oxlint, 0 errors).
  • npm run verify:test-discovery — Discovered all 1355 test files exactly once.
  • npm run verify:module-boundaries — Checked resolved module boundaries in 1946 source files (0 errors).
  • Git pre-commit hooks (oxfmt, oxlint --fix) — Passed cleanly.
  • Git pre-push hook (npm run check:fast) — Passed cleanly.

Compatibility, safety, and release

  • Breaking changes or migration steps: None.
  • Real Hopper/Ghidra, browser, or OS coverage: Not applicable.
  • Package or release metadata impact: None.
  • Security, privacy, process, or containment review: Pure in-memory candidate path probe; no external process execution or network access.

Author readiness

Human owner: @Abishek0070

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/morluto/rea/pull/4223 **Author:** [@Abishek0070](https://github.com/Abishek0070) **Created:** 10/15/2026 **Status:** ✅ Merged **Merged:** 10/16/2026 **Merged by:** [@morluto](https://github.com/morluto) **Base:** `main` ← **Head:** `fix/reference-source-mts-cts-resolution` --- ### 📝 Commits (3) - [`2fe0064`](https://github.com/morluto/rea/commit/2fe0064c5aed29d358b15e223a296c57d98fa611) fix(reference): resolve extensionless imports to .mts and .cts files - [`5f4d189`](https://github.com/morluto/rea/commit/5f4d18937b9392da3e598cadf0ab0115b4476ef8) Merge branch 'main' into fix/reference-source-mts-cts-resolution - [`e0bfaf8`](https://github.com/morluto/rea/commit/e0bfaf8a8889d28af2b8701d0a050d5bf4103389) test(reference): restore regression coverage for extensionless .mts and .cts imports ### 📊 Changes **2 files changed** (+66 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `src/application/ReferenceSourceImportEntries.test.ts` (+64 -0) 📝 `src/application/ReferenceSourceImportEntries.ts` (+2 -0) </details> ### 📄 Description ## Summary Include `.mts` and `.cts` extension probe slots in `RESOLUTION_SUFFIXES` so that extensionless imports and requires targeting ESM and CJS TypeScript files and directory indexes resolve to internal relationships instead of remaining unresolved. ## Problem and expected behavior When analyzing reference sources that employ TypeScript's `.mts` (ECMAScript module) or `.cts` (CommonJS) file extensions, extensionless specifiers such as `import "./esm"` or `require("./cjs")` (as well as directory imports targeting `index.mts` or `index.cts`) were left with `resolution: "unresolved"`. REA classifies `.mts` and `.cts` as `"TypeScript"` in `referenceSourceClassification.ts` and parses their AST imports via Babel in `referenceSourceImportParsing.ts`, but omitted both extensions from `RESOLUTION_SUFFIXES`. Extensionless specifiers are expected to probe `.mts` and `.cts` candidates in TypeScript probe order and resolve matching entries to `resolution: "internal"`. ## Change and scope - Added `[".mts"]` and `[".cts"]` probe slots to `RESOLUTION_SUFFIXES` directly following `[".ts"]` in `src/application/ReferenceSourceImportEntries.ts`, preserving TypeScript-over-JavaScript precedence before probing `.js`, `.mjs`, `.cjs`, `.tsx`, and `.jsx`. - Preserved `REQUIRE_RESOLUTION_SUFFIXES` behavior without injecting unwanted JSON fallbacks into `.mts`/`.cts` slots. - Added regression tests in `src/application/ReferenceSourceImportEntries.test.ts` covering extensionless imports, requires, and directory index lookups for `.mts` and `.cts`. - Scope fit: Ordinary fix within existing reference source import resolution boundaries; maintainer scope decision is not applicable. ## Contract and boundary impact - Semantic owner and earliest changed stage: Reference source import projection (`src/application/ReferenceSourceImportEntries.ts`). - Contribution scope fit and linked maintainer decision: Ordinary fix within existing boundaries; not applicable. - CLI and MCP/tool-catalog contract: None (internal reference source import graph relationship resolution). - Provider, bridge, target-format, or platform compatibility: Platform-independent. - Evidence, artifact, provenance, or reconstruction contract: Preserves exact relative target paths and resolves internal relationships without altering file hashing, classifications, or inventory identities. - Target selection, authority, upstream behavior, and cleanup details: Not applicable. - Generated metadata (`docs/public/product-catalog.json`), package, or installation impact: None. Expected effects: - [x] Read existing files or captured data. - [ ] Launch or attach to a process. - [ ] Inject instrumentation or run scripts/code. - [ ] Change process memory, registers, files, or configuration. - [ ] Contact network services. - [ ] Recover protected code or work around protections. - [ ] Documentation or usability only; no target interaction. - [ ] Not sure yet; investigation or maintainer guidance needed. ## Evidence and regression coverage - Tests added or updated: Added `resolves extensionless imports and requires to .mts and .cts files and directory indexes` in `src/application/ReferenceSourceImportEntries.test.ts`. - Base reproduction or other evidence: Before applying the fix, the regression test failed with all 4 relationships (`import "./esm"`, `import "./pkg-esm"`, `require("./cjs")`, and `require("./pkg-cjs")`) remaining `{ resolution: "unresolved" }`. With the fix, all 4 resolve to `{ resolution: "internal" }` pointing to `src/esm.mts`, `src/pkg-esm/index.mts`, `src/cjs.cts`, and `src/pkg-cjs/index.cts`. - User-visible CLI/MCP output (if applicable): Not applicable. - Remaining proof gaps: None for reference source entry resolution. For evidence-bearing changes: - [x] Observed, derived, and inferred claims remain distinguishable. - [x] Artifact identity, source provenance, and failed attempts remain preserved. - [x] Unsupported, incomplete, unavailable, or uncertain outcomes remain visible. ## Validation performed - `npm run test:local -- src/application/ReferenceSourceImportEntries.test.ts` — 4 passed (1.56s). - `npm run check:fast` — 2 tasks successful (`typecheck` and `oxlint`, 0 errors). - `npm run verify:test-discovery` — Discovered all 1355 test files exactly once. - `npm run verify:module-boundaries` — Checked resolved module boundaries in 1946 source files (0 errors). - Git pre-commit hooks (`oxfmt`, `oxlint --fix`) — Passed cleanly. - Git pre-push hook (`npm run check:fast`) — Passed cleanly. ## Compatibility, safety, and release - Breaking changes or migration steps: None. - Real Hopper/Ghidra, browser, or OS coverage: Not applicable. - Package or release metadata impact: None. - Security, privacy, process, or containment review: Pure in-memory candidate path probe; no external process execution or network access. ## Author readiness Human owner: @Abishek0070 - [x] I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work. - [x] I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps. - [x] I declare this PR ready for initial maintainer review. ## Before merge - [ ] This PR addresses a concrete problem or an agreed enhancement. - [ ] Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff. - [ ] The PR has one focused outcome and the title follows `type(scope): outcome`. - [ ] Related issue is linked, or the reason for not linking one is stated above. - [ ] Tests cover changed observable behavior and meaningful failure paths. - [ ] Owning docs, contracts, and generated metadata are updated where needed. - [ ] User-visible CLI/MCP changes include representative output. - [ ] I checked the final diff for secrets, unrelated cleanup, and unsupported claims. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-31 01:12:07 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#6135
No description provided.