Class DoctorService

java.lang.Object
com.shaft.mcp.DoctorService

@Service public class DoctorService extends Object
MCP adapter for deterministic SHAFT Doctor analysis with optional configured provider advisory.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates the default local MCP Doctor service.
  • Method Summary

    Modifier and Type
    Method
    Description
    com.shaft.doctor.model.DoctorAnalysisSummary
    analyze(List<String> inputPaths, List<String> historicalBundlePaths, List<String> allowedRoots, String outputDirectory, boolean includeScreenshots, boolean includePageSnapshots, int minimumAllureResults)
    Analyzes explicitly allowed local evidence and optionally appends a configured provider advisory.
    analyzeFailedAllure(List<String> allureResultPaths, List<String> historicalBundlePaths, String outputDirectory, boolean includeScreenshots, boolean includePageSnapshots, int minimumAllureResults, String repositoryRoot, List<String> allowedSourcePaths, boolean useAi, boolean allowLocalAi, boolean allowRemoteAi, String driverVariableName)
    Analyzes failed Allure evidence and returns deterministic remediation plus optional AI advisory snippets.
    analyzeFailedPlaywrightAllure(List<String> allureResultPaths, List<String> historicalBundlePaths, String outputDirectory, boolean includeScreenshots, boolean includePageSnapshots, int minimumAllureResults, String repositoryRoot, List<String> allowedSourcePaths, boolean useAi, boolean allowLocalAi, boolean allowRemoteAi, String driverVariableName)
    Analyzes failed Allure evidence and returns Playwright remediation snippets.
    com.shaft.doctor.repair.DoctorRepairProposalResult
    proposeFix(String repositoryRoot, String baseSha, String diagnosisPath, String evidenceBundlePath, String issueReference, List<String> allowedPaths, List<com.shaft.doctor.repair.DoctorRepairRequest.FilePatch> patches, List<List<String>> validationCommands, boolean networkValidationApproved, String outputDirectory, boolean useAi)
    Creates a repair proposal in an isolated worktree without writing to GitHub.
    com.shaft.doctor.repair.HealingLocatorProposal
    proposeHealedLocator(String repositoryRoot, String healingReportPath, String sourcePath, boolean sourcePatchConsent, String outputDirectory)
    Creates a proposal-only locator patch from a verified SHAFT Heal report.
    com.shaft.doctor.repair.RepairPublicationResult
    publishDraftPr(String manifestPath, boolean approved, String approvalToken, boolean overrideFailedValidation, String overrideRationale, String title)
    Publishes an approved proposal as a draft pull request only.
    suggestFix(String jsonReportPath, String repositoryRoot, List<String> allowedSourcePaths, boolean useAi, boolean allowLocalAi, boolean allowRemoteAi, String driverVariableName)
    Rebuilds MCP remediation actions and code blocks from an existing Doctor JSON report.
    suggestPlaywrightFix(String jsonReportPath, String repositoryRoot, List<String> allowedSourcePaths, boolean useAi, boolean allowLocalAi, boolean allowRemoteAi, String driverVariableName)
    Rebuilds Playwright remediation actions and code blocks from an existing Doctor JSON report.

    Methods inherited from class Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • DoctorService

      public DoctorService()
      Creates the default local MCP Doctor service.
  • Method Details

    • analyzeFailedAllure

      @Tool(name="doctor_analyze_failed_allure", description="analyzes failed Allure results and returns deterministic actions plus copy-paste code blocks") public McpAnalysisReport analyzeFailedAllure(List<String> allureResultPaths, List<String> historicalBundlePaths, String outputDirectory, boolean includeScreenshots, boolean includePageSnapshots, int minimumAllureResults, String repositoryRoot, List<String> allowedSourcePaths, boolean useAi, boolean allowLocalAi, boolean allowRemoteAi, String driverVariableName)
      Analyzes failed Allure evidence and returns deterministic remediation plus optional AI advisory snippets.
      Parameters:
      allureResultPaths - Allure result directories or files inside the MCP workspace
      historicalBundlePaths - optional older Doctor bundles inside the MCP workspace
      outputDirectory - output directory inside the MCP workspace
      includeScreenshots - explicit approval to retain local screenshot evidence
      includePageSnapshots - explicit approval to retain local page-snapshot evidence
      minimumAllureResults - minimum populated Allure result count
      repositoryRoot - optional repository root inside the MCP workspace
      allowedSourcePaths - optional repository-relative source paths approved for AI SOURCE evidence
      useAi - whether to request optional provider snippet fallback
      allowLocalAi - local provider consent for this request
      allowRemoteAi - remote provider consent for this request
      driverVariableName - Java driver variable name used in snippets
      Returns:
      deterministic diagnosis, action records, code blocks, report paths, and provider metadata
    • analyzeFailedPlaywrightAllure

      @Tool(name="playwright_doctor_analyze_failed_allure", description="analyzes failed Allure results and returns SHAFT Playwright remediation code blocks") public McpAnalysisReport analyzeFailedPlaywrightAllure(List<String> allureResultPaths, List<String> historicalBundlePaths, String outputDirectory, boolean includeScreenshots, boolean includePageSnapshots, int minimumAllureResults, String repositoryRoot, List<String> allowedSourcePaths, boolean useAi, boolean allowLocalAi, boolean allowRemoteAi, String driverVariableName)
      Analyzes failed Allure evidence and returns Playwright remediation snippets.
      Parameters:
      allureResultPaths - Allure result directories or files inside the MCP workspace
      historicalBundlePaths - optional older Doctor bundles inside the MCP workspace
      outputDirectory - output directory inside the MCP workspace
      includeScreenshots - explicit approval to retain local screenshot evidence
      includePageSnapshots - explicit approval to retain local page-snapshot evidence
      minimumAllureResults - minimum populated Allure result count
      repositoryRoot - optional repository root inside the MCP workspace
      allowedSourcePaths - optional repository-relative source paths approved for AI SOURCE evidence
      useAi - whether to request optional provider snippet fallback
      allowLocalAi - local provider consent for this request
      allowRemoteAi - remote provider consent for this request
      driverVariableName - Java driver variable name used in snippets
      Returns:
      deterministic diagnosis, action records, code blocks, report paths, and provider metadata
    • suggestFix

      @Tool(name="doctor_suggest_fix", description="returns copy-paste remediation code blocks from an existing SHAFT Doctor report") public McpAnalysisReport suggestFix(String jsonReportPath, String repositoryRoot, List<String> allowedSourcePaths, boolean useAi, boolean allowLocalAi, boolean allowRemoteAi, String driverVariableName)
      Rebuilds MCP remediation actions and code blocks from an existing Doctor JSON report.
      Parameters:
      jsonReportPath - Doctor JSON report path inside the MCP workspace
      repositoryRoot - optional repository root inside the MCP workspace
      allowedSourcePaths - optional repository-relative source paths approved for AI SOURCE evidence
      useAi - whether to request optional provider snippet fallback
      allowLocalAi - local provider consent for this request
      allowRemoteAi - remote provider consent for this request
      driverVariableName - Java driver variable name used in snippets
      Returns:
      deterministic diagnosis, action records, code blocks, report paths, and provider metadata
    • suggestPlaywrightFix

      @Tool(name="playwright_doctor_suggest_fix", description="returns SHAFT Playwright remediation code blocks from an existing Doctor report") public McpAnalysisReport suggestPlaywrightFix(String jsonReportPath, String repositoryRoot, List<String> allowedSourcePaths, boolean useAi, boolean allowLocalAi, boolean allowRemoteAi, String driverVariableName)
      Rebuilds Playwright remediation actions and code blocks from an existing Doctor JSON report.
      Parameters:
      jsonReportPath - Doctor JSON report path inside the MCP workspace
      repositoryRoot - optional repository root inside the MCP workspace
      allowedSourcePaths - optional repository-relative source paths approved for AI SOURCE evidence
      useAi - whether to request optional provider snippet fallback
      allowLocalAi - local provider consent for this request
      allowRemoteAi - remote provider consent for this request
      driverVariableName - Java driver variable name used in snippets
      Returns:
      deterministic diagnosis, action records, code blocks, report paths, and provider metadata
    • analyze

      public com.shaft.doctor.model.DoctorAnalysisSummary analyze(List<String> inputPaths, List<String> historicalBundlePaths, List<String> allowedRoots, String outputDirectory, boolean includeScreenshots, boolean includePageSnapshots, int minimumAllureResults)
      Analyzes explicitly allowed local evidence and optionally appends a configured provider advisory.
      Parameters:
      inputPaths - explicit evidence files or directories
      historicalBundlePaths - optional older Doctor bundle files
      allowedRoots - roots that all readable inputs must remain within
      outputDirectory - report destination inside an allowed root
      includeScreenshots - explicit screenshot retention approval
      includePageSnapshots - explicit page-source or snapshot retention approval
      minimumAllureResults - minimum valid Allure result count expected
      Returns:
      deterministic diagnosis and local report paths
    • proposeFix

      public com.shaft.doctor.repair.DoctorRepairProposalResult proposeFix(String repositoryRoot, String baseSha, String diagnosisPath, String evidenceBundlePath, String issueReference, List<String> allowedPaths, List<com.shaft.doctor.repair.DoctorRepairRequest.FilePatch> patches, List<List<String>> validationCommands, boolean networkValidationApproved, String outputDirectory, boolean useAi)
      Creates a repair proposal in an isolated worktree without writing to GitHub.
      Parameters:
      repositoryRoot - approved Git repository root
      baseSha - exact approved base commit
      diagnosisPath - Doctor diagnosis or combined report JSON
      evidenceBundlePath - optional evidence bundle
      issueReference - linked issue or session
      allowedPaths - approved repository-relative repair scope
      patches - reviewed structured patches
      validationCommands - tokenized Maven validation commands
      networkValidationApproved - whether Maven validation may use the network
      outputDirectory - proposal manifest directory
      useAi - whether to request an optional provider-generated patch instead
      Returns:
      complete proposal and optional provider status
    • proposeHealedLocator

      @Tool(name="doctor_propose_healed_locator", description="maps a verified SHAFT Heal report to one reviewable locator patch without editing source or publishing") public com.shaft.doctor.repair.HealingLocatorProposal proposeHealedLocator(String repositoryRoot, String healingReportPath, String sourcePath, boolean sourcePatchConsent, String outputDirectory)
      Creates a proposal-only locator patch from a verified SHAFT Heal report.
      Parameters:
      repositoryRoot - approved Git repository root
      healingReportPath - verified SHAFT Heal report JSON
      sourcePath - repository-relative Java source file
      sourcePatchConsent - explicit proposal consent
      outputDirectory - proposal artifact directory
      Returns:
      reviewable locator proposal and structured Doctor patch
    • publishDraftPr

      public com.shaft.doctor.repair.RepairPublicationResult publishDraftPr(String manifestPath, boolean approved, String approvalToken, boolean overrideFailedValidation, String overrideRationale, String title)
      Publishes an approved proposal as a draft pull request only.
      Parameters:
      manifestPath - persisted proposal manifest
      approved - explicit publication approval
      approvalToken - exact proposal token
      overrideFailedValidation - explicit failed-validation override
      overrideRationale - required override rationale
      title - optional draft pull-request title
      Returns:
      draft publication details