contextl 1.2.46 → 1.2.48

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "contextl",
3
- "version": "1.2.46",
3
+ "version": "1.2.48",
4
4
  "description": "contextl — finds the most relevant files in your codebase for any change request. MCP server for AI coding agents.",
5
5
  "keywords": [
6
6
  "mcp",
@@ -605,7 +605,16 @@ def _find_file_in_repo(
605
605
  matches.append(path)
606
606
 
607
607
  if matches:
608
- matches.sort(key=lambda p: (p.count("/"), 0 if p.endswith("__init__.py") else 1))
608
+ if source_file:
609
+ def _sort_key(p):
610
+ is_init = 0 if p.endswith("__init__.py") else 1
611
+ if is_init == 0:
612
+ return (is_init, p.count("/"), _path_distance(source_file, p))
613
+ else:
614
+ return (is_init, _path_distance(source_file, p), p.count("/"))
615
+ matches.sort(key=_sort_key)
616
+ else:
617
+ matches.sort(key=lambda p: (0 if p.endswith("__init__.py") else 1, p.count("/")))
609
618
  return matches[0]
610
619
 
611
620
  # Fallback for Python cross-language imports (e.g. from tests to .ts/.js core logic)
@@ -111,10 +111,14 @@ COMMON_ABBREVS = {
111
111
  "mid": "middleware"
112
112
  }
113
113
 
114
+ REVERSE_ABBREVS = {v: k for k, v in COMMON_ABBREVS.items()}
115
+
114
116
  def _is_match(term: str, target: str) -> bool:
115
117
  term_canon = COMMON_ABBREVS.get(term, term)
116
118
  if term_canon in target or target in term_canon or target.startswith(term_canon) or term_canon.startswith(target):
117
119
  return True
120
+ if target == REVERSE_ABBREVS.get(term_canon):
121
+ return True
118
122
  return False
119
123
 
120
124