Class DoctorService
java.lang.Object
com.shaft.mcp.DoctorService
MCP adapter for deterministic SHAFT Doctor analysis with optional configured provider advisory.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionanalyze(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, String backend) Analyzes failed Allure evidence and returns deterministic remediation plus optional AI advisory snippets.proposeAdvisoryLocator(String repositoryRoot, String healingReportPath, String sourcePath, boolean sourcePatchConsent, String outputDirectory) Creates an advisory-only, unconfirmed locator patch proposal from a low-trust (BELOW_THRESHOLD) SHAFT Heal report (issue #4194).proposeFix(String repositoryRoot, String baseSha, String diagnosisPath, String evidenceBundlePath, String issueReference, List<String> allowedPaths, List<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.proposeHealedLocator(String repositoryRoot, String healingReportPath, String sourcePath, boolean sourcePatchConsent, String outputDirectory) Creates a proposal-only locator patch from a verified SHAFT Heal report.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, String backend) Rebuilds MCP remediation actions and code blocks from an existing Doctor JSON report.
-
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; accepts allure-results directories, individual *-result.json files, or a SHAFT single-file AllureReport.html; when allureResultPaths is empty, automatically analyzes the newest such evidence found in the workspace; optional backend (web|playwright, defaults to web) selects the generated remediation snippets' engine, absorbing playwright_doctor_analyze_failed_allure") 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, @ToolParam(required=false) String backend) Analyzes failed Allure evidence and returns deterministic remediation plus optional AI advisory snippets.- Parameters:
allureResultPaths- Allure result directories or files inside the MCP workspacehistoricalBundlePaths- optional older Doctor bundles inside the MCP workspaceoutputDirectory- output directory inside the MCP workspaceincludeScreenshots- explicit approval to retain local screenshot evidenceincludePageSnapshots- explicit approval to retain local page-snapshot evidenceminimumAllureResults- minimum populated Allure result countrepositoryRoot- optional repository root inside the MCP workspaceallowedSourcePaths- optional repository-relative source paths approved for AI SOURCE evidenceuseAi- whether to request optional provider snippet fallbackallowLocalAi- local provider consent for this requestallowRemoteAi- remote provider consent for this requestdriverVariableName- 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; optional backend (web|playwright, defaults to web) selects the generated snippets' engine, absorbing playwright_doctor_suggest_fix") public McpAnalysisReport suggestFix(String jsonReportPath, String repositoryRoot, List<String> allowedSourcePaths, boolean useAi, boolean allowLocalAi, boolean allowRemoteAi, String driverVariableName, @ToolParam(required=false) String backend) Rebuilds MCP remediation actions and code blocks from an existing Doctor JSON report.- Parameters:
jsonReportPath- Doctor JSON report path inside the MCP workspacerepositoryRoot- optional repository root inside the MCP workspaceallowedSourcePaths- optional repository-relative source paths approved for AI SOURCE evidenceuseAi- whether to request optional provider snippet fallbackallowLocalAi- local provider consent for this requestallowRemoteAi- remote provider consent for this requestdriverVariableName- Java driver variable name used in snippetsbackend- optional codegen target ("web" default | "playwright"); absorbs playwright_doctor_suggest_fix- Returns:
- deterministic diagnosis, action records, code blocks, report paths, and provider metadata
-
analyze
public 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 directorieshistoricalBundlePaths- optional older Doctor bundle filesallowedRoots- roots that all readable inputs must remain withinoutputDirectory- report destination inside an allowed rootincludeScreenshots- explicit screenshot retention approvalincludePageSnapshots- explicit page-source or snapshot retention approvalminimumAllureResults- minimum valid Allure result count expected- Returns:
- deterministic diagnosis and local report paths
-
proposeFix
public DoctorRepairProposalResult proposeFix(String repositoryRoot, String baseSha, String diagnosisPath, String evidenceBundlePath, String issueReference, List<String> allowedPaths, List<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 rootbaseSha- exact approved base commitdiagnosisPath- Doctor diagnosis or combined report JSONevidenceBundlePath- optional evidence bundleissueReference- linked issue or sessionallowedPaths- approved repository-relative repair scopepatches- reviewed structured patchesvalidationCommands- tokenized Maven validation commandsnetworkValidationApproved- whether Maven validation may use the networkoutputDirectory- proposal manifest directoryuseAi- 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 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 roothealingReportPath- verified SHAFT Heal report JSONsourcePath- repository-relative Java source filesourcePatchConsent- explicit proposal consentoutputDirectory- proposal artifact directory- Returns:
- reviewable locator proposal and structured Doctor patch
-
proposeAdvisoryLocator
@Tool(name="doctor_propose_advisory_locator", description="maps a low-trust SHAFT Heal report to one reviewable advisory locator comment proposal without editing, replacing, or publishing") public HealingLocatorProposal proposeAdvisoryLocator(String repositoryRoot, String healingReportPath, String sourcePath, boolean sourcePatchConsent, String outputDirectory) Creates an advisory-only, unconfirmed locator patch proposal from a low-trust (BELOW_THRESHOLD) SHAFT Heal report (issue #4194).Unlike
proposeHealedLocator(String, String, String, boolean, String), this never requires a confirmed recovery -- a low-confidence best candidate is exactly the signal this exists for. The resulting patch only adds a review comment; it never replaces the existing locator.- Parameters:
repositoryRoot- approved Git repository roothealingReportPath- low-trust SHAFT Heal report JSONsourcePath- repository-relative Java source filesourcePatchConsent- explicit proposal consentoutputDirectory- proposal artifact directory- Returns:
- reviewable advisory proposal and structured Doctor patch
-
publishDraftPr
public 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 manifestapproved- explicit publication approvalapprovalToken- exact proposal tokenoverrideFailedValidation- explicit failed-validation overrideoverrideRationale- required override rationaletitle- optional draft pull-request title- Returns:
- draft publication details
-