From e1d186bf623fa9ce484d6007e25b94eac14e2e24 Mon Sep 17 00:00:00 2001 From: Tirth Kanani Date: Sun, 14 Jun 2026 18:17:07 +0100 Subject: [PATCH 1/2] fix(languages): add .mts/.cts extensions and *.spec.tsx test glob to the TypeScript config The TypeScript LanguageConfig omitted the first-class .mts/.cts module extensions, so those files resolved to null and were skipped by the tree-sitter pipeline. It also listed *.test.tsx but not *.spec.tsx, miscategorizing spec-named TSX test files as regular source. Add .mts/.cts to extensions and *.spec.tsx to the test glob, mirroring the JavaScript config's .mjs/.cjs and test/spec parity. Co-Authored-By: Claude Opus 4.8 (1M context) --- .../core/src/__tests__/language-registry.test.ts | 10 ++++++++++ .../packages/core/src/languages/configs/typescript.ts | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/understand-anything-plugin/packages/core/src/__tests__/language-registry.test.ts b/understand-anything-plugin/packages/core/src/__tests__/language-registry.test.ts index 7a3c77495..6da95c693 100644 --- a/understand-anything-plugin/packages/core/src/__tests__/language-registry.test.ts +++ b/understand-anything-plugin/packages/core/src/__tests__/language-registry.test.ts @@ -72,6 +72,9 @@ describe("LanguageRegistry", () => { expect(registry.getByExtension(".h")?.id).toBe("c"); expect(registry.getByExtension(".lua")?.id).toBe("lua"); expect(registry.getByExtension(".js")?.id).toBe("javascript"); + expect(registry.getByExtension(".mts")?.id).toBe("typescript"); + expect(registry.getByExtension(".cts")?.id).toBe("typescript"); + expect(registry.getForFile("src/server.mts")?.id).toBe("typescript"); }); it("has no duplicate extension mappings across configs", () => { @@ -93,6 +96,13 @@ describe("LanguageRegistry", () => { }); }); + describe("typescript config test patterns", () => { + it("recognizes both .test.tsx and .spec.tsx test files", () => { + expect(typescriptConfig.filePatterns.tests).toContain("*.test.tsx"); + expect(typescriptConfig.filePatterns.tests).toContain("*.spec.tsx"); + }); + }); + describe("Non-code language configs", () => { it("detects all non-code file types via extension", () => { const registry = LanguageRegistry.createDefault(); diff --git a/understand-anything-plugin/packages/core/src/languages/configs/typescript.ts b/understand-anything-plugin/packages/core/src/languages/configs/typescript.ts index 04a884d74..9493af798 100644 --- a/understand-anything-plugin/packages/core/src/languages/configs/typescript.ts +++ b/understand-anything-plugin/packages/core/src/languages/configs/typescript.ts @@ -3,7 +3,7 @@ import type { LanguageConfig } from "../types.js"; export const typescriptConfig = { id: "typescript", displayName: "TypeScript", - extensions: [".ts", ".tsx"], + extensions: [".ts", ".tsx", ".mts", ".cts"], treeSitter: { wasmPackage: "tree-sitter-typescript", wasmFile: "tree-sitter-typescript.wasm", @@ -24,7 +24,7 @@ export const typescriptConfig = { filePatterns: { entryPoints: ["src/index.ts", "src/main.ts", "src/App.tsx", "index.ts"], barrels: ["index.ts"], - tests: ["*.test.ts", "*.spec.ts", "*.test.tsx"], + tests: ["*.test.ts", "*.spec.ts", "*.test.tsx", "*.spec.tsx"], config: ["tsconfig.json"], }, } satisfies LanguageConfig; From a2d0dc0afd12bf6c14e6c0c04040e7fad3c8f8c5 Mon Sep 17 00:00:00 2001 From: Tirth Kanani Date: Tue, 16 Jun 2026 23:32:24 +0100 Subject: [PATCH 2/2] docs(core): clarify .d.ts and .mts/.cts grammar routing; add JS .jsx test patterns - typescript config: comment that .d.ts/.d.mts/.d.cts intentionally fall through to .ts/.mts/.cts as types-only files (no call-graph gating) - tree-sitter-plugin: comment that only .tsx needs the TSX grammar and .mts/.cts deliberately use the plain TS grammar - javascript config: add *.test.jsx / *.spec.jsx for parity with the TS side Co-Authored-By: Claude Opus 4.8 (1M context) --- .../packages/core/src/__tests__/language-registry.test.ts | 8 ++++++++ .../packages/core/src/languages/configs/javascript.ts | 2 +- .../packages/core/src/languages/configs/typescript.ts | 5 +++++ .../packages/core/src/plugins/tree-sitter-plugin.ts | 5 ++++- 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/understand-anything-plugin/packages/core/src/__tests__/language-registry.test.ts b/understand-anything-plugin/packages/core/src/__tests__/language-registry.test.ts index 6da95c693..577dedacf 100644 --- a/understand-anything-plugin/packages/core/src/__tests__/language-registry.test.ts +++ b/understand-anything-plugin/packages/core/src/__tests__/language-registry.test.ts @@ -2,6 +2,7 @@ import { describe, it, expect } from "vitest"; import { LanguageRegistry } from "../languages/language-registry.js"; import { StrictLanguageConfigSchema } from "../languages/types.js"; import { typescriptConfig } from "../languages/configs/typescript.js"; +import { javascriptConfig } from "../languages/configs/javascript.js"; import { pythonConfig } from "../languages/configs/python.js"; describe("LanguageRegistry", () => { @@ -103,6 +104,13 @@ describe("LanguageRegistry", () => { }); }); + describe("javascript config test patterns", () => { + it("recognizes .jsx test files for parity with the .tsx patterns", () => { + expect(javascriptConfig.filePatterns.tests).toContain("*.test.jsx"); + expect(javascriptConfig.filePatterns.tests).toContain("*.spec.jsx"); + }); + }); + describe("Non-code language configs", () => { it("detects all non-code file types via extension", () => { const registry = LanguageRegistry.createDefault(); diff --git a/understand-anything-plugin/packages/core/src/languages/configs/javascript.ts b/understand-anything-plugin/packages/core/src/languages/configs/javascript.ts index d89cf4997..851253df8 100644 --- a/understand-anything-plugin/packages/core/src/languages/configs/javascript.ts +++ b/understand-anything-plugin/packages/core/src/languages/configs/javascript.ts @@ -23,7 +23,7 @@ export const javascriptConfig = { filePatterns: { entryPoints: ["index.js", "src/index.js", "main.js"], barrels: ["index.js"], - tests: ["*.test.js", "*.spec.js"], + tests: ["*.test.js", "*.spec.js", "*.test.jsx", "*.spec.jsx"], config: ["package.json", "jsconfig.json"], }, } satisfies LanguageConfig; diff --git a/understand-anything-plugin/packages/core/src/languages/configs/typescript.ts b/understand-anything-plugin/packages/core/src/languages/configs/typescript.ts index 9493af798..f94246079 100644 --- a/understand-anything-plugin/packages/core/src/languages/configs/typescript.ts +++ b/understand-anything-plugin/packages/core/src/languages/configs/typescript.ts @@ -3,6 +3,11 @@ import type { LanguageConfig } from "../types.js"; export const typescriptConfig = { id: "typescript", displayName: "TypeScript", + // Declaration files (.d.ts / .d.mts / .d.cts) are intentionally NOT listed + // separately: getForFile() resolves by the final extension, so they fall + // through to .ts / .mts / .cts and are parsed as ordinary (types-only) + // TypeScript. They carry no runtime exports or call edges, so the extractor + // simply yields an empty call graph for them — no special gating is applied. extensions: [".ts", ".tsx", ".mts", ".cts"], treeSitter: { wasmPackage: "tree-sitter-typescript", diff --git a/understand-anything-plugin/packages/core/src/plugins/tree-sitter-plugin.ts b/understand-anything-plugin/packages/core/src/plugins/tree-sitter-plugin.ts index 65203d255..9c0bc1010 100644 --- a/understand-anything-plugin/packages/core/src/plugins/tree-sitter-plugin.ts +++ b/understand-anything-plugin/packages/core/src/plugins/tree-sitter-plugin.ts @@ -111,7 +111,10 @@ export class TreeSitterPlugin implements AnalyzerPlugin { private languageKeyFromPath(filePath: string): string | null { const ext = extname(filePath).toLowerCase(); - // Special case: .tsx needs its own grammar + // Special case: only .tsx needs the dedicated TSX grammar (it carries JSX). + // .mts / .cts deliberately fall through to the plain TypeScript grammar via + // _extensionToLang — they cannot contain JSX, so do NOT add them to this + // branch by analogy with the .mjs-treated-as-JS pattern. if (ext === ".tsx") return "tsx"; return this._extensionToLang.get(ext) ?? null;