codegraphcontext 0.2.6__py3-none-any.whl → 0.2.7__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.
@@ -16,7 +16,7 @@ CONFIG_DIR = Path.home() / ".codegraphcontext"
16
16
  CONFIG_FILE = CONFIG_DIR / ".env"
17
17
 
18
18
  # Database credential keys (stored in same .env file but not managed as config)
19
- DATABASE_CREDENTIAL_KEYS = {"NEO4J_URI", "NEO4J_USERNAME", "NEO4J_PASSWORD"}
19
+ DATABASE_CREDENTIAL_KEYS = {"NEO4J_URI", "NEO4J_USERNAME", "NEO4J_PASSWORD", "NEO4J_DATABASE"}
20
20
 
21
21
  # Default configuration values
22
22
  DEFAULT_CONFIG = {
@@ -28,6 +28,7 @@ DEFAULT_CONFIG = {
28
28
  "DEBUG_LOGS": "false",
29
29
  "DEBUG_LOG_PATH": str(Path.home() / "mcp_debug.log"),
30
30
  "ENABLE_APP_LOGS": "CRITICAL",
31
+ "LIBRARY_LOG_LEVEL": "WARNING",
31
32
  "LOG_FILE_PATH": str(CONFIG_DIR / "logs" / "cgc.log"),
32
33
  "MAX_FILE_SIZE_MB": "10",
33
34
  "IGNORE_TEST_FILES": "false",
@@ -55,6 +56,7 @@ CONFIG_DESCRIPTIONS = {
55
56
  "DEBUG_LOGS": "Enable debug logging (for development/troubleshooting)",
56
57
  "DEBUG_LOG_PATH": "Path to debug log file",
57
58
  "ENABLE_APP_LOGS": "Application log level (DEBUG|INFO|WARNING|ERROR|CRITICAL|DISABLED)",
59
+ "LIBRARY_LOG_LEVEL": "Log level for third-party libraries (neo4j, asyncio, urllib3) (DEBUG|INFO|WARNING|ERROR|CRITICAL)",
58
60
  "LOG_FILE_PATH": "Path to application log file",
59
61
  "MAX_FILE_SIZE_MB": "Maximum file size to index (in MB)",
60
62
  "IGNORE_TEST_FILES": "Skip test files during indexing",
@@ -78,6 +80,7 @@ CONFIG_VALIDATORS = {
78
80
  "ALLOW_DB_DELETION": ["true", "false"],
79
81
  "DEBUG_LOGS": ["true", "false"],
80
82
  "ENABLE_APP_LOGS": ["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL", "DISABLED"],
83
+ "LIBRARY_LOG_LEVEL": ["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"],
81
84
  "IGNORE_TEST_FILES": ["true", "false"],
82
85
  "IGNORE_HIDDEN_FILES": ["true", "false"],
83
86
  "ENABLE_AUTO_WATCH": ["true", "false"],
@@ -86,13 +89,15 @@ CONFIG_VALIDATORS = {
86
89
  "SCIP_INDEXER": ["true", "false"],
87
90
  "SKIP_EXTERNAL_RESOLUTION": ["true", "false"],
88
91
  }
92
+ def ensure_config_dir(path: Path = CONFIG_DIR):
93
+ """
94
+ Ensure that the configuration directory exists.
95
+ Creates the directory and a logs subdirectory if they do not already exist.
96
+ """
97
+ path.mkdir(parents=True, exist_ok=True)
98
+ (path / "logs").mkdir(parents=True, exist_ok=True)
89
99
 
90
100
 
91
- def ensure_config_dir():
92
- """Ensure configuration directory exists."""
93
- CONFIG_DIR.mkdir(parents=True, exist_ok=True)
94
- (CONFIG_DIR / "logs").mkdir(parents=True, exist_ok=True)
95
-
96
101
 
97
102
  def load_config() -> Dict[str, str]:
98
103
  """
@@ -44,10 +44,24 @@ from .cli_helpers import (
44
44
  list_watching_helper,
45
45
  )
46
46
 
47
- # Set the log level for the noisy neo4j, asyncio, and urllib3 loggers to WARNING to keep the output clean.
48
- logging.getLogger("neo4j").setLevel(logging.WARNING)
49
- logging.getLogger("asyncio").setLevel(logging.WARNING)
50
- logging.getLogger("urllib3").setLevel(logging.WARNING)
47
+ # Set the log level for the noisy neo4j, asyncio, and urllib3 loggers to keep the output clean.
48
+ # Get the log level from config, defaulting to WARNING
49
+ def _configure_library_loggers():
50
+ """Configure third-party library loggers based on config setting."""
51
+ try:
52
+ log_level_str = config_manager.get_config_value('LIBRARY_LOG_LEVEL')
53
+ if log_level_str is None:
54
+ log_level_str = 'WARNING'
55
+ log_level_str = str(log_level_str).upper()
56
+ log_level = getattr(logging, log_level_str, logging.WARNING)
57
+ except (AttributeError, Exception):
58
+ log_level = logging.WARNING
59
+
60
+ logging.getLogger("neo4j").setLevel(log_level)
61
+ logging.getLogger("asyncio").setLevel(log_level)
62
+ logging.getLogger("urllib3").setLevel(log_level)
63
+
64
+ _configure_library_loggers()
51
65
 
52
66
 
53
67
  # Import visualization module
@@ -288,11 +302,24 @@ def _load_credentials():
288
302
  os.environ.get("NEO4J_PASSWORD")
289
303
  ])
290
304
  if has_neo4j_creds:
291
- console.print("[cyan]Using database: Neo4j[/cyan]")
305
+ neo4j_db = os.environ.get("NEO4J_DATABASE")
306
+ if neo4j_db:
307
+ console.print(f"[cyan]Using database: Neo4j (database: {neo4j_db})[/cyan]")
308
+ else:
309
+ console.print("[cyan]Using database: Neo4j[/cyan]")
292
310
  else:
293
311
  console.print("[yellow]⚠ DEFAULT_DATABASE=neo4j but credentials not found. Falling back to FalkorDB.[/yellow]")
312
+ elif default_db == "falkordb-remote":
313
+ host = os.environ.get("FALKORDB_HOST")
314
+ if host:
315
+ console.print(f"[cyan]Using database: FalkorDB Remote ({host})[/cyan]")
316
+ else:
317
+ console.print("[yellow]⚠ DATABASE_TYPE=falkordb-remote but FALKORDB_HOST not set.[/yellow]")
294
318
  else:
295
- console.print("[cyan]Using database: FalkorDB[/cyan]")
319
+ if os.environ.get("FALKORDB_HOST"):
320
+ console.print(f"[cyan]Using database: FalkorDB Remote ({os.environ.get('FALKORDB_HOST')})[/cyan]")
321
+ else:
322
+ console.print("[cyan]Using database: FalkorDB[/cyan]")
296
323
 
297
324
  # ============================================================================
298
325
  # CONFIG COMMAND GROUP
@@ -352,9 +379,9 @@ def config_db(backend: str = typer.Argument(..., help="Database backend: 'neo4j'
352
379
  cgc config db falkordb
353
380
  """
354
381
  backend = backend.lower()
355
- if backend not in ['falkordb', 'neo4j']:
382
+ if backend not in ['falkordb', 'falkordb-remote', 'neo4j']:
356
383
  console.print(f"[bold red]Invalid backend: {backend}[/bold red]")
357
- console.print("Must be 'falkordb' or 'neo4j'")
384
+ console.print("Must be 'falkordb', 'falkordb-remote', or 'neo4j'")
358
385
  raise typer.Exit(code=1)
359
386
 
360
387
  config_manager.set_config_value("DEFAULT_DATABASE", backend)
@@ -700,7 +727,7 @@ def doctor():
700
727
 
701
728
  if uri and username and password:
702
729
  console.print(f" [cyan]Testing Neo4j connection to {uri}...[/cyan]")
703
- is_connected, error_msg = DatabaseManager.test_connection(uri, username, password)
730
+ is_connected, error_msg = DatabaseManager.test_connection(uri, username, password, database=os.environ.get("NEO4J_DATABASE"))
704
731
  if is_connected:
705
732
  console.print(f" [green]✓[/green] Neo4j connection successful")
706
733
  else:
@@ -377,7 +377,7 @@ def configure_mcp_client():
377
377
  if line and not line.startswith("#") and "=" in line:
378
378
  key, value = line.split("=", 1)
379
379
  key = key.strip()
380
- if key in ["NEO4J_URI", "NEO4J_USERNAME", "NEO4J_PASSWORD"]:
380
+ if key in ["NEO4J_URI", "NEO4J_USERNAME", "NEO4J_PASSWORD", "NEO4J_DATABASE"]:
381
381
  env_vars[key] = value.strip()
382
382
  except Exception:
383
383
  pass