Version
v0.9.0 and current main at 7d6cdb23ef5ca2fd51f5d5b7509b33e112ef15f3
Platform
Linux (x64)
Install channel
Built from source
Binary variant
standard
What happened, and what did you expect?
An extensionless executable script is silently excluded from discovery even when its first line unambiguously declares a supported language:
#!/usr/bin/env python3
def extensionless_probe():
return 42
cbm_language_for_filename("tool") returns CBM_LANG_COUNT, and detect_file_language() returns immediately without inspecting the shebang. The file therefore produces no File or Function nodes, and graph/code searches are indistinguishable from a true negative.
Expected behavior: preserve existing special-filename and extension detection, but when they return unknown, inspect a bounded first line and infer a supported scripting language from a valid shebang.
Reproduction
- Create a dummy repository:
mkdir -p /tmp/cbm-shebang-repro/bin
cat >/tmp/cbm-shebang-repro/bin/tool <<'PY'
#!/usr/bin/env python3
def extensionless_probe():
return 42
PY
chmod +x /tmp/cbm-shebang-repro/bin/tool
- Index it:
codebase-memory-mcp cli index_repository '{"repo_path":"/tmp/cbm-shebang-repro","mode":"full"}'
- Search for
extensionless_probe with search_graph or search_code.
Actual: zero results; the file is absent from discovery. Expected: Python File/Function nodes and a matching search result.
The executable bit is not essential to parsing; the shebang is the language signal and should also work on platforms without POSIX mode bits.
Proposed fix
- Keep filename/extension mappings authoritative.
- Only when they return unknown, read at most the first line.
- Recognize direct interpreter paths plus
/usr/bin/env forms, including env -S.
- Match interpreter basenames exactly (with version suffixes such as
python3.12 where applicable).
- Reject malformed/NUL-containing lines and read failures as unknown.
- Add reproduce-first discovery tests for direct Python,
env python3, env -S python3 -u, precedence, and negative inputs.
Related work checked
Confirmations
Version
v0.9.0and currentmainat7d6cdb23ef5ca2fd51f5d5b7509b33e112ef15f3Platform
Linux (x64)
Install channel
Built from source
Binary variant
standard
What happened, and what did you expect?
An extensionless executable script is silently excluded from discovery even when its first line unambiguously declares a supported language:
cbm_language_for_filename("tool")returnsCBM_LANG_COUNT, anddetect_file_language()returns immediately without inspecting the shebang. The file therefore produces noFileorFunctionnodes, and graph/code searches are indistinguishable from a true negative.Expected behavior: preserve existing special-filename and extension detection, but when they return unknown, inspect a bounded first line and infer a supported scripting language from a valid shebang.
Reproduction
codebase-memory-mcp cli index_repository '{"repo_path":"/tmp/cbm-shebang-repro","mode":"full"}'extensionless_probewithsearch_graphorsearch_code.Actual: zero results; the file is absent from discovery. Expected: Python
File/Functionnodes and a matching search result.The executable bit is not essential to parsing; the shebang is the language signal and should also work on platforms without POSIX mode bits.
Proposed fix
/usr/bin/envforms, includingenv -S.python3.12where applicable).env python3,env -S python3 -u, precedence, and negative inputs.Related work checked
extra_extensions(feat(discover): user-defined extension→language mappings (C port) #73/docs(config): document extra_extensions values and skip behavior #487) maps extensions only and cannot represent an extensionless basename.Confirmations