Run diagnostics to check system health and configuration. Checks: - Configuration validity - Database connectivity - Tree-sitter installation - Required dependencies - File permissions
()
| 841 | |
| 842 | @app.command() |
| 843 | def 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() |
nothing calls this directly
no test coverage detected