impl CliAdapter {
    /// Toyota Way Extract Method: Basic analysis commands dispatch
    /// Handles core metrics: churn, complexity, dead code, SATD, TDG, lint hotspots
    fn dispatch_basic_analysis(
        analyze_cmd: &AnalyzeCommands,
    ) -> Result<(Method, String, Value, Option<OutputFormat>), ProtocolError> {
        match analyze_cmd {
            AnalyzeCommands::Churn {
                project_path,
                days,
                format,
                output,
                top_files,
                include: _,
                exclude: _,
            } => Self::decode_analyze_churn(project_path, *days, format, output, *top_files),
            AnalyzeCommands::Complexity {
                path,
                project_path,
                file,
                files,
                toolchain,
                format,
                output,
                max_cyclomatic,
                max_cognitive,
                include,
                watch,
                top_files,
                fail_on_violation: _,
                timeout: _,
                ml: _, // GH-97: ML flag
            } => Self::decode_analyze_complexity_with_migration(
                path,
                project_path,
                file,
                files,
                toolchain,
                format,
                output,
                max_cyclomatic,
                max_cognitive,
                include,
                *watch,
                *top_files,
            ),
            AnalyzeCommands::DeadCode {
                path,
                format,
                top_files,
                include_unreachable,
                min_dead_lines,
                include_tests,
                output,
                fail_on_violation: _,
                max_percentage: _,
                timeout: _,
                include: _,
                exclude: _,
                max_depth: _,
            } => Self::decode_analyze_dead_code(
                path,
                format,
                top_files,
                *include_unreachable,
                *min_dead_lines,
                *include_tests,
                output,
            ),
            AnalyzeCommands::Satd {
                path,
                format,
                severity,
                critical_only,
                include_tests,
                strict,
                evolution,
                days,
                metrics,
                output,
                top_files,
                fail_on_violation: _,
                timeout: _,
                include: _,
                exclude: _,
            } => Self::decode_analyze_satd(
                path,
                format,
                severity,
                *critical_only,
                *include_tests,
                *strict,
                *evolution,
                *days,
                *metrics,
                output,
                *top_files,
            ),
            AnalyzeCommands::Tdg {
                path,
                threshold,
                top_files,
                format,
                include_components,
                output,
                critical_only,
                verbose,
                ml: _, // GH-97: ML flag
            } => Self::decode_analyze_tdg(
                path,
                output,
                format,
                *threshold,
                *critical_only,
                *top_files,
                *include_components,
                *verbose,
            ),
            AnalyzeCommands::LintHotspot {
                project_path,
                file,
                format,
                max_density,
                min_confidence,
                enforce,
                dry_run,
                enforcement_metadata,
                output,
                perf,
                clippy_flags,
                top_files,
                include: _,
                exclude: _,
            } => Self::decode_analyze_lint_hotspot(
                project_path,
                file,
                format,
                max_density,
                min_confidence,
                enforce,
                dry_run,
                enforcement_metadata,
                output,
                perf,
                clippy_flags,
                top_files,
            ),
            _ => Err(ProtocolError::UnsupportedProtocol(
                "Command not supported in basic analysis dispatch".to_string(),
            )),
        }
    }

    /// Toyota Way Extract Method: Advanced analysis commands dispatch
    /// Handles comprehensive analysis: deep context, comprehensive, defect prediction, duplicates, `BigO`
    fn dispatch_advanced_analysis(
        analyze_cmd: &AnalyzeCommands,
    ) -> Result<(Method, String, Value, Option<OutputFormat>), ProtocolError> {
        match analyze_cmd {
            AnalyzeCommands::DeepContext {
                project_path,
                output,
                format,
                full,
                include,
                exclude,
                period_days,
                dag_type,
                max_depth,
                include_patterns,
                exclude_patterns,
                cache_strategy,
                parallel,
                verbose,
                top_files: _,
            } => Self::decode_analyze_deep_context(
                project_path,
                output,
                format,
                *full,
                include,
                exclude,
                *period_days,
                dag_type,
                max_depth,
                include_patterns,
                exclude_patterns,
                cache_strategy,
                parallel,
                *verbose,
            ),
            AnalyzeCommands::Comprehensive {
                project_path,
                file,
                files,
                format,
                include_duplicates,
                include_dead_code,
                include_defects,
                include_complexity,
                include_tdg,
                confidence_threshold,
                min_lines,
                include,
                exclude,
                output,
                perf,
                executive_summary,
                top_files,
            } => Self::decode_analyze_comprehensive(
                project_path,
                file,
                files,
                format,
                include_duplicates,
                include_dead_code,
                include_defects,
                include_complexity,
                include_tdg,
                confidence_threshold,
                min_lines,
                include,
                exclude,
                output,
                perf,
                executive_summary,
                top_files,
            ),
            AnalyzeCommands::DefectPrediction {
                project_path,
                confidence_threshold,
                min_lines,
                include_low_confidence,
                format,
                high_risk_only,
                include_recommendations,
                include,
                exclude,
                output,
                perf,
                top_files,
            } => Self::decode_analyze_defect_prediction(
                project_path,
                confidence_threshold,
                min_lines,
                include_low_confidence,
                format,
                high_risk_only,
                include_recommendations,
                include,
                exclude,
                output,
                perf,
                top_files,
            ),
            AnalyzeCommands::Duplicates {
                project_path,
                detection_type,
                threshold,
                min_lines,
                max_tokens,
                format,
                perf,
                include,
                exclude,
                output,
                top_files,
            } => Self::decode_analyze_duplicates(
                project_path,
                detection_type,
                threshold,
                min_lines,
                max_tokens,
                format,
                perf,
                include,
                exclude,
                output,
                top_files,
            ),
            AnalyzeCommands::BigO {
                project_path,
                format,
                confidence_threshold,
                analyze_space,
                include,
                exclude,
                output,
                perf,
                high_complexity_only,
                top_files,
            } => Self::decode_analyze_big_o(
                project_path,
                format,
                confidence_threshold,
                analyze_space,
                include,
                exclude,
                output,
                perf,
                high_complexity_only,
                top_files,
            ),
            _ => Err(ProtocolError::UnsupportedProtocol(
                "Command not supported in advanced analysis dispatch".to_string(),
            )),
        }
    }

    /// Toyota Way Extract Method: Structural analysis commands dispatch
    /// Handles graph and structural analysis: DAG, graph metrics, symbol table, name similarity
    fn dispatch_structural_analysis(
        analyze_cmd: &AnalyzeCommands,
    ) -> Result<(Method, String, Value, Option<OutputFormat>), ProtocolError> {
        match analyze_cmd {
            AnalyzeCommands::Dag {
                dag_type,
                project_path,
                output,
                max_depth,
                target_nodes,
                filter_external,
                show_complexity,
                include_duplicates,
                include_dead_code,
                enhanced,
            } => Self::decode_analyze_dag(
                dag_type,
                project_path,
                output,
                max_depth,
                target_nodes,
                *filter_external,
                *show_complexity,
                *include_duplicates,
                *include_dead_code,
                *enhanced,
            ),
            AnalyzeCommands::GraphMetrics {
                project_path,
                metrics,
                pagerank_seeds,
                damping_factor,
                max_iterations,
                convergence_threshold,
                format,
                include,
                exclude,
                output,
                export_graphml,
                perf,
                top_k,
                min_centrality,
            } => Self::decode_analyze_graph_metrics(
                project_path,
                metrics,
                pagerank_seeds,
                damping_factor,
                max_iterations,
                convergence_threshold,
                format,
                include,
                exclude,
                output,
                export_graphml,
                perf,
                top_k,
                min_centrality,
            ),
            AnalyzeCommands::SymbolTable {
                project_path,
                format,
                query,
                filter,
                include,
                exclude,
                show_unreferenced,
                show_references,
                output,
                perf,
                top_files,
            } => Self::decode_analyze_symbol_table(
                project_path,
                format,
                query,
                filter,
                include,
                exclude,
                show_unreferenced,
                show_references,
                output,
                perf,
                top_files,
            ),
            AnalyzeCommands::NameSimilarity {
                project_path,
                query,
                top_k,
                phonetic,
                scope,
                threshold,
                format,
                include,
                exclude,
                output,
                perf,
                fuzzy,
                case_sensitive,
            } => Self::decode_analyze_name_similarity(
                project_path,
                query,
                top_k,
                phonetic,
                scope,
                threshold,
                format,
                include,
                exclude,
                output,
                perf,
                fuzzy,
                case_sensitive,
            ),
            _ => Err(ProtocolError::UnsupportedProtocol(
                "Command not supported in structural analysis dispatch".to_string(),
            )),
        }
    }

    /// Toyota Way Extract Method: Specialized analysis commands dispatch
    /// Handles specialized analysis: makefile, provability, proof annotations, coverage, WebAssembly
    fn dispatch_specialized_analysis(
        analyze_cmd: &AnalyzeCommands,
    ) -> Result<(Method, String, Value, Option<OutputFormat>), ProtocolError> {
        match analyze_cmd {
            AnalyzeCommands::Makefile {
                path,
                rules,
                format,
                fix,
                gnu_version,
                top_files,
            } => Self::decode_analyze_makefile(path, rules, format, fix, gnu_version, top_files),
            AnalyzeCommands::Provability {
                project_path,
                functions,
                analysis_depth,
                format,
                high_confidence_only,
                include_evidence,
                output,
                top_files,
            } => Self::decode_analyze_provability(
                project_path,
                functions,
                *analysis_depth,
                format,
                *high_confidence_only,
                *include_evidence,
                output,
                *top_files,
            ),
            AnalyzeCommands::ProofAnnotations {
                project_path,
                format,
                high_confidence_only,
                include_evidence,
                property_type,
                verification_method,
                output,
                perf,
                clear_cache,
                top_files,
            } => Self::decode_analyze_proof_annotations(
                project_path,
                format,
                high_confidence_only,
                include_evidence,
                property_type,
                verification_method,
                output,
                perf,
                clear_cache,
                top_files,
            ),
            AnalyzeCommands::IncrementalCoverage {
                project_path,
                base_branch,
                target_branch,
                format,
                coverage_threshold,
                changed_files_only,
                detailed,
                output,
                perf,
                cache_dir,
                force_refresh,
                top_files,
            } => Self::decode_analyze_incremental_coverage(
                project_path,
                base_branch,
                target_branch,
                format,
                coverage_threshold,
                changed_files_only,
                detailed,
                output,
                perf,
                cache_dir,
                force_refresh,
                top_files,
            ),
            AnalyzeCommands::AssemblyScript { top_files: _, .. } => {
                Self::decode_analyze_assemblyscript()
            }
            AnalyzeCommands::WebAssembly { top_files: _, .. } => Self::decode_analyze_webassembly(),
            _ => Err(ProtocolError::UnsupportedProtocol(
                "Command not supported in specialized analysis dispatch".to_string(),
            )),
        }
    }
}
