java-codebase-rag 0.1.0__py3-none-any.whl
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.
- ast_java.py +2813 -0
- brownfield_events.py +58 -0
- build_ast_graph.py +3081 -0
- chunk_heuristics.py +62 -0
- graph_enrich.py +1681 -0
- index_common.py +10 -0
- java_codebase_rag/__init__.py +1 -0
- java_codebase_rag/cli.py +761 -0
- java_codebase_rag/cli_progress.py +52 -0
- java_codebase_rag/config.py +327 -0
- java_codebase_rag/pipeline.py +189 -0
- java_codebase_rag-0.1.0.dist-info/METADATA +818 -0
- java_codebase_rag-0.1.0.dist-info/RECORD +27 -0
- java_codebase_rag-0.1.0.dist-info/WHEEL +5 -0
- java_codebase_rag-0.1.0.dist-info/entry_points.txt +3 -0
- java_codebase_rag-0.1.0.dist-info/licenses/LICENSE +21 -0
- java_codebase_rag-0.1.0.dist-info/top_level.txt +17 -0
- java_index_flow_lancedb.py +398 -0
- java_index_v1_common.py +33 -0
- java_ontology.py +446 -0
- kuzu_queries.py +1989 -0
- mcp_hints.py +748 -0
- mcp_v2.py +1957 -0
- path_filtering.py +472 -0
- pr_analysis.py +534 -0
- search_lancedb.py +1075 -0
- server.py +578 -0
chunk_heuristics.py
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"""Lightweight, query-time hints from chunk text — no AST / re-index required."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import re
|
|
6
|
+
from dataclasses import dataclass
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
@dataclass
|
|
10
|
+
class ChunkHints:
|
|
11
|
+
"""Heuristic metadata derived from a chunk's text."""
|
|
12
|
+
|
|
13
|
+
primary_type_hint: str | None = None
|
|
14
|
+
"""First top-level ``class`` / ``interface`` / ``enum`` / ``record`` name in the chunk."""
|
|
15
|
+
|
|
16
|
+
import_heavy: bool = False
|
|
17
|
+
"""True when most lines are ``import`` statements (low semantic density)."""
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
_JAVA_TYPE = re.compile(
|
|
21
|
+
r"\b(?:public\s+|private\s+|protected\s+|sealed\s+|final\s+|abstract\s+|static\s+)*"
|
|
22
|
+
r"(?:class|interface|enum|record)\s+([A-Za-z_][A-Za-z0-9_]*)"
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def analyze_chunk(text: str | None, *, language: str, kind: str) -> ChunkHints:
|
|
27
|
+
if not text or not text.strip():
|
|
28
|
+
return ChunkHints()
|
|
29
|
+
|
|
30
|
+
lines = text.strip().split("\n")
|
|
31
|
+
n = len(lines)
|
|
32
|
+
lang = (language or "").lower()
|
|
33
|
+
is_java = kind == "java" or lang == "java"
|
|
34
|
+
|
|
35
|
+
import_heavy = False
|
|
36
|
+
if is_java and n >= 3:
|
|
37
|
+
imp = sum(1 for L in lines if L.lstrip().startswith("import "))
|
|
38
|
+
import_heavy = imp / n >= 0.55
|
|
39
|
+
|
|
40
|
+
primary: str | None = None
|
|
41
|
+
if is_java:
|
|
42
|
+
head = "\n".join(lines[: min(80, n)])
|
|
43
|
+
m = _JAVA_TYPE.search(head)
|
|
44
|
+
if m:
|
|
45
|
+
primary = m.group(1)
|
|
46
|
+
|
|
47
|
+
return ChunkHints(
|
|
48
|
+
primary_type_hint=primary,
|
|
49
|
+
import_heavy=import_heavy,
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def looks_like_code_identifier(query: str) -> bool:
|
|
54
|
+
"""PascalCase type name or SCREAMING_SNAKE constant — good candidates for FTS hybrid."""
|
|
55
|
+
q = query.strip()
|
|
56
|
+
if not q or len(q) < 2 or len(q) > 200:
|
|
57
|
+
return False
|
|
58
|
+
if re.fullmatch(r"[A-Z][a-zA-Z0-9_]*", q):
|
|
59
|
+
return True
|
|
60
|
+
if "_" in q and re.fullmatch(r"[A-Z][A-Z0-9_]*", q):
|
|
61
|
+
return True
|
|
62
|
+
return False
|