java-codebase-rag 0.6.1__py3-none-any.whl → 0.6.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.
java_codebase_rag/cli.py CHANGED
@@ -6,6 +6,7 @@ from __future__ import annotations
6
6
  import argparse
7
7
  import asyncio
8
8
  import json
9
+ import os
9
10
  import pprint
10
11
  import shutil
11
12
  import sys
@@ -930,5 +931,21 @@ def main(argv: list[str] | None = None) -> int:
930
931
  return 2
931
932
 
932
933
 
934
+ def _console_script_main() -> None:
935
+ """Real CLI entry: terminate without interpreter finalization.
936
+
937
+ A pyarrow/lance worker thread (loaded via lancedb in lifecycle commands) can
938
+ outlive CPython finalization in a one-shot CLI subprocess and trip
939
+ ``PyGILState_Release`` (SIGABRT, exit -6). Flushing + ``os._exit`` skips that
940
+ racy teardown — the command has already done its work and emitted its result.
941
+ ``main()`` stays return-based so in-process test callers (``cli.main(...)``)
942
+ keep working.
943
+ """
944
+ rc = main()
945
+ sys.stdout.flush()
946
+ sys.stderr.flush()
947
+ os._exit(rc)
948
+
949
+
933
950
  if __name__ == "__main__":
934
- raise SystemExit(main())
951
+ _console_script_main()
@@ -52,14 +52,36 @@ _DEFAULT_EMBEDDING_MODEL = "sentence-transformers/all-MiniLM-L6-v2"
52
52
  _UNRESOLVED_VAR_RE = re.compile(r"\$(\w+|\{[^}]+\})")
53
53
 
54
54
 
55
- def maybe_expand_embedding_model_path(value: str) -> str:
56
- """Expand ``~`` and ``$VAR`` when *value* is path-shaped.
55
+ def maybe_expand_embedding_model_path(
56
+ value: str,
57
+ *,
58
+ config_dir: Path | None = None,
59
+ source_root: Path | None = None,
60
+ source: SettingSource | None = None,
61
+ ) -> str:
62
+ """Expand ``~`` / ``$VAR`` for path-shaped values and resolve relatives to absolute.
57
63
 
58
64
  Path-shape: starts with ``/``, ``./``, ``../``, ``~``, or contains ``$``.
59
65
  Plain ``org/name`` (hub id) does not match and is passed through unchanged.
60
66
 
61
- Used for ``embedding.model`` after precedence resolution and for runtime
62
- ``SBERT_MODEL`` reads (e.g. MCP) so the string matches ``ResolvedOperatorConfig``.
67
+ Relative resolution mirrors :func:`_resolve_index_dir_path` so a committed
68
+ config is portable regardless of process CWD:
69
+
70
+ * YAML values (``source == "yaml"``) resolve against ``config_dir`` (the
71
+ directory holding ``.java-codebase-rag.yml``).
72
+ * CLI / env values resolve against ``source_root``.
73
+
74
+ Only a result that still starts with ``./`` or ``../`` *after* ``~`` /
75
+ ``$VAR`` expansion is re-based — so hub ids (``org/name``), absolute paths,
76
+ ``~/``-expanded paths, and an env var that already yielded an absolute path
77
+ are all left untouched.
78
+
79
+ When no base is supplied (the runtime ``SBERT_MODEL`` read via
80
+ :func:`resolved_sbert_model_for_process_env`), relative resolution is
81
+ skipped: the value is returned ``expandvars`` / ``expanduser``-expanded but
82
+ not re-based, matching the prior best-effort behavior. The main resolution
83
+ path (:func:`resolve_operator_config`) supplies a base, so the absolute path
84
+ it stores is what downstream loaders receive.
63
85
  """
64
86
  needs_expand = value.startswith(("/", "./", "../", "~")) or "$" in value
65
87
  if not needs_expand:
@@ -70,9 +92,31 @@ def maybe_expand_embedding_model_path(value: str) -> str:
70
92
  f"java-codebase-rag: path-shaped model string contains unresolved variable: {expanded}",
71
93
  file=sys.stderr,
72
94
  )
95
+ if expanded.startswith(("./", "../")):
96
+ base = _embedding_model_base(
97
+ source=source, config_dir=config_dir, source_root=source_root
98
+ )
99
+ if base is not None:
100
+ return str((base / expanded).resolve())
73
101
  return expanded
74
102
 
75
103
 
104
+ def _embedding_model_base(
105
+ *,
106
+ source: SettingSource | None,
107
+ config_dir: Path | None,
108
+ source_root: Path | None,
109
+ ) -> Path | None:
110
+ """Base directory for a relative ``embedding.model``.
111
+
112
+ Mirrors :func:`_resolve_index_dir_path`: YAML values anchor on the config
113
+ file's directory; CLI / env values anchor on the resolved ``source_root``.
114
+ """
115
+ if source == "yaml":
116
+ return config_dir
117
+ return source_root
118
+
119
+
76
120
  def resolved_sbert_model_for_process_env(import_time_default: str) -> str:
77
121
  """``SBERT_MODEL`` from the process environment, with the same expansion as YAML/CLI resolution.
78
122
 
@@ -387,7 +431,12 @@ def resolve_operator_config(
387
431
  yaml_path=("embedding", "model"),
388
432
  default=_DEFAULT_EMBEDDING_MODEL,
389
433
  )
390
- model = maybe_expand_embedding_model_path(model)
434
+ model = maybe_expand_embedding_model_path(
435
+ model,
436
+ config_dir=config_dir,
437
+ source_root=root,
438
+ source=model_src,
439
+ )
391
440
  device, device_src = _pick_optional_device(
392
441
  cli_val=cli_embedding_device,
393
442
  env_key="SBERT_DEVICE",
@@ -759,6 +759,11 @@ def generate_yaml_config(
759
759
  else:
760
760
  config["embedding"].pop("model", None)
761
761
 
762
+ # Seed cross-service resolution safe-by-default: only evidence-backed cross-service
763
+ # edges survive (see _is_brownfield_sourced in build_ast_graph). setdefault preserves
764
+ # an explicit user choice (e.g. `auto`) on re-run update.
765
+ config.setdefault("cross_service_resolution", "brownfield_only")
766
+
762
767
  # Keys NOT written by installer (preserved if present):
763
768
  # - source_root (config.py resolves from walk-up discovery)
764
769
  # - index_dir (config.py defaults to <source_root>/.java-codebase-rag)
@@ -1250,9 +1255,14 @@ def run_update(
1250
1255
  print("Skipping index update.")
1251
1256
  return EXIT_PARTIAL if has_artifact_failures else EXIT_SUCCESS
1252
1257
 
1253
- # Resolve configuration
1258
+ # Resolve configuration. Pass source_root=None so the YAML ``source_root``
1259
+ # field is honored exactly like increment/init/reprocess — passing the
1260
+ # discovered config dir here routes resolve_operator_config into the
1261
+ # explicit-override branch that SKIPS the YAML field, which made `update`
1262
+ # point cocoindex at the config dir (no Java) against the real index and
1263
+ # mass-delete it. Discovery still runs against the CLI's cwd.
1254
1264
  try:
1255
- cfg = resolve_operator_config(source_root=project_root, cli_index_dir=None)
1265
+ cfg = resolve_operator_config(source_root=None, cli_index_dir=None)
1256
1266
  index_dir = cfg.index_dir
1257
1267
  except Exception as e:
1258
1268
  print(f"\nWarning: Failed to resolve configuration: {e}")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: java-codebase-rag
3
- Version: 0.6.1
3
+ Version: 0.6.2
4
4
  Summary: MCP server for semantic + structural search over Java codebases
5
5
  Author: HumanBean17
6
6
  License-Expression: MIT
@@ -7,7 +7,6 @@ index_common.py,sha256=HT6FKHFJ084eFvd3fR1j8z8gf4eWoPHVW8GXLpw464I,285
7
7
  java_index_flow_lancedb.py,sha256=MH9iTNF6HDHDTt5Jn7TOVE5hQ4WUPNt7PlQoh1tuh9o,13212
8
8
  java_index_v1_common.py,sha256=nF1KrSqboF_RRvWerG9knRRFmWwsrG_CvhgnsoZ8KqA,1154
9
9
  java_ontology.py,sha256=71bCLDNvMy0SpZPzSR5apJ0qJXNd6y5ggkLdBEw_PFo,16682
10
- kuzu_queries.py,sha256=9bQzrU311AOw_BcUp_KSGiZgPVSaLSU7y63XfcT_vqI,90137
11
10
  ladybug_queries.py,sha256=912j9VAYDjcU4ReVorWQ6R4DZl0tteKic-Pqu0jyBS0,90837
12
11
  mcp_hints.py,sha256=3swh05LSiWur3tm3-yssndBsLxIxFhy501kBtJI8jJ0,42509
13
12
  mcp_v2.py,sha256=o94GJI7j6dLJDIA3R_1ZiQhjzQfMAEW3etdeZYnHOUc,80637
@@ -17,20 +16,18 @@ search_lancedb.py,sha256=scG6HBUrsgIeSWFrGcLcGdhWv1qODOx4JOBMAlLDY_E,36793
17
16
  server.py,sha256=Js3XDpV7ThAtj352StH6QdhHutf1D5qUkbR-8k3jO8g,31303
18
17
  java_codebase_rag/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
19
18
  java_codebase_rag/_fdlimit.py,sha256=WroFdfSNbcriKok6q8znTf74dqlznxea_1Fd5bHl_3o,1930
20
- java_codebase_rag/cli.py,sha256=a5IFLWAsh77mfLv1Z9OdpvLaYvj4i0KR3_kLtL-ans8,34156
19
+ java_codebase_rag/cli.py,sha256=HkzCP8-G3WlCzoXcVCI2K3forDOMpTmUSoxgx3jbKk4,34774
21
20
  java_codebase_rag/cli_format.py,sha256=arU7P9W6Fvm7X_wzR1wJ8EfyxK1rDP_ESEhdA0ub4Mo,2579
22
21
  java_codebase_rag/cli_progress.py,sha256=9jCqEagYOXs32SYVA31_sOCrONvYy7cl1CrdBD2Pg44,3168
23
- java_codebase_rag/config.py,sha256=Gn3LgxkTOtAvsL-3U2Xn7atOIhyOT2aGmY8SBBTLoQg,16975
24
- java_codebase_rag/installer.py,sha256=DlBuVVWbHXgcjaQkuXUeT9fNdmk7XZefVT3zzw47k18,45965
22
+ java_codebase_rag/config.py,sha256=bfwYI4R8PU9YV_M4r8-03iaUZ_0TW-qN_NuhIsDXy2M,18769
23
+ java_codebase_rag/installer.py,sha256=sE0l85K_o291PdpF1vpesefR9VgdvvVeARXrpTxa30A,46689
25
24
  java_codebase_rag/lance_optimize.py,sha256=MzACYlgwxmkJCK64qQLyIAdizSq5BARqaMYSZONlc1I,6069
26
25
  java_codebase_rag/pipeline.py,sha256=UcgluFAW9Ghnas8u40x45bVic0mQv6rjzcliDKsnYJI,11936
27
26
  java_codebase_rag/install_data/agents/explorer-rag-enhanced.md,sha256=APl9d-No12qZNZLjU7mwNRwxHIgnT3ZtQZiD4clWlyU,14413
28
27
  java_codebase_rag/install_data/skills/explore-codebase/SKILL.md,sha256=pIM-Xdwq_fXkhhBJCdb-fA2nes5c_mMPcdUXb7Adyxo,12040
29
- java_codebase_rag-0.6.1.dist-info/licenses/LICENSE,sha256=gxvtiHtuviR_q8ZAjWw-QTcF3DyPzg6ZY-lQrr8OPpw,1068
30
- user_rag/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
31
- user_rag/cli.py,sha256=TVcyfzwvmdYXJW6KrEYTKMHm7z2JSXMmz2uB-8kkjxY,5604
32
- java_codebase_rag-0.6.1.dist-info/METADATA,sha256=aPiLbGD8xE-P3B_RI9gx7VuqrTd-VUriZ--ZPYNK02I,16934
33
- java_codebase_rag-0.6.1.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
34
- java_codebase_rag-0.6.1.dist-info/entry_points.txt,sha256=mVVQJa0n73OWfhHXYCDoPRrWin_LJhH2Rn0CkJ2iax4,101
35
- java_codebase_rag-0.6.1.dist-info/top_level.txt,sha256=syQgi8XPBwY2ws_NZ1uRCxTf_s41NpshwEHNdcdnk3A,245
36
- java_codebase_rag-0.6.1.dist-info/RECORD,,
28
+ java_codebase_rag-0.6.2.dist-info/licenses/LICENSE,sha256=gxvtiHtuviR_q8ZAjWw-QTcF3DyPzg6ZY-lQrr8OPpw,1068
29
+ java_codebase_rag-0.6.2.dist-info/METADATA,sha256=X92kaZ5TbEacz0sznWtUtpYEJvBdWIXX0s8MlqOeRyg,16934
30
+ java_codebase_rag-0.6.2.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
31
+ java_codebase_rag-0.6.2.dist-info/entry_points.txt,sha256=wsPZwot0Ui4JI3TIgW8LcbN8bNtKFbwQAlHAAJXfYgQ,117
32
+ java_codebase_rag-0.6.2.dist-info/top_level.txt,sha256=syQgi8XPBwY2ws_NZ1uRCxTf_s41NpshwEHNdcdnk3A,245
33
+ java_codebase_rag-0.6.2.dist-info/RECORD,,
@@ -0,0 +1,3 @@
1
+ [console_scripts]
2
+ java-codebase-rag = java_codebase_rag.cli:_console_script_main
3
+ java-codebase-rag-mcp = server:main
@@ -1,3 +0,0 @@
1
- [console_scripts]
2
- java-codebase-rag = java_codebase_rag.cli:main
3
- java-codebase-rag-mcp = server:main