java-codebase-rag 0.12.0__py3-none-any.whl → 0.12.2__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.
Files changed (77) hide show
  1. java_codebase_rag-0.12.2.dist-info/METADATA +35 -0
  2. java_codebase_rag-0.12.2.dist-info/RECORD +4 -0
  3. {java_codebase_rag-0.12.0.dist-info → java_codebase_rag-0.12.2.dist-info}/WHEEL +1 -1
  4. java_codebase_rag/_deprecation.py +0 -103
  5. java_codebase_rag/_fdlimit.py +0 -56
  6. java_codebase_rag/_stdio.py +0 -32
  7. java_codebase_rag/_version.py +0 -35
  8. java_codebase_rag/absence/__init__.py +0 -0
  9. java_codebase_rag/absence/absence_diagnosis.py +0 -700
  10. java_codebase_rag/absence/absence_types.py +0 -124
  11. java_codebase_rag/absence/absence_vocab.py +0 -460
  12. java_codebase_rag/analysis/__init__.py +0 -0
  13. java_codebase_rag/analysis/pr_analysis.py +0 -563
  14. java_codebase_rag/analysis/resolve_service.py +0 -740
  15. java_codebase_rag/ast/__init__.py +0 -0
  16. java_codebase_rag/ast/ast_java.py +0 -2847
  17. java_codebase_rag/ast/ast_kotlin.py +0 -1794
  18. java_codebase_rag/ast/brownfield_events.py +0 -58
  19. java_codebase_rag/ast/chunk_heuristics.py +0 -83
  20. java_codebase_rag/ast/language.py +0 -117
  21. java_codebase_rag/cli.py +0 -1215
  22. java_codebase_rag/cli_dispatch.py +0 -251
  23. java_codebase_rag/cli_format.py +0 -85
  24. java_codebase_rag/cli_progress.py +0 -94
  25. java_codebase_rag/config.py +0 -833
  26. java_codebase_rag/eval/__init__.py +0 -1
  27. java_codebase_rag/eval/ground_truth.py +0 -100
  28. java_codebase_rag/eval/metrics.py +0 -107
  29. java_codebase_rag/eval/runner.py +0 -556
  30. java_codebase_rag/graph/__init__.py +0 -0
  31. java_codebase_rag/graph/build_ast_graph.py +0 -4593
  32. java_codebase_rag/graph/graph_enrich.py +0 -1940
  33. java_codebase_rag/graph/graph_types.py +0 -224
  34. java_codebase_rag/graph/java_ontology.py +0 -465
  35. java_codebase_rag/graph/ladybug_queries.py +0 -2213
  36. java_codebase_rag/graph/path_filtering.py +0 -509
  37. java_codebase_rag/index/__init__.py +0 -0
  38. java_codebase_rag/index/java_index_flow_lancedb.py +0 -879
  39. java_codebase_rag/index/java_index_v1_common.py +0 -33
  40. java_codebase_rag/install_data/__init__.py +0 -0
  41. java_codebase_rag/install_data/agents/explorer-rag-cli.md +0 -110
  42. java_codebase_rag/install_data/agents/explorer-rag-enhanced.md +0 -152
  43. java_codebase_rag/install_data/skills/explore-codebase/SKILL.md +0 -165
  44. java_codebase_rag/install_data/skills/explore-codebase-cli/SKILL.md +0 -107
  45. java_codebase_rag/installer.py +0 -2188
  46. java_codebase_rag/jrag.py +0 -4545
  47. java_codebase_rag/jrag_envelope.py +0 -1107
  48. java_codebase_rag/jrag_hints.py +0 -204
  49. java_codebase_rag/jrag_render.py +0 -926
  50. java_codebase_rag/lance_optimize.py +0 -264
  51. java_codebase_rag/mcp/__init__.py +0 -0
  52. java_codebase_rag/mcp/mcp_hints.py +0 -932
  53. java_codebase_rag/mcp/mcp_v2.py +0 -1916
  54. java_codebase_rag/mcp/server.py +0 -886
  55. java_codebase_rag/pipeline.py +0 -531
  56. java_codebase_rag/progress.py +0 -570
  57. java_codebase_rag/read_payloads.py +0 -781
  58. java_codebase_rag/search/__init__.py +0 -0
  59. java_codebase_rag/search/index_common.py +0 -10
  60. java_codebase_rag/search/search_lancedb.py +0 -1296
  61. java_codebase_rag/search/search_lexical.py +0 -449
  62. java_codebase_rag/search/search_scoring.py +0 -537
  63. java_codebase_rag/watch/__init__.py +0 -0
  64. java_codebase_rag/watch/client.py +0 -230
  65. java_codebase_rag/watch/daemon.py +0 -396
  66. java_codebase_rag/watch/lock.py +0 -201
  67. java_codebase_rag/watch/paths.py +0 -76
  68. java_codebase_rag/watch/protocol.py +0 -122
  69. java_codebase_rag/watch/server.py +0 -273
  70. java_codebase_rag/watch/warm.py +0 -105
  71. java_codebase_rag/watch/watcher.py +0 -394
  72. java_codebase_rag-0.12.0.dist-info/METADATA +0 -340
  73. java_codebase_rag-0.12.0.dist-info/RECORD +0 -75
  74. java_codebase_rag-0.12.0.dist-info/entry_points.txt +0 -5
  75. java_codebase_rag-0.12.0.dist-info/licenses/LICENSE +0 -21
  76. java_codebase_rag-0.12.0.dist-info/top_level.txt +0 -1
  77. /java_codebase_rag/__init__.py → /java_codebase_rag-0.12.2.dist-info/top_level.txt +0 -0
@@ -1,58 +0,0 @@
1
- """Structured stderr events for brownfield extraction (PR-1 scaffolding; PR-2 wiring).
2
-
3
- Each call emits one JSON object on a single line to sys.stderr. MCP stdio servers
4
- must not use this module from tool handlers — graph build / AST paths only.
5
- """
6
- from __future__ import annotations
7
-
8
- import json
9
- import sys
10
- from typing import Any
11
-
12
- _VALID_SEVERITIES = frozenset({"INFO", "WARN"})
13
- _VALID_EVENTS = frozenset(
14
- {
15
- "brownfield-exclusivity-shadowing",
16
- "brownfield-method-string-literal",
17
- }
18
- )
19
-
20
-
21
- def emit_structured_brownfield_event(
22
- event_id: str,
23
- severity_level: str,
24
- **fields: Any,
25
- ) -> None:
26
- """Emit one JSON line to stderr with keys ``event`` and ``severity`` plus ``**fields``.
27
-
28
- Parameters are named ``event_id`` / ``severity_level`` so ``**fields`` may contain
29
- keys ``event`` or ``severity`` without a caller TypeError; those keys never override
30
- the canonical record (reserved keys are merged last).
31
- """
32
- if severity_level not in _VALID_SEVERITIES:
33
- raise ValueError(
34
- f"severity must be one of {_VALID_SEVERITIES}, got {severity_level!r}"
35
- )
36
- if event_id not in _VALID_EVENTS:
37
- raise ValueError(f"event must be one of {_VALID_EVENTS}, got {event_id!r}")
38
- # Fields first so JSON ``event`` / ``severity`` always match event_id / severity_level.
39
- payload = {**fields, "event": event_id, "severity": severity_level}
40
- print(json.dumps(payload, ensure_ascii=False), file=sys.stderr, flush=True)
41
-
42
-
43
- def emit_brownfield_exclusivity_shadowing(**fields: Any) -> None:
44
- """INFO: brownfield HTTP annotation co-present with shadowable framework annotations."""
45
- emit_structured_brownfield_event(
46
- "brownfield-exclusivity-shadowing",
47
- "INFO",
48
- **fields,
49
- )
50
-
51
-
52
- def emit_brownfield_method_string_literal(**fields: Any) -> None:
53
- """WARN: HTTP client/route `method` still a string literal (migration / misuse)."""
54
- emit_structured_brownfield_event(
55
- "brownfield-method-string-literal",
56
- "WARN",
57
- **fields,
58
- )
@@ -1,83 +0,0 @@
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
- # Kotlin type declarations. Covers ``class`` / ``interface`` / ``object`` /
26
- # ``enum class`` plus the modifiers Kotlin uses (``internal`` / ``open`` / etc.).
27
- # ``object`` is the Kotlin-specific kind the Java regex misses; top-level
28
- # ``fun`` is intentionally NOT a type declaration (no name to pin a type to).
29
- _KOTLIN_TYPE = re.compile(
30
- r"\b(?:public\s+|private\s+|protected\s+|internal\s+|"
31
- r"final\s+|open\s+|abstract\s+|sealed\s+|data\s+)*"
32
- r"(?:class|interface|object|enum\s+class)\s+([A-Za-z_][A-Za-z0-9_]*)"
33
- )
34
-
35
-
36
- def analyze_chunk(text: str | None, *, language: str, kind: str) -> ChunkHints:
37
- if not text or not text.strip():
38
- return ChunkHints()
39
-
40
- lines = text.strip().split("\n")
41
- n = len(lines)
42
- lang = (language or "").lower()
43
- # Kotlin chunks live in the java LanceDB table (``kind == "java"``), so the
44
- # ``language`` field — not ``kind`` — is what distinguishes them. Detect
45
- # Kotlin first so the Kotlin regex wins for ``object`` / Kotlin modifiers.
46
- is_kotlin = lang == "kotlin"
47
- is_java = not is_kotlin and (kind == "java" or lang == "java")
48
-
49
- # Both Java and Kotlin use ``import <pkg.Type>`` lines (Java ends the line
50
- # with ``;``, Kotlin does not), so the import-density heuristic matches on
51
- # the ``import `` prefix only — the trailing-``;`` difference is irrelevant.
52
- import_heavy = False
53
- if (is_java or is_kotlin) and n >= 3:
54
- imp = sum(1 for L in lines if L.lstrip().startswith("import "))
55
- import_heavy = imp / n >= 0.55
56
-
57
- primary: str | None = None
58
- head = "\n".join(lines[: min(80, n)])
59
- if is_kotlin:
60
- m = _KOTLIN_TYPE.search(head)
61
- if m:
62
- primary = m.group(1)
63
- elif is_java:
64
- m = _JAVA_TYPE.search(head)
65
- if m:
66
- primary = m.group(1)
67
-
68
- return ChunkHints(
69
- primary_type_hint=primary,
70
- import_heavy=import_heavy,
71
- )
72
-
73
-
74
- def looks_like_code_identifier(query: str) -> bool:
75
- """PascalCase type name or SCREAMING_SNAKE constant — good candidates for FTS hybrid."""
76
- q = query.strip()
77
- if not q or len(q) < 2 or len(q) > 200:
78
- return False
79
- if re.fullmatch(r"[A-Z][a-zA-Z0-9_]*", q):
80
- return True
81
- if "_" in q and re.fullmatch(r"[A-Z][A-Z0-9_]*", q):
82
- return True
83
- return False
@@ -1,117 +0,0 @@
1
- """Language-dispatch seam for AST extraction.
2
-
3
- A registry of ``LanguageBackend`` objects keyed by ``language_id``; each backend
4
- owns the source suffixes it claims (``.java`` always; ``.kt`` when the
5
- ``tree-sitter-kotlin`` grammar imports) and a ``parse`` entry point returning a
6
- ``JavaFileAst`` — the single AST shape shared by both languages (Kotlin reuses
7
- this surface; it does not introduce a separate type).
8
-
9
- Both backends parse into ``JavaFileAst``, so ``FileAst`` remains a direct alias
10
- for ``JavaFileAst``. The Kotlin backend is registered conditionally on the
11
- grammar wheel importing (see the ``try``/``except ImportError`` below); a
12
- minimal or graph-only install with no ``tree-sitter-kotlin`` simply has Java in
13
- the registry, and ``backend_for`` returns ``None`` for ``.kt``.
14
-
15
- Import cycle note: ``ast_java`` defines ``JavaFileAst`` whose ``__post_init__``
16
- validates against ``KNOWN_LANGUAGE_IDS`` (defined here). To keep the cycle
17
- one-directional, ``ast_java`` does NOT import this module at top level — it
18
- imports ``KNOWN_LANGUAGE_IDS`` lazily inside ``__post_init__``. This module
19
- freely imports from ``ast_java``.
20
- """
21
- from __future__ import annotations
22
-
23
- from pathlib import Path
24
- from typing import Protocol, runtime_checkable
25
-
26
- from java_codebase_rag.ast.ast_java import JavaFileAst, parse_java
27
-
28
- __all__ = [
29
- "LanguageBackend",
30
- "JavaBackend",
31
- "LANG_BACKENDS",
32
- "KNOWN_LANGUAGE_IDS",
33
- "backend_for",
34
- "FileAst",
35
- ]
36
-
37
-
38
- @runtime_checkable
39
- class LanguageBackend(Protocol):
40
- """A pluggable parser backend for one source language."""
41
-
42
- language_id: str
43
- suffixes: tuple[str, ...]
44
-
45
- def parse(
46
- self,
47
- source: bytes | str,
48
- *,
49
- filename: str,
50
- verbose: bool = False,
51
- ) -> JavaFileAst: ...
52
-
53
-
54
- class JavaBackend:
55
- """The Java backend — delegates to the existing tree-sitter ``parse_java``."""
56
-
57
- language_id: str = "java"
58
- suffixes: tuple[str, ...] = (".java",)
59
-
60
- def parse(
61
- self, source: bytes | str, *, filename: str = "", verbose: bool = False
62
- ) -> JavaFileAst:
63
- return parse_java(source, filename=filename, verbose=verbose)
64
-
65
-
66
- # Registry: language_id -> backend. Kotlin is appended conditionally on the
67
- # grammar wheel importing (try/except below), so minimal/graph-only installs
68
- # simply skip `.kt` files instead of crashing at import time.
69
- LANG_BACKENDS: dict[str, LanguageBackend] = {
70
- "java": JavaBackend(),
71
- }
72
-
73
- # Conditional Kotlin registration. The grammar wheel (tree-sitter-kotlin) is an
74
- # optional dependency on some platforms (Intel-Mac graph-only installs); when it
75
- # is absent, KotlinBackend stays out of the registry and ``backend_for`` returns
76
- # ``None`` for ``.kt`` — the file is then skipped by every parse site.
77
- try: # pragma: no cover - branch depends on whether the wheel is installed
78
- import tree_sitter_kotlin as _ts_kotlin # noqa: F401
79
-
80
- from java_codebase_rag.ast.ast_kotlin import parse_kotlin as _parse_kotlin
81
-
82
- class KotlinBackend:
83
- """The Kotlin backend — delegates to ``parse_kotlin``."""
84
-
85
- language_id: str = "kotlin"
86
- suffixes: tuple[str, ...] = (".kt",)
87
-
88
- def parse(
89
- self, source: bytes | str, *, filename: str = "", verbose: bool = False
90
- ) -> JavaFileAst:
91
- return _parse_kotlin(source, filename=filename, verbose=verbose)
92
-
93
- LANG_BACKENDS["kotlin"] = KotlinBackend()
94
- except ImportError:
95
- pass
96
-
97
- # Derived from the registry so the two never drift apart.
98
- KNOWN_LANGUAGE_IDS: frozenset[str] = frozenset(LANG_BACKENDS.keys())
99
-
100
-
101
- def backend_for(path: Path | str) -> LanguageBackend | None:
102
- """Return the first backend whose ``suffixes`` contain ``path``'s suffix.
103
-
104
- Suffix matching is case-sensitive against ``Path(path).suffix``. Returns
105
- ``None`` when no backend claims the file (e.g. ``.md``), or for a ``.kt``
106
- file on an install where the ``tree-sitter-kotlin`` grammar is absent.
107
- """
108
- suffix = Path(path).suffix
109
- for backend in LANG_BACKENDS.values():
110
- if suffix in backend.suffixes:
111
- return backend
112
- return None
113
-
114
-
115
- # Single-language alias. Re-exported so downstream call sites can target the
116
- # generic name and stay source-stable when a Kotlin AST shape is introduced.
117
- FileAst = JavaFileAst