java-codebase-rag 0.11.2__tar.gz → 0.12.0__tar.gz
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.
- {java_codebase_rag-0.11.2/src/java_codebase_rag.egg-info → java_codebase_rag-0.12.0}/PKG-INFO +31 -22
- {java_codebase_rag-0.11.2 → java_codebase_rag-0.12.0}/README.md +24 -16
- {java_codebase_rag-0.11.2 → java_codebase_rag-0.12.0}/pyproject.toml +10 -8
- java_codebase_rag-0.12.0/src/java_codebase_rag/_deprecation.py +103 -0
- {java_codebase_rag-0.11.2 → java_codebase_rag-0.12.0}/src/java_codebase_rag/_version.py +2 -2
- {java_codebase_rag-0.11.2 → java_codebase_rag-0.12.0}/src/java_codebase_rag/ast/ast_java.py +22 -0
- java_codebase_rag-0.12.0/src/java_codebase_rag/ast/ast_kotlin.py +1794 -0
- {java_codebase_rag-0.11.2 → java_codebase_rag-0.12.0}/src/java_codebase_rag/ast/chunk_heuristics.py +26 -5
- java_codebase_rag-0.12.0/src/java_codebase_rag/ast/language.py +117 -0
- {java_codebase_rag-0.11.2 → java_codebase_rag-0.12.0}/src/java_codebase_rag/cli.py +17 -17
- java_codebase_rag-0.12.0/src/java_codebase_rag/cli_dispatch.py +251 -0
- {java_codebase_rag-0.11.2 → java_codebase_rag-0.12.0}/src/java_codebase_rag/config.py +8 -8
- {java_codebase_rag-0.11.2 → java_codebase_rag-0.12.0}/src/java_codebase_rag/eval/runner.py +3 -3
- {java_codebase_rag-0.11.2 → java_codebase_rag-0.12.0}/src/java_codebase_rag/graph/build_ast_graph.py +130 -8
- {java_codebase_rag-0.11.2 → java_codebase_rag-0.12.0}/src/java_codebase_rag/graph/graph_enrich.py +8 -5
- {java_codebase_rag-0.11.2 → java_codebase_rag-0.12.0}/src/java_codebase_rag/graph/ladybug_queries.py +1 -1
- {java_codebase_rag-0.11.2 → java_codebase_rag-0.12.0}/src/java_codebase_rag/graph/path_filtering.py +39 -7
- {java_codebase_rag-0.11.2 → java_codebase_rag-0.12.0}/src/java_codebase_rag/index/java_index_flow_lancedb.py +160 -15
- {java_codebase_rag-0.11.2 → java_codebase_rag-0.12.0}/src/java_codebase_rag/install_data/agents/explorer-rag-cli.md +6 -4
- {java_codebase_rag-0.11.2 → java_codebase_rag-0.12.0}/src/java_codebase_rag/install_data/agents/explorer-rag-enhanced.md +4 -4
- {java_codebase_rag-0.11.2 → java_codebase_rag-0.12.0}/src/java_codebase_rag/install_data/skills/explore-codebase/SKILL.md +4 -4
- {java_codebase_rag-0.11.2 → java_codebase_rag-0.12.0}/src/java_codebase_rag/install_data/skills/explore-codebase-cli/SKILL.md +5 -5
- {java_codebase_rag-0.11.2 → java_codebase_rag-0.12.0}/src/java_codebase_rag/installer.py +15 -15
- {java_codebase_rag-0.11.2 → java_codebase_rag-0.12.0}/src/java_codebase_rag/jrag.py +25 -11
- {java_codebase_rag-0.11.2 → java_codebase_rag-0.12.0}/src/java_codebase_rag/lance_optimize.py +7 -7
- {java_codebase_rag-0.11.2 → java_codebase_rag-0.12.0}/src/java_codebase_rag/mcp/mcp_v2.py +2 -2
- {java_codebase_rag-0.11.2 → java_codebase_rag-0.12.0}/src/java_codebase_rag/mcp/server.py +6 -4
- {java_codebase_rag-0.11.2 → java_codebase_rag-0.12.0}/src/java_codebase_rag/pipeline.py +4 -4
- {java_codebase_rag-0.11.2 → java_codebase_rag-0.12.0}/src/java_codebase_rag/progress.py +1 -1
- {java_codebase_rag-0.11.2 → java_codebase_rag-0.12.0}/src/java_codebase_rag/search/search_lexical.py +1 -1
- {java_codebase_rag-0.11.2 → java_codebase_rag-0.12.0}/src/java_codebase_rag/search/search_scoring.py +19 -5
- {java_codebase_rag-0.11.2 → java_codebase_rag-0.12.0}/src/java_codebase_rag/watch/lock.py +1 -1
- {java_codebase_rag-0.11.2 → java_codebase_rag-0.12.0}/src/java_codebase_rag/watch/watcher.py +45 -21
- {java_codebase_rag-0.11.2 → java_codebase_rag-0.12.0/src/java_codebase_rag.egg-info}/PKG-INFO +31 -22
- {java_codebase_rag-0.11.2 → java_codebase_rag-0.12.0}/src/java_codebase_rag.egg-info/SOURCES.txt +12 -1
- java_codebase_rag-0.12.0/src/java_codebase_rag.egg-info/entry_points.txt +5 -0
- {java_codebase_rag-0.11.2 → java_codebase_rag-0.12.0}/src/java_codebase_rag.egg-info/requires.txt +1 -0
- java_codebase_rag-0.12.0/tests/test_ast_kotlin.py +1125 -0
- {java_codebase_rag-0.11.2 → java_codebase_rag-0.12.0}/tests/test_docs_watch.py +2 -2
- java_codebase_rag-0.12.0/tests/test_kotlin_flow.py +227 -0
- java_codebase_rag-0.12.0/tests/test_kotlin_integration.py +335 -0
- java_codebase_rag-0.12.0/tests/test_kotlin_resolution.py +210 -0
- java_codebase_rag-0.12.0/tests/test_language_backend.py +252 -0
- java_codebase_rag-0.12.0/tests/test_same_fqn_collision.py +84 -0
- java_codebase_rag-0.12.0/tests/test_search_kotlin.py +169 -0
- java_codebase_rag-0.11.2/src/java_codebase_rag.egg-info/entry_points.txt +0 -4
- {java_codebase_rag-0.11.2 → java_codebase_rag-0.12.0}/LICENSE +0 -0
- {java_codebase_rag-0.11.2 → java_codebase_rag-0.12.0}/setup.cfg +0 -0
- {java_codebase_rag-0.11.2 → java_codebase_rag-0.12.0}/src/java_codebase_rag/__init__.py +0 -0
- {java_codebase_rag-0.11.2 → java_codebase_rag-0.12.0}/src/java_codebase_rag/_fdlimit.py +0 -0
- {java_codebase_rag-0.11.2 → java_codebase_rag-0.12.0}/src/java_codebase_rag/_stdio.py +0 -0
- {java_codebase_rag-0.11.2 → java_codebase_rag-0.12.0}/src/java_codebase_rag/absence/__init__.py +0 -0
- {java_codebase_rag-0.11.2 → java_codebase_rag-0.12.0}/src/java_codebase_rag/absence/absence_diagnosis.py +0 -0
- {java_codebase_rag-0.11.2 → java_codebase_rag-0.12.0}/src/java_codebase_rag/absence/absence_types.py +0 -0
- {java_codebase_rag-0.11.2 → java_codebase_rag-0.12.0}/src/java_codebase_rag/absence/absence_vocab.py +0 -0
- {java_codebase_rag-0.11.2 → java_codebase_rag-0.12.0}/src/java_codebase_rag/analysis/__init__.py +0 -0
- {java_codebase_rag-0.11.2 → java_codebase_rag-0.12.0}/src/java_codebase_rag/analysis/pr_analysis.py +0 -0
- {java_codebase_rag-0.11.2 → java_codebase_rag-0.12.0}/src/java_codebase_rag/analysis/resolve_service.py +0 -0
- {java_codebase_rag-0.11.2 → java_codebase_rag-0.12.0}/src/java_codebase_rag/ast/__init__.py +0 -0
- {java_codebase_rag-0.11.2 → java_codebase_rag-0.12.0}/src/java_codebase_rag/ast/brownfield_events.py +0 -0
- {java_codebase_rag-0.11.2 → java_codebase_rag-0.12.0}/src/java_codebase_rag/cli_format.py +0 -0
- {java_codebase_rag-0.11.2 → java_codebase_rag-0.12.0}/src/java_codebase_rag/cli_progress.py +0 -0
- {java_codebase_rag-0.11.2 → java_codebase_rag-0.12.0}/src/java_codebase_rag/eval/__init__.py +0 -0
- {java_codebase_rag-0.11.2 → java_codebase_rag-0.12.0}/src/java_codebase_rag/eval/ground_truth.py +0 -0
- {java_codebase_rag-0.11.2 → java_codebase_rag-0.12.0}/src/java_codebase_rag/eval/metrics.py +0 -0
- {java_codebase_rag-0.11.2 → java_codebase_rag-0.12.0}/src/java_codebase_rag/graph/__init__.py +0 -0
- {java_codebase_rag-0.11.2 → java_codebase_rag-0.12.0}/src/java_codebase_rag/graph/graph_types.py +0 -0
- {java_codebase_rag-0.11.2 → java_codebase_rag-0.12.0}/src/java_codebase_rag/graph/java_ontology.py +0 -0
- {java_codebase_rag-0.11.2 → java_codebase_rag-0.12.0}/src/java_codebase_rag/index/__init__.py +0 -0
- {java_codebase_rag-0.11.2 → java_codebase_rag-0.12.0}/src/java_codebase_rag/index/java_index_v1_common.py +0 -0
- {java_codebase_rag-0.11.2 → java_codebase_rag-0.12.0}/src/java_codebase_rag/install_data/__init__.py +0 -0
- {java_codebase_rag-0.11.2 → java_codebase_rag-0.12.0}/src/java_codebase_rag/jrag_envelope.py +0 -0
- {java_codebase_rag-0.11.2 → java_codebase_rag-0.12.0}/src/java_codebase_rag/jrag_hints.py +0 -0
- {java_codebase_rag-0.11.2 → java_codebase_rag-0.12.0}/src/java_codebase_rag/jrag_render.py +0 -0
- {java_codebase_rag-0.11.2 → java_codebase_rag-0.12.0}/src/java_codebase_rag/mcp/__init__.py +0 -0
- {java_codebase_rag-0.11.2 → java_codebase_rag-0.12.0}/src/java_codebase_rag/mcp/mcp_hints.py +0 -0
- {java_codebase_rag-0.11.2 → java_codebase_rag-0.12.0}/src/java_codebase_rag/read_payloads.py +0 -0
- {java_codebase_rag-0.11.2 → java_codebase_rag-0.12.0}/src/java_codebase_rag/search/__init__.py +0 -0
- {java_codebase_rag-0.11.2 → java_codebase_rag-0.12.0}/src/java_codebase_rag/search/index_common.py +0 -0
- {java_codebase_rag-0.11.2 → java_codebase_rag-0.12.0}/src/java_codebase_rag/search/search_lancedb.py +0 -0
- {java_codebase_rag-0.11.2 → java_codebase_rag-0.12.0}/src/java_codebase_rag/watch/__init__.py +0 -0
- {java_codebase_rag-0.11.2 → java_codebase_rag-0.12.0}/src/java_codebase_rag/watch/client.py +0 -0
- {java_codebase_rag-0.11.2 → java_codebase_rag-0.12.0}/src/java_codebase_rag/watch/daemon.py +0 -0
- {java_codebase_rag-0.11.2 → java_codebase_rag-0.12.0}/src/java_codebase_rag/watch/paths.py +0 -0
- {java_codebase_rag-0.11.2 → java_codebase_rag-0.12.0}/src/java_codebase_rag/watch/protocol.py +0 -0
- {java_codebase_rag-0.11.2 → java_codebase_rag-0.12.0}/src/java_codebase_rag/watch/server.py +0 -0
- {java_codebase_rag-0.11.2 → java_codebase_rag-0.12.0}/src/java_codebase_rag/watch/warm.py +0 -0
- {java_codebase_rag-0.11.2 → java_codebase_rag-0.12.0}/src/java_codebase_rag.egg-info/dependency_links.txt +0 -0
- {java_codebase_rag-0.11.2 → java_codebase_rag-0.12.0}/src/java_codebase_rag.egg-info/top_level.txt +0 -0
- {java_codebase_rag-0.11.2 → java_codebase_rag-0.12.0}/tests/test_config_watch.py +0 -0
{java_codebase_rag-0.11.2/src/java_codebase_rag.egg-info → java_codebase_rag-0.12.0}/PKG-INFO
RENAMED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: java-codebase-rag
|
|
3
|
-
Version: 0.
|
|
4
|
-
Summary: MCP server for semantic + structural search over Java codebases
|
|
3
|
+
Version: 0.12.0
|
|
4
|
+
Summary: jrag (formerly java-codebase-rag) — MCP server + jrag CLI for semantic + structural search over Java/Kotlin codebases
|
|
5
5
|
Author: HumanBean17
|
|
6
6
|
License-Expression: MIT
|
|
7
|
-
Project-URL: Homepage, https://github.com/HumanBean17/
|
|
8
|
-
Project-URL: Repository, https://github.com/HumanBean17/
|
|
9
|
-
Project-URL: Issues, https://github.com/HumanBean17/
|
|
10
|
-
Keywords:
|
|
7
|
+
Project-URL: Homepage, https://github.com/HumanBean17/jrag
|
|
8
|
+
Project-URL: Repository, https://github.com/HumanBean17/jrag
|
|
9
|
+
Project-URL: Issues, https://github.com/HumanBean17/jrag/issues
|
|
10
|
+
Keywords: jrag,java,mcp,rag,code-search,graph,lancedb,ladybug
|
|
11
11
|
Classifier: Development Status :: 3 - Alpha
|
|
12
12
|
Classifier: Intended Audience :: Developers
|
|
13
13
|
Classifier: Programming Language :: Python :: 3
|
|
@@ -35,6 +35,7 @@ Requires-Dist: rich<16,>=14
|
|
|
35
35
|
Requires-Dist: sentence-transformers<6,>=5.4.0; sys_platform != "darwin" or platform_machine != "x86_64"
|
|
36
36
|
Requires-Dist: tree-sitter<0.26,>=0.25.2
|
|
37
37
|
Requires-Dist: tree-sitter-java<0.24,>=0.23.5
|
|
38
|
+
Requires-Dist: tree-sitter-kotlin<2,>=1.1.0
|
|
38
39
|
Requires-Dist: unidiff<1,>=0.7.3
|
|
39
40
|
Requires-Dist: watchdog<7,>=6
|
|
40
41
|
Provides-Extra: dev
|
|
@@ -44,7 +45,7 @@ Requires-Dist: pytest-xdist>=3; extra == "dev"
|
|
|
44
45
|
Requires-Dist: ruff>=0.4; extra == "dev"
|
|
45
46
|
Dynamic: license-file
|
|
46
47
|
|
|
47
|
-
#
|
|
48
|
+
# jrag
|
|
48
49
|
|
|
49
50
|
A graph-native code intelligence layer for Java microservice estates, surfaced through the **`jrag` CLI** — one command per engineering intent. A **legacy MCP server** (`search` / `find` / `describe` / `neighbors` / `resolve`) is also available for existing setups. Both are thin surfaces over the same **AST Graph**: a deterministic property graph extracted from Java source with tree-sitter, stored **locally** in **LadybugDB** (graph) alongside a **LanceDB** vector index (chunks). There is no server to host and no cloud round-trip — the index lives on your disk and your source never leaves the machine. Both surfaces collapse onto three primitive operations: **locate**, **inspect**, **walk**.
|
|
50
51
|
|
|
@@ -82,15 +83,17 @@ The rest of this README is the install, the tool/command orientation, and the re
|
|
|
82
83
|
## Install
|
|
83
84
|
|
|
84
85
|
```bash
|
|
85
|
-
pip install
|
|
86
|
+
pip install jrag-cli
|
|
86
87
|
```
|
|
87
88
|
|
|
88
|
-
Python **3.11+** required, on **Linux, macOS, and Windows**. On Linux, Windows, and **Apple Silicon** Macs every native dependency (LanceDB, LadybugDB, CocoIndex) ships a wheel and you get the full semantic + graph search. **Intel Macs (x86_64) install graph-only**: PyTorch ≥2.3 and LanceDB ≥0.26 dropped macOS Intel wheels, so the vector stack is auto-excluded via PEP 508 markers — `pip install
|
|
89
|
+
Python **3.11+** required, on **Linux, macOS, and Windows**. On Linux, Windows, and **Apple Silicon** Macs every native dependency (LanceDB, LadybugDB, CocoIndex) ships a wheel and you get the full semantic + graph search. **Intel Macs (x86_64) install graph-only**: PyTorch ≥2.3 and LanceDB ≥0.26 dropped macOS Intel wheels, so the vector stack is auto-excluded via PEP 508 markers — `pip install jrag-cli` works out of the box, the graph layer (`find` / `describe` / `neighbors` / `resolve`) is fully usable, and the `search` tool falls back to **lexical search** over the symbol graph — BM25-ranked over a LadybugDB full-text index (same tool contract, keyword-ranked instead of semantic; an advisory notes the mode). Semantic/vector search needs Apple Silicon, Linux, or Windows. After install, `jrag --help` should print the CLI groups.
|
|
89
90
|
The package includes the CocoIndex lifecycle dependency used by `init`, `increment`, `reprocess`, and `erase` on platforms that have it (it is absent on Intel Mac).
|
|
90
91
|
|
|
92
|
+
**Kotlin (`.kt`) is indexed alongside Java (`.java`)** — both feed one merged AST graph (a Kotlin class can implement a Java interface and vice versa). Kotlin parsing requires the `tree-sitter-kotlin` grammar; if it fails to import, `.kt` files are skipped and Java-only indexing proceeds. **Intel Mac note:** `tree-sitter-kotlin` currently ships a macOS x86_64 wheel, so Kotlin indexing works there today; if a future release drops that wheel, Kotlin indexing degrades off on Intel Mac while the Java graph keeps working. See `docs/CODEBASE_REQUIREMENTS.md` A.1 for the v1 Kotlin limitations (extension-function calls unresolved; non-Spring frameworks out of scope; generated-code classification Java-only).
|
|
93
|
+
|
|
91
94
|
### Interactive setup (recommended)
|
|
92
95
|
|
|
93
|
-
Run `
|
|
96
|
+
Run `jrag install` from your Java project root to launch an interactive setup wizard that:
|
|
94
97
|
|
|
95
98
|
1. Detects Java source directories (Maven/Gradle modules)
|
|
96
99
|
2. Configures the embedding model (auto-downloads ~90MB or uses a local path)
|
|
@@ -101,19 +104,19 @@ Run `java-codebase-rag install` from your Java project root to launch an interac
|
|
|
101
104
|
|
|
102
105
|
```bash
|
|
103
106
|
# Interactive mode
|
|
104
|
-
|
|
107
|
+
jrag install
|
|
105
108
|
|
|
106
109
|
# Non-interactive mode (for CI/automation)
|
|
107
|
-
|
|
110
|
+
jrag install --non-interactive --agent claude-code
|
|
108
111
|
```
|
|
109
112
|
|
|
110
|
-
After `pip install --upgrade
|
|
113
|
+
After `pip install --upgrade jrag-cli`, run `jrag update` to refresh shipped artifacts and catch up the index (Lance + graph).
|
|
111
114
|
|
|
112
115
|
All indexing lifecycle commands (`init`, `increment`, `reprocess`, `install`, `update`) show a unified `Vectors → Optimize → Graph` progress bar on stderr during the index build (powered by `rich`); pass `--quiet` to suppress it.
|
|
113
116
|
|
|
114
117
|
### Manual registration
|
|
115
118
|
|
|
116
|
-
If you prefer manual configuration, see [`docs/
|
|
119
|
+
If you prefer manual configuration, see [`docs/JRAG-CLI.md`](./docs/JRAG-CLI.md) for the full CLI reference.
|
|
117
120
|
|
|
118
121
|
> **Stability disclaimer.** This package does **not** promise backward compatibility. MCP tool contracts, env vars, Lance/LadybugDB schemas, config files, and Python APIs may change without a deprecation period. Track `main` and rebuild indexes when ontology or embedding settings change.
|
|
119
122
|
|
|
@@ -121,7 +124,7 @@ If you prefer manual configuration, see [`docs/JAVA-CODEBASE-RAG-CLI.md`](./docs
|
|
|
121
124
|
|
|
122
125
|
## Tools & commands at a glance
|
|
123
126
|
|
|
124
|
-
`jrag` is the default and recommended surface (`
|
|
127
|
+
`jrag` is the default and recommended surface (`jrag install --surface cli`). The **MCP server** (`--surface mcp`) is kept as a **legacy** option for existing setups. Both surfaces walk the same LanceDB vectors + LadybugDB **AST Graph**. Switch an existing install later with `jrag update --surface mcp|cli`.
|
|
125
128
|
|
|
126
129
|
**CLI surface — `jrag`, one command per engineering intent**
|
|
127
130
|
|
|
@@ -213,7 +216,7 @@ The operator-facing surface is small: pick an index dir, pick an embedding model
|
|
|
213
216
|
|
|
214
217
|
## CLI cheat sheet
|
|
215
218
|
|
|
216
|
-
Run `
|
|
219
|
+
Run `jrag --help` to list grouped subcommands. Operator playbook with workflows, exit codes, and env alignment lives in [`docs/JRAG-CLI.md`](./docs/JRAG-CLI.md).
|
|
217
220
|
|
|
218
221
|
| Group | Subcommand | What it does |
|
|
219
222
|
|---|---|---|
|
|
@@ -230,8 +233,8 @@ Run `java-codebase-rag --help` to list grouped subcommands. Operator playbook wi
|
|
|
230
233
|
|
|
231
234
|
## jrag — agent CLI
|
|
232
235
|
|
|
233
|
-
`jrag` is
|
|
234
|
-
coding agents. It gives the agent **one command per engineering intent** and
|
|
236
|
+
`jrag` is the unified console script (operator + agent verbs) built for AI
|
|
237
|
+
coding agents and operators alike. It gives the agent **one command per engineering intent** and
|
|
235
238
|
takes human-readable identifiers (FQN / simple name / route path / topic) —
|
|
236
239
|
never raw node IDs. Every `<query>` command resolves the identifier via
|
|
237
240
|
`resolve_v2` as the first step; on `many` it returns candidates and stops, on
|
|
@@ -285,7 +288,7 @@ A missing or stale index produces an actionable `status: error` envelope (exit
|
|
|
285
288
|
2) rather than a traceback:
|
|
286
289
|
|
|
287
290
|
```
|
|
288
|
-
error: No index at /path/to/code_graph.lbug. Run:
|
|
291
|
+
error: No index at /path/to/code_graph.lbug. Run: jrag init --source-root <root>
|
|
289
292
|
```
|
|
290
293
|
|
|
291
294
|
See [`plans/active/PLAN-JRAG-CLI.md`](./plans/active/PLAN-JRAG-CLI.md) for the
|
|
@@ -300,7 +303,7 @@ full design and per-PR breakdown.
|
|
|
300
303
|
| [`docs/paper/paper.pdf`](./docs/paper/paper.pdf) | Architecture report — design rationale, GPS metaphor, three-layer architecture, design principles, future work. |
|
|
301
304
|
| [`docs/AGENT-GUIDE.md`](./docs/AGENT-GUIDE.md) | Agent-facing guide. Copy-paste into `QWEN.md` / `CLAUDE.md` / `AGENTS.md`. |
|
|
302
305
|
| [`docs/CONFIGURATION.md`](./docs/CONFIGURATION.md) | Environment variables, project YAML, graph ontology, brownfield overrides, ignore patterns. |
|
|
303
|
-
| [`docs/
|
|
306
|
+
| [`docs/JRAG-CLI.md`](./docs/JRAG-CLI.md) | CLI operator playbook: workflows, exit codes, env alignment. |
|
|
304
307
|
| [`docs/EDGE-NAVIGATION.md`](./docs/EDGE-NAVIGATION.md) | MCP-traversable edges, directions, dot-key composition. |
|
|
305
308
|
| [`skills/`](./skills/) | `/explore-codebase-cli` (CLI surface) + `/explore-codebase` (legacy MCP surface) skills — operating manuals for hosts with skill discovery (alternative to copy-pasting AGENT-GUIDE). See [`skills/README.md`](./skills/README.md). |
|
|
306
309
|
| [`docs/MANUAL-VERIFICATION-CHECKLIST.md`](./docs/MANUAL-VERIFICATION-CHECKLIST.md) | 7-phase agent-driven verification after indexing your project. |
|
|
@@ -312,8 +315,8 @@ full design and per-PR breakdown.
|
|
|
312
315
|
## Install from source (contributors)
|
|
313
316
|
|
|
314
317
|
```bash
|
|
315
|
-
git clone https://github.com/HumanBean17/
|
|
316
|
-
cd
|
|
318
|
+
git clone https://github.com/HumanBean17/jrag
|
|
319
|
+
cd jrag
|
|
317
320
|
python3 -m venv .venv
|
|
318
321
|
.venv/bin/pip install -e ".[dev]"
|
|
319
322
|
```
|
|
@@ -329,3 +332,9 @@ The default embedding model is `sentence-transformers/all-MiniLM-L6-v2` (downloa
|
|
|
329
332
|
- `get_service_topology` — microservice-level summary aggregating `HTTP_CALLS` / `ASYNC_CALLS`.
|
|
330
333
|
- Agentic routing layer (query classifier → vector / graph / both).
|
|
331
334
|
- Optional `codegraph_nodes` LanceDB table embedding symbol summaries so the graph itself is vector-searchable.
|
|
335
|
+
|
|
336
|
+
---
|
|
337
|
+
|
|
338
|
+
## Built on
|
|
339
|
+
|
|
340
|
+
The indexing pipeline runs on [**CocoIndex**](https://github.com/cocoindex-io/cocoindex) — an open-source data indexing framework that powers the vector store lifecycle (`init`, `increment`, `reprocess`, `erase`) behind every `jrag` index.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#
|
|
1
|
+
# jrag
|
|
2
2
|
|
|
3
3
|
A graph-native code intelligence layer for Java microservice estates, surfaced through the **`jrag` CLI** — one command per engineering intent. A **legacy MCP server** (`search` / `find` / `describe` / `neighbors` / `resolve`) is also available for existing setups. Both are thin surfaces over the same **AST Graph**: a deterministic property graph extracted from Java source with tree-sitter, stored **locally** in **LadybugDB** (graph) alongside a **LanceDB** vector index (chunks). There is no server to host and no cloud round-trip — the index lives on your disk and your source never leaves the machine. Both surfaces collapse onto three primitive operations: **locate**, **inspect**, **walk**.
|
|
4
4
|
|
|
@@ -36,15 +36,17 @@ The rest of this README is the install, the tool/command orientation, and the re
|
|
|
36
36
|
## Install
|
|
37
37
|
|
|
38
38
|
```bash
|
|
39
|
-
pip install
|
|
39
|
+
pip install jrag-cli
|
|
40
40
|
```
|
|
41
41
|
|
|
42
|
-
Python **3.11+** required, on **Linux, macOS, and Windows**. On Linux, Windows, and **Apple Silicon** Macs every native dependency (LanceDB, LadybugDB, CocoIndex) ships a wheel and you get the full semantic + graph search. **Intel Macs (x86_64) install graph-only**: PyTorch ≥2.3 and LanceDB ≥0.26 dropped macOS Intel wheels, so the vector stack is auto-excluded via PEP 508 markers — `pip install
|
|
42
|
+
Python **3.11+** required, on **Linux, macOS, and Windows**. On Linux, Windows, and **Apple Silicon** Macs every native dependency (LanceDB, LadybugDB, CocoIndex) ships a wheel and you get the full semantic + graph search. **Intel Macs (x86_64) install graph-only**: PyTorch ≥2.3 and LanceDB ≥0.26 dropped macOS Intel wheels, so the vector stack is auto-excluded via PEP 508 markers — `pip install jrag-cli` works out of the box, the graph layer (`find` / `describe` / `neighbors` / `resolve`) is fully usable, and the `search` tool falls back to **lexical search** over the symbol graph — BM25-ranked over a LadybugDB full-text index (same tool contract, keyword-ranked instead of semantic; an advisory notes the mode). Semantic/vector search needs Apple Silicon, Linux, or Windows. After install, `jrag --help` should print the CLI groups.
|
|
43
43
|
The package includes the CocoIndex lifecycle dependency used by `init`, `increment`, `reprocess`, and `erase` on platforms that have it (it is absent on Intel Mac).
|
|
44
44
|
|
|
45
|
+
**Kotlin (`.kt`) is indexed alongside Java (`.java`)** — both feed one merged AST graph (a Kotlin class can implement a Java interface and vice versa). Kotlin parsing requires the `tree-sitter-kotlin` grammar; if it fails to import, `.kt` files are skipped and Java-only indexing proceeds. **Intel Mac note:** `tree-sitter-kotlin` currently ships a macOS x86_64 wheel, so Kotlin indexing works there today; if a future release drops that wheel, Kotlin indexing degrades off on Intel Mac while the Java graph keeps working. See `docs/CODEBASE_REQUIREMENTS.md` A.1 for the v1 Kotlin limitations (extension-function calls unresolved; non-Spring frameworks out of scope; generated-code classification Java-only).
|
|
46
|
+
|
|
45
47
|
### Interactive setup (recommended)
|
|
46
48
|
|
|
47
|
-
Run `
|
|
49
|
+
Run `jrag install` from your Java project root to launch an interactive setup wizard that:
|
|
48
50
|
|
|
49
51
|
1. Detects Java source directories (Maven/Gradle modules)
|
|
50
52
|
2. Configures the embedding model (auto-downloads ~90MB or uses a local path)
|
|
@@ -55,19 +57,19 @@ Run `java-codebase-rag install` from your Java project root to launch an interac
|
|
|
55
57
|
|
|
56
58
|
```bash
|
|
57
59
|
# Interactive mode
|
|
58
|
-
|
|
60
|
+
jrag install
|
|
59
61
|
|
|
60
62
|
# Non-interactive mode (for CI/automation)
|
|
61
|
-
|
|
63
|
+
jrag install --non-interactive --agent claude-code
|
|
62
64
|
```
|
|
63
65
|
|
|
64
|
-
After `pip install --upgrade
|
|
66
|
+
After `pip install --upgrade jrag-cli`, run `jrag update` to refresh shipped artifacts and catch up the index (Lance + graph).
|
|
65
67
|
|
|
66
68
|
All indexing lifecycle commands (`init`, `increment`, `reprocess`, `install`, `update`) show a unified `Vectors → Optimize → Graph` progress bar on stderr during the index build (powered by `rich`); pass `--quiet` to suppress it.
|
|
67
69
|
|
|
68
70
|
### Manual registration
|
|
69
71
|
|
|
70
|
-
If you prefer manual configuration, see [`docs/
|
|
72
|
+
If you prefer manual configuration, see [`docs/JRAG-CLI.md`](./docs/JRAG-CLI.md) for the full CLI reference.
|
|
71
73
|
|
|
72
74
|
> **Stability disclaimer.** This package does **not** promise backward compatibility. MCP tool contracts, env vars, Lance/LadybugDB schemas, config files, and Python APIs may change without a deprecation period. Track `main` and rebuild indexes when ontology or embedding settings change.
|
|
73
75
|
|
|
@@ -75,7 +77,7 @@ If you prefer manual configuration, see [`docs/JAVA-CODEBASE-RAG-CLI.md`](./docs
|
|
|
75
77
|
|
|
76
78
|
## Tools & commands at a glance
|
|
77
79
|
|
|
78
|
-
`jrag` is the default and recommended surface (`
|
|
80
|
+
`jrag` is the default and recommended surface (`jrag install --surface cli`). The **MCP server** (`--surface mcp`) is kept as a **legacy** option for existing setups. Both surfaces walk the same LanceDB vectors + LadybugDB **AST Graph**. Switch an existing install later with `jrag update --surface mcp|cli`.
|
|
79
81
|
|
|
80
82
|
**CLI surface — `jrag`, one command per engineering intent**
|
|
81
83
|
|
|
@@ -167,7 +169,7 @@ The operator-facing surface is small: pick an index dir, pick an embedding model
|
|
|
167
169
|
|
|
168
170
|
## CLI cheat sheet
|
|
169
171
|
|
|
170
|
-
Run `
|
|
172
|
+
Run `jrag --help` to list grouped subcommands. Operator playbook with workflows, exit codes, and env alignment lives in [`docs/JRAG-CLI.md`](./docs/JRAG-CLI.md).
|
|
171
173
|
|
|
172
174
|
| Group | Subcommand | What it does |
|
|
173
175
|
|---|---|---|
|
|
@@ -184,8 +186,8 @@ Run `java-codebase-rag --help` to list grouped subcommands. Operator playbook wi
|
|
|
184
186
|
|
|
185
187
|
## jrag — agent CLI
|
|
186
188
|
|
|
187
|
-
`jrag` is
|
|
188
|
-
coding agents. It gives the agent **one command per engineering intent** and
|
|
189
|
+
`jrag` is the unified console script (operator + agent verbs) built for AI
|
|
190
|
+
coding agents and operators alike. It gives the agent **one command per engineering intent** and
|
|
189
191
|
takes human-readable identifiers (FQN / simple name / route path / topic) —
|
|
190
192
|
never raw node IDs. Every `<query>` command resolves the identifier via
|
|
191
193
|
`resolve_v2` as the first step; on `many` it returns candidates and stops, on
|
|
@@ -239,7 +241,7 @@ A missing or stale index produces an actionable `status: error` envelope (exit
|
|
|
239
241
|
2) rather than a traceback:
|
|
240
242
|
|
|
241
243
|
```
|
|
242
|
-
error: No index at /path/to/code_graph.lbug. Run:
|
|
244
|
+
error: No index at /path/to/code_graph.lbug. Run: jrag init --source-root <root>
|
|
243
245
|
```
|
|
244
246
|
|
|
245
247
|
See [`plans/active/PLAN-JRAG-CLI.md`](./plans/active/PLAN-JRAG-CLI.md) for the
|
|
@@ -254,7 +256,7 @@ full design and per-PR breakdown.
|
|
|
254
256
|
| [`docs/paper/paper.pdf`](./docs/paper/paper.pdf) | Architecture report — design rationale, GPS metaphor, three-layer architecture, design principles, future work. |
|
|
255
257
|
| [`docs/AGENT-GUIDE.md`](./docs/AGENT-GUIDE.md) | Agent-facing guide. Copy-paste into `QWEN.md` / `CLAUDE.md` / `AGENTS.md`. |
|
|
256
258
|
| [`docs/CONFIGURATION.md`](./docs/CONFIGURATION.md) | Environment variables, project YAML, graph ontology, brownfield overrides, ignore patterns. |
|
|
257
|
-
| [`docs/
|
|
259
|
+
| [`docs/JRAG-CLI.md`](./docs/JRAG-CLI.md) | CLI operator playbook: workflows, exit codes, env alignment. |
|
|
258
260
|
| [`docs/EDGE-NAVIGATION.md`](./docs/EDGE-NAVIGATION.md) | MCP-traversable edges, directions, dot-key composition. |
|
|
259
261
|
| [`skills/`](./skills/) | `/explore-codebase-cli` (CLI surface) + `/explore-codebase` (legacy MCP surface) skills — operating manuals for hosts with skill discovery (alternative to copy-pasting AGENT-GUIDE). See [`skills/README.md`](./skills/README.md). |
|
|
260
262
|
| [`docs/MANUAL-VERIFICATION-CHECKLIST.md`](./docs/MANUAL-VERIFICATION-CHECKLIST.md) | 7-phase agent-driven verification after indexing your project. |
|
|
@@ -266,8 +268,8 @@ full design and per-PR breakdown.
|
|
|
266
268
|
## Install from source (contributors)
|
|
267
269
|
|
|
268
270
|
```bash
|
|
269
|
-
git clone https://github.com/HumanBean17/
|
|
270
|
-
cd
|
|
271
|
+
git clone https://github.com/HumanBean17/jrag
|
|
272
|
+
cd jrag
|
|
271
273
|
python3 -m venv .venv
|
|
272
274
|
.venv/bin/pip install -e ".[dev]"
|
|
273
275
|
```
|
|
@@ -283,3 +285,9 @@ The default embedding model is `sentence-transformers/all-MiniLM-L6-v2` (downloa
|
|
|
283
285
|
- `get_service_topology` — microservice-level summary aggregating `HTTP_CALLS` / `ASYNC_CALLS`.
|
|
284
286
|
- Agentic routing layer (query classifier → vector / graph / both).
|
|
285
287
|
- Optional `codegraph_nodes` LanceDB table embedding symbol summaries so the graph itself is vector-searchable.
|
|
288
|
+
|
|
289
|
+
---
|
|
290
|
+
|
|
291
|
+
## Built on
|
|
292
|
+
|
|
293
|
+
The indexing pipeline runs on [**CocoIndex**](https://github.com/cocoindex-io/cocoindex) — an open-source data indexing framework that powers the vector store lifecycle (`init`, `increment`, `reprocess`, `erase`) behind every `jrag` index.
|
|
@@ -4,15 +4,15 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "java-codebase-rag"
|
|
7
|
-
version = "0.
|
|
8
|
-
description = "MCP server for semantic + structural search over Java codebases"
|
|
7
|
+
version = "0.12.0"
|
|
8
|
+
description = "jrag (formerly java-codebase-rag) — MCP server + jrag CLI for semantic + structural search over Java/Kotlin codebases"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.11"
|
|
11
11
|
license = "MIT"
|
|
12
12
|
authors = [
|
|
13
13
|
{ name = "HumanBean17" },
|
|
14
14
|
]
|
|
15
|
-
keywords = ["
|
|
15
|
+
keywords = ["jrag", "java", "mcp", "rag", "code-search", "graph", "lancedb", "ladybug"]
|
|
16
16
|
classifiers = [
|
|
17
17
|
"Development Status :: 3 - Alpha",
|
|
18
18
|
"Intended Audience :: Developers",
|
|
@@ -46,6 +46,7 @@ dependencies = [
|
|
|
46
46
|
"sentence-transformers>=5.4.0,<6; sys_platform != 'darwin' or platform_machine != 'x86_64'",
|
|
47
47
|
"tree-sitter>=0.25.2,<0.26",
|
|
48
48
|
"tree-sitter-java>=0.23.5,<0.24",
|
|
49
|
+
"tree-sitter-kotlin>=1.1.0,<2",
|
|
49
50
|
"unidiff>=0.7.3,<1",
|
|
50
51
|
"watchdog>=6,<7",
|
|
51
52
|
]
|
|
@@ -59,14 +60,15 @@ dev = [
|
|
|
59
60
|
]
|
|
60
61
|
|
|
61
62
|
[project.urls]
|
|
62
|
-
Homepage = "https://github.com/HumanBean17/
|
|
63
|
-
Repository = "https://github.com/HumanBean17/
|
|
64
|
-
Issues = "https://github.com/HumanBean17/
|
|
63
|
+
Homepage = "https://github.com/HumanBean17/jrag"
|
|
64
|
+
Repository = "https://github.com/HumanBean17/jrag"
|
|
65
|
+
Issues = "https://github.com/HumanBean17/jrag/issues"
|
|
65
66
|
|
|
66
67
|
[project.scripts]
|
|
67
|
-
|
|
68
|
+
jrag = "java_codebase_rag.cli_dispatch:_console_script_main"
|
|
69
|
+
jrag-mcp = "java_codebase_rag.mcp.server:main"
|
|
70
|
+
java-codebase-rag = "java_codebase_rag.cli_dispatch:_console_script_main"
|
|
68
71
|
java-codebase-rag-mcp = "java_codebase_rag.mcp.server:main"
|
|
69
|
-
jrag = "java_codebase_rag.jrag:_console_script_main"
|
|
70
72
|
|
|
71
73
|
[tool.setuptools.packages.find]
|
|
72
74
|
where = ["src"]
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"""Legacy-alias deprecation notice for the ``jrag`` rename.
|
|
2
|
+
|
|
3
|
+
The tool is being renamed from ``java-codebase-rag`` to ``jrag``. The legacy
|
|
4
|
+
command aliases (``java-codebase-rag`` and ``java-codebase-rag-mcp``) continue
|
|
5
|
+
to work; when invoked through one of them in an interactive context, this
|
|
6
|
+
helper emits a single-line notice pointing the operator at the new name.
|
|
7
|
+
|
|
8
|
+
Suppression rule
|
|
9
|
+
----------------
|
|
10
|
+
The notice is suppressed when **either** of the following holds:
|
|
11
|
+
|
|
12
|
+
* ``$JRAG_NO_DEPRECATION`` is present and non-empty — any non-empty value
|
|
13
|
+
suppresses (so ``"1"``, ``"0"``, ``"false"``, ``"yes"`` all suppress; the
|
|
14
|
+
empty string and an unset variable do not). The simpler "present and
|
|
15
|
+
non-empty" rule is preferred over parsing truthy values so that operators
|
|
16
|
+
can shut the notice up with whatever value is easiest to reach for.
|
|
17
|
+
* ``sys.stderr.isatty()`` is false (or ``sys.stderr`` lacks ``isatty``) — i.e.
|
|
18
|
+
non-interactive contexts: piped, redirected, or captured stderr. Under real
|
|
19
|
+
MCP use stderr is not a TTY, so the call is silent in production; it exists
|
|
20
|
+
for the rare human-debug case.
|
|
21
|
+
|
|
22
|
+
This module is stdlib-only and import-light: it runs at MCP-server startup and
|
|
23
|
+
before ``--help``, so it must not pull in any backend (cli, search, mcp) code.
|
|
24
|
+
"""
|
|
25
|
+
from __future__ import annotations
|
|
26
|
+
|
|
27
|
+
import os
|
|
28
|
+
import sys
|
|
29
|
+
|
|
30
|
+
_LEGACY_ALIASES = frozenset({"java-codebase-rag", "java-codebase-rag-mcp"})
|
|
31
|
+
|
|
32
|
+
_DEPRECATION_LINE = (
|
|
33
|
+
"jrag: 'java-codebase-rag' is now 'jrag'; this alias continues to work. "
|
|
34
|
+
"Set JRAG_NO_DEPRECATION=1 to silence.\n"
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
#: Executable suffixes appended by Windows (and packaging tools like pip) to
|
|
38
|
+
#: console-script wrappers. All three are exactly 4 characters long (``.exe``,
|
|
39
|
+
#: ``.bat``, ``.cmd``) so a single ``b[:-4]`` slice strips any of them. Stripping
|
|
40
|
+
#: keeps routing decisions stable across POSIX and Windows installs:
|
|
41
|
+
#: ``C:\\Users\\foo\\Scripts\\jrag.exe`` → ``"jrag"``;
|
|
42
|
+
#: ``...\\java-codebase-rag.exe`` → ``"java-codebase-rag"``.
|
|
43
|
+
_WINDOWS_EXE_SUFFIXES: tuple[str, ...] = (".exe", ".bat", ".cmd")
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def _invoked_program_name() -> str:
|
|
47
|
+
"""Basename of ``sys.argv[0]`` with a Windows executable suffix stripped.
|
|
48
|
+
|
|
49
|
+
Returns the empty string when ``sys.argv`` is empty. Otherwise takes
|
|
50
|
+
``os.path.basename(sys.argv[0])`` and, if it ends (case-insensitively) with
|
|
51
|
+
one of ``.exe`` / ``.bat`` / ``.cmd``, drops the 4-character suffix.
|
|
52
|
+
|
|
53
|
+
Shared with :mod:`java_codebase_rag.cli_dispatch` for identity-default
|
|
54
|
+
routing: both legacy-alias deprecation here and ``jrag``-vs-alias routing
|
|
55
|
+
there rely on the same canonicalized basename. Without this, Windows builds
|
|
56
|
+
would route ``jrag.exe --version`` through the wrong parser and never emit
|
|
57
|
+
the deprecation notice for ``java-codebase-rag.exe``.
|
|
58
|
+
"""
|
|
59
|
+
argv = sys.argv
|
|
60
|
+
if not argv:
|
|
61
|
+
return ""
|
|
62
|
+
base = os.path.basename(argv[0])
|
|
63
|
+
if base.lower().endswith(_WINDOWS_EXE_SUFFIXES):
|
|
64
|
+
return base[:-4]
|
|
65
|
+
return base
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def _stderr_is_tty() -> bool:
|
|
69
|
+
"""True iff ``sys.stderr`` reports itself as a TTY.
|
|
70
|
+
|
|
71
|
+
Defensive against stderr replacements that omit ``isatty``.
|
|
72
|
+
"""
|
|
73
|
+
stderr = sys.stderr
|
|
74
|
+
return hasattr(stderr, "isatty") and stderr.isatty()
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def _suppressed() -> bool:
|
|
78
|
+
"""True iff the notice should be suppressed."""
|
|
79
|
+
if os.environ.get("JRAG_NO_DEPRECATION"):
|
|
80
|
+
return True
|
|
81
|
+
return not _stderr_is_tty()
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def maybe_warn_legacy_alias(stream=None) -> None:
|
|
85
|
+
"""Emit a one-line legacy-alias deprecation notice when appropriate.
|
|
86
|
+
|
|
87
|
+
Detects a legacy invocation (``sys.argv[0]`` basename is exactly
|
|
88
|
+
``java-codebase-rag`` or ``java-codebase-rag-mcp``) and, if not suppressed,
|
|
89
|
+
writes a single line to ``stream`` (defaulting to ``sys.stderr``). Never
|
|
90
|
+
raises: any error inside the write is swallowed so the rename helper can
|
|
91
|
+
never break tool startup.
|
|
92
|
+
|
|
93
|
+
See module docstring for the suppression rule.
|
|
94
|
+
"""
|
|
95
|
+
if _invoked_program_name() not in _LEGACY_ALIASES:
|
|
96
|
+
return
|
|
97
|
+
if _suppressed():
|
|
98
|
+
return
|
|
99
|
+
target = stream if stream is not None else sys.stderr
|
|
100
|
+
try:
|
|
101
|
+
target.write(_DEPRECATION_LINE)
|
|
102
|
+
except Exception: # pragma: no cover - defensive: never break startup
|
|
103
|
+
return
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"""Version string for the CLI ``--version`` flag.
|
|
2
2
|
|
|
3
3
|
The single source of truth is the installed distribution metadata
|
|
4
|
-
(``
|
|
4
|
+
(``jrag-cli`` in pyproject.toml), read via :mod:`importlib.metadata`
|
|
5
5
|
so a pyproject bump propagates with no second hardcoded copy.
|
|
6
6
|
:func:`version_string` appends the CPython version for the
|
|
7
7
|
``<prog> <version> (python <x.y.z>)`` format chosen for the ``--version`` flag.
|
|
@@ -15,7 +15,7 @@ import platform
|
|
|
15
15
|
from importlib.metadata import PackageNotFoundError
|
|
16
16
|
from importlib.metadata import version as _dist_version
|
|
17
17
|
|
|
18
|
-
_PACKAGE = "
|
|
18
|
+
_PACKAGE = "jrag-cli"
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
def package_version() -> str:
|
|
@@ -249,6 +249,11 @@ class AnnotationRef:
|
|
|
249
249
|
container_capability_values: tuple[str, ...] = field(default_factory=tuple)
|
|
250
250
|
# Entry-aligned with `container_capability_values`; each value is "enum" | "string".
|
|
251
251
|
container_capability_kinds: tuple[str, ...] = field(default_factory=tuple)
|
|
252
|
+
# Kotlin use-site target (one of "field"|"get"|"set"|"param"|"property"|"file") or
|
|
253
|
+
# None. Java ``parse_java`` always leaves this None — Java has no use-site targets.
|
|
254
|
+
# This is an AST-level field (not a persisted graph column); it drives Kotlin-only
|
|
255
|
+
# routing of an annotation to the FieldDecl / accessor MethodDecl / ParamDecl slot.
|
|
256
|
+
use_site_target: str | None = None
|
|
252
257
|
|
|
253
258
|
|
|
254
259
|
@dataclass
|
|
@@ -394,11 +399,26 @@ class JavaFileAst:
|
|
|
394
399
|
explicit_imports: dict[str, str] # "List" -> "java.util.List"
|
|
395
400
|
top_level_types: list[TypeDecl]
|
|
396
401
|
all_types: list[TypeDecl] # flat, includes nested
|
|
402
|
+
# Language-dispatch seam (Task 1). Required — no default — so every
|
|
403
|
+
# construction site names the language explicitly. Validated against the
|
|
404
|
+
# registry in ``language.KNOWN_LANGUAGE_IDS``. Lazily imported inside
|
|
405
|
+
# ``__post_init__`` to avoid a module-load cycle (``language`` imports
|
|
406
|
+
# ``JavaFileAst``/``parse_java`` from this module).
|
|
407
|
+
language: str
|
|
397
408
|
parse_error: bool = False
|
|
398
409
|
source_bytes: int = 0
|
|
399
410
|
file_imports: FileImports = field(default_factory=FileImports)
|
|
400
411
|
routes_skipped_unresolved: int = 0
|
|
401
412
|
|
|
413
|
+
def __post_init__(self) -> None:
|
|
414
|
+
from .language import KNOWN_LANGUAGE_IDS
|
|
415
|
+
|
|
416
|
+
if self.language not in KNOWN_LANGUAGE_IDS:
|
|
417
|
+
raise ValueError(
|
|
418
|
+
f"Unknown language id {self.language!r}; "
|
|
419
|
+
f"expected one of {sorted(KNOWN_LANGUAGE_IDS)}"
|
|
420
|
+
)
|
|
421
|
+
|
|
402
422
|
|
|
403
423
|
@dataclass
|
|
404
424
|
class _ParseCtx:
|
|
@@ -2625,6 +2645,7 @@ def parse_java(source: bytes | str, *, filename: str = "", verbose: bool = False
|
|
|
2625
2645
|
explicit_imports={},
|
|
2626
2646
|
top_level_types=[],
|
|
2627
2647
|
all_types=[],
|
|
2648
|
+
language="java",
|
|
2628
2649
|
parse_error=False,
|
|
2629
2650
|
source_bytes=len(src),
|
|
2630
2651
|
file_imports=FileImports(),
|
|
@@ -2710,6 +2731,7 @@ def parse_java(source: bytes | str, *, filename: str = "", verbose: bool = False
|
|
|
2710
2731
|
explicit_imports=explicit_imports,
|
|
2711
2732
|
top_level_types=top_types,
|
|
2712
2733
|
all_types=all_types,
|
|
2734
|
+
language="java",
|
|
2713
2735
|
parse_error=root.has_error,
|
|
2714
2736
|
source_bytes=len(src),
|
|
2715
2737
|
file_imports=file_imports,
|