MCPcopy Index your code
hub / github.com/CodeGraphContext/CodeGraphContext / doctor

Function doctor

src/codegraphcontext/cli/main.py:843–1034  ·  view source on GitHub ↗

Run diagnostics to check system health and configuration. Checks: - Configuration validity - Database connectivity - Tree-sitter installation - Required dependencies - File permissions

()

Source from the content-addressed store, hash-verified

841
842@app.command()
843def doctor():
844 """
845 Run diagnostics to check system health and configuration.
846
847 Checks:
848 - Configuration validity
849 - Database connectivity
850 - Tree-sitter installation
851 - Required dependencies
852 - File permissions
853 """
854 console.print("[bold cyan]🏥 Running CodeGraphContext Diagnostics...[/bold cyan]\n")
855
856 all_checks_passed = True
857
858 config_manager.ensure_first_run_bootstrap()
859 config_manager.ensure_config_file()
860
861 # 1. Check configuration
862 console.print("[bold]1. Checking Configuration...[/bold]")
863 config = {}
864 try:
865 config = config_manager.load_config()
866
867 if config_manager.CONFIG_FILE.exists():
868 console.print(f" [green]✓[/green] Config loaded from {config_manager.CONFIG_FILE}")
869 else:
870 console.print(f" [yellow]ℹ[/yellow] No .env config found, using defaults")
871 console.print(f" [dim]Config will be created at: {config_manager.CONFIG_FILE}[/dim]")
872
873 if config_manager.CONTEXT_CONFIG_FILE.exists():
874 console.print(f" [green]✓[/green] Context config loaded from {config_manager.CONTEXT_CONFIG_FILE}")
875 else:
876 console.print(f" [yellow]ℹ[/yellow] No Context config found")
877 console.print(f" [dim]Context config will be auto-generated at: {config_manager.CONTEXT_CONFIG_FILE}[/dim]")
878
879 # Validate each config value
880 invalid_configs = []
881 for key, value in config.items():
882 is_valid, error_msg = config_manager.validate_config_value(key, value)
883 if not is_valid:
884 invalid_configs.append(f"{key}: {error_msg}")
885
886 if invalid_configs:
887 console.print(f" [red]✗[/red] Invalid configuration values found:")
888 for err in invalid_configs:
889 console.print(f" - {err}")
890 all_checks_passed = False
891 else:
892 console.print(f" [green]✓[/green] All configuration values are valid")
893 except Exception as e:
894 console.print(f" [red]✗[/red] Configuration error: {e}")
895 all_checks_passed = False
896
897 # 2. Check database connectivity
898 console.print("\n[bold]2. Checking Database Connection...[/bold]")
899 try:
900 _load_credentials()

Callers

nothing calls this directly

Calls 8

_load_credentialsFunction · 0.85
itemsMethod · 0.80
extract_host_portMethod · 0.80
check_port_reachableMethod · 0.80
valuesMethod · 0.80
getMethod · 0.65
test_connectionMethod · 0.45

Tested by

no test coverage detected