Skip to content

search_code returns 0 results for .mjs files #197

Closed

Description

@tomerikjansen-crypto

Description

search_code returns zero results for any pattern searched in .mjs (ES module) files, even though the files are indexed and search_graph finds nodes within them.

Environment

  • Version: 0.5.7 (upgraded from 0.4.10, same issue on both)
  • OS: Windows 11 Pro 10.0.26300
  • Project: Mixed codebase — Python (.py), JavaScript (.mjs, .jsx, .js), Markdown

Steps to Reproduce

  1. Index a repository containing .mjs files (Express server routes in our case)
  2. Run search_code with a pattern that exists in those files
{
  "pattern": "router.get",
  "project": "my-project",
  "path_filter": "dashboard/server",
  "mode": "compact",
  "limit": 10
}

Result: {"results":[], "total_grep_matches": 0, "total_results": 0}

  1. Verify with native grep — the pattern exists in 9 files (25 occurrences):
server/routes/archive.mjs:1
server/routes/hurtiglogg.mjs:3
server/routes/projects.mjs:4
server/routes/tidslinje.mjs:2
server/routes/economics.mjs:6
server/routes/epost.mjs:1
server/routes/planner.mjs:2
server/routes/system.mjs:2
server/routes/tasks.mjs:4

Additional patterns tested (all return 0 for .mjs)

  • asyncHandler — used in 40+ route handlers across .mjs files → 0 results
  • router.post → 0 results
  • process.env → 0 results (when filtered to *.mjs)

What works

  • search_graph with label: Route returns nodes from .mjs files — so indexing parses them correctly
  • search_code works for .py and .js files
  • Native grep/ripgrep finds all patterns correctly

Likely cause

The internal grep in search_code may not include .mjs in its list of recognized JavaScript file extensions, so it skips these files entirely during the text search phase. The graph indexer (tree-sitter) handles them fine.

Workaround

Using the file_pattern parameter with *.mjs also returns 0, so there is no workaround within the tool.

Activity

  1. added
    bugSomething isn't working
    parsing/qualityGraph extraction bugs, false positives, missing edges
    on Apr 3, 2026
  2. DeusData commented on May 31, 2026

    @DeusData
    Owner

    Fixed. Root cause: .mjs (and .cjs) were missing from the extension→language table, so those files were never assigned a language — they weren't indexed at all (no graph nodes), and search_code (which greps the set of indexed files) therefore returned 0 for any pattern in them. (.js/.jsx were mapped, which is why plain .js worked.)

    Added .mjs/.cjs → JavaScript and .mts/.cts → TypeScript. Verified end-to-end on macOS: a function in server.mjs is now extracted and returned by search_code (total_results=1). Regression tests lang_ext_mjs_cjs / lang_ext_mts_cts added. Closes #197. 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingparsing/qualityGraph extraction bugs, false positives, missing edges

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions