Local code intelligence for developers and AI agents. Connect code, docs and infrastructure in a persistent graph, with CBM Lens, MCP tools, agent integrations and change-aware test selection.
C aiderastclaude-codecode-analysiscode-intelligencecodexcursorcypherdeveloper-toolsgemini-cligraph-visualizationkilocodeknowledge-graphmcpmcp-servermodel-context-protocolopencodesqlitetree-sitterwindsurf
fix(discover): map .mjs/.cjs (JS) and .mts/.cts (TS) extensions (#197)
Martin Vogel2de984bdb6ac
diff --git a/src/discover/language.c b/src/discover/language.cindex b7b9a7d5e..c80c2635c 100644--- a/src/discover/language.c+++ b/src/discover/language.c@@ -145,6 +145,8 @@ static const ext_entry_t EXT_TABLE[] = {/* JavaScript */{".js", CBM_LANG_JAVASCRIPT},{".jsx", CBM_LANG_JAVASCRIPT},+ {".mjs", CBM_LANG_JAVASCRIPT}, /* ES modules (#197) */+ {".cjs", CBM_LANG_JAVASCRIPT}, /* CommonJS modules *//* JSON */{".json", CBM_LANG_JSON},@@ -241,6 +243,8 @@ static const ext_entry_t EXT_TABLE[] = {/* TypeScript */{".ts", CBM_LANG_TYPESCRIPT},+ {".mts", CBM_LANG_TYPESCRIPT}, /* TS ES modules */+ {".cts", CBM_LANG_TYPESCRIPT}, /* TS CommonJS modules *//* VimScript */{".vim", CBM_LANG_VIMSCRIPT},diff --git a/tests/test_language.c b/tests/test_language.cindex 3ccd0eb2d..fbf72bd89 100644--- a/tests/test_language.c+++ b/tests/test_language.c@@ -25,6 +25,18 @@ TEST(lang_ext_jsx) {ASSERT_EQ(cbm_language_for_extension(".jsx"), CBM_LANG_JAVASCRIPT);PASS();}+/* Issue #197: .mjs (ES modules) / .cjs (CommonJS) were unmapped, so those+ * files were never indexed or searchable. */+TEST(lang_ext_mjs_cjs) {+ ASSERT_EQ(cbm_language_for_extension(".mjs"), CBM_LANG_JAVASCRIPT);+ ASSERT_EQ(cbm_language_for_extension(".cjs"), CBM_LANG_JAVASCRIPT);+ PASS();+}+TEST(lang_ext_mts_cts) {+ ASSERT_EQ(cbm_language_for_extension(".mts"), CBM_LANG_TYPESCRIPT);+ ASSERT_EQ(cbm_language_for_extension(".cts"), CBM_LANG_TYPESCRIPT);+ PASS();+}TEST(lang_ext_typescript) {ASSERT_EQ(cbm_language_for_extension(".ts"), CBM_LANG_TYPESCRIPT);PASS();@@ -543,7 +555,8 @@ TEST(lang_name_unknown) {/* These tests need temp files with content markers */TEST(lang_m_objc) {/* Write a temp file with Objective-C markers */- char path[256]; snprintf(path, sizeof(path), "%s/test_lang_objc.m", cbm_tmpdir());+ char path[256];+ snprintf(path, sizeof(path), "%s/test_lang_objc.m", cbm_tmpdir());FILE *f = fopen(path, "w");ASSERT_NOT_NULL(f);fprintf(f, "#import <Foundation/Foundation.h>\n@interface Foo : NSObject\n@end\n");@@ -555,7 +568,8 @@ TEST(lang_m_objc) {}TEST(lang_m_magma) {- char path[256]; snprintf(path, sizeof(path), "%s/test_lang_magma.m", cbm_tmpdir());+ char path[256];+ snprintf(path, sizeof(path), "%s/test_lang_magma.m", cbm_tmpdir());FILE *f = fopen(path, "w");ASSERT_NOT_NULL(f);fprintf(f, "function MyFunc(x)\n return x^2;\nend function;\n");@@ -567,7 +581,8 @@ TEST(lang_m_magma) {}TEST(lang_m_matlab) {- char path[256]; snprintf(path, sizeof(path), "%s/test_lang_matlab.m", cbm_tmpdir());+ char path[256];+ snprintf(path, sizeof(path), "%s/test_lang_matlab.m", cbm_tmpdir());FILE *f = fopen(path, "w");ASSERT_NOT_NULL(f);fprintf(f, "function y = square(x)\n y = x.^2;\nend\n");@@ -997,7 +1012,6 @@ TEST(lang_ext_sosl) {PASS();}-/* --- Ported from lang_test.go: TestForLanguage --- */TEST(lang_all_have_names) {/* Every language enum value from 0 to CBM_LANG_COUNT-1@@ -1018,6 +1032,8 @@ SUITE(language) {RUN_TEST(lang_ext_python);RUN_TEST(lang_ext_javascript);RUN_TEST(lang_ext_jsx);+ RUN_TEST(lang_ext_mjs_cjs);+ RUN_TEST(lang_ext_mts_cts);RUN_TEST(lang_ext_typescript);RUN_TEST(lang_ext_tsx);RUN_TEST(lang_ext_rust);