Class CaptureService

java.lang.Object
com.shaft.mcp.CaptureService

@Service public class CaptureService extends Object
MCP adapter for deterministic managed-browser SHAFT Capture recording.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final class 
    Structured request fields for the Playwright-codegen-compatible MCP start tool.
  • Constructor Summary

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

    Modifier and Type
    Method
    Description
    com.shaft.capture.runtime.CaptureStatus
    checkpoint(String description, String kind)
    Adds a human-review checkpoint to the active recording.
    codeBlocks(String sessionPath, String outputDirectory, String packageName, String className, boolean overwrite, String driverVariableName)
    Generates deterministic copy-paste code blocks from a persisted Capture session without replaying.
    List<com.shaft.capture.generate.CodegenFeatureCatalog.Feature>
    Returns the Playwright codegen feature inventory and SHAFT support mapping.
    com.shaft.capture.generate.CaptureGenerationResult
    generate(String sessionPath, String outputDirectory, String packageName, String className, boolean overwrite, boolean replay, boolean aiPreview, String enrichmentPreviewPath, boolean applyEnrichment, boolean approveEnrichment, boolean allowLocalAi, boolean allowRemoteAi)
    Generates a deterministic SHAFT TestNG test from a persisted Capture session.
    generatePlaywrightReplay(String sessionPath, String outputDirectory, String packageName, String className, boolean overwrite, boolean replay, boolean useAi, boolean allowLocalAi, boolean allowRemoteAi, String driverVariableName)
    Generates, compiles, and optionally replays a SHAFT Playwright TestNG test from a Capture session.
    generateReplay(String sessionPath, String outputDirectory, String packageName, String className, boolean overwrite, boolean replay, boolean useAi, boolean allowLocalAi, boolean allowRemoteAi, String driverVariableName)
    Generates, compiles, and optionally replays a deterministic SHAFT TestNG test from a Capture session.
    playwrightCodeBlocks(String sessionPath, String outputDirectory, String packageName, String className, boolean overwrite, String driverVariableName)
    Generates deterministic copy-paste SHAFT Playwright code blocks from a persisted Capture session.
    com.shaft.capture.runtime.CaptureStatus
    start(String targetUrl, String browser, String outputPath, boolean headless)
    Launches a fresh SHAFT-managed browser and starts deterministic capture.
    com.shaft.capture.runtime.CaptureStatus
    Launches a fresh SHAFT-managed browser with Playwright-codegen-shaped options.
    com.shaft.capture.runtime.CaptureStatus
    Returns safe recorder status without captured values.
    com.shaft.capture.runtime.CaptureStatus
    stop(boolean discard)
    Stops the active recording.

    Methods inherited from class Object

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

    • CaptureService

      public CaptureService()
      Creates the default MCP Capture service.
  • Method Details

    • start

      @Tool(name="capture_start", description="starts a privacy-safe SHAFT managed-browser recording with live browser controls") public com.shaft.capture.runtime.CaptureStatus start(String targetUrl, String browser, String outputPath, boolean headless)
      Launches a fresh SHAFT-managed browser and starts deterministic capture.
      Parameters:
      targetUrl - initial http, https, or file URL
      browser - Chrome or Edge; blank selects Chrome
      outputPath - capture JSON path; blank selects a timestamped recording
      headless - whether to launch without a visible window
      Returns:
      safe recorder status
    • startWithOptions

      @Tool(name="capture_start_codegen", description="starts SHAFT Capture with Playwright-codegen-compatible options and live browser controls") public com.shaft.capture.runtime.CaptureStatus startWithOptions(CaptureService.CaptureCodegenStartRequest request)
      Launches a fresh SHAFT-managed browser with Playwright-codegen-shaped options.
      Parameters:
      request - structured codegen recording request
      Returns:
      safe recorder status
    • codegenFeatures

      @Tool(name="capture_codegen_features", description="returns Playwright codegen features and how SHAFT Capture/MCP maps each feature") public List<com.shaft.capture.generate.CodegenFeatureCatalog.Feature> codegenFeatures()
      Returns the Playwright codegen feature inventory and SHAFT support mapping.
      Returns:
      codegen feature mapping
    • status

      @Tool(name="capture_status", description="returns SHAFT Capture session, browser, URL, event count, warnings, and output status") public com.shaft.capture.runtime.CaptureStatus status()
      Returns safe recorder status without captured values.
      Returns:
      current or final recorder status
    • stop

      @Tool(name="capture_stop", description="stops SHAFT Capture; after COMPLETED, call capture_code_blocks and ask snippet or insertion") public com.shaft.capture.runtime.CaptureStatus stop(boolean discard)
      Stops the active recording.
      Parameters:
      discard - whether to delete capture artifacts after shutdown
      Returns:
      final recorder status
    • checkpoint

      @Tool(name="capture_checkpoint", description="records a USER_MARKER, ASSERTION, PAGE_TRANSITION, or RECOVERY checkpoint") public com.shaft.capture.runtime.CaptureStatus checkpoint(String description, String kind)
      Adds a human-review checkpoint to the active recording.
      Parameters:
      description - checkpoint description
      kind - checkpoint kind; blank selects USER_MARKER
      Returns:
      safe recorder status
    • generateReplay

      @Tool(name="capture_generate_replay", description="generates, compiles, optionally replays, and returns copy-paste SHAFT code blocks") public McpCaptureReplayResult generateReplay(String sessionPath, String outputDirectory, String packageName, String className, boolean overwrite, boolean replay, boolean useAi, boolean allowLocalAi, boolean allowRemoteAi, String driverVariableName)
      Generates, compiles, and optionally replays a deterministic SHAFT TestNG test from a Capture session.
      Parameters:
      sessionPath - persisted Capture JSON path inside the MCP workspace
      outputDirectory - generated project root inside the MCP workspace
      packageName - generated Java package
      className - optional generated class name
      overwrite - whether existing artifacts may be replaced
      replay - whether to execute the generated test
      useAi - whether to request optional AI enrichment preview
      allowLocalAi - explicit approval for local inference
      allowRemoteAi - explicit approval for remote inference
      driverVariableName - Java driver variable name used in extracted snippets
      Returns:
      generation report plus copy-paste code blocks
    • generatePlaywrightReplay

      @Tool(name="playwright_capture_generate_replay", description="generates, compiles, optionally replays, and returns copy-paste SHAFT Playwright code blocks") public McpCaptureReplayResult generatePlaywrightReplay(String sessionPath, String outputDirectory, String packageName, String className, boolean overwrite, boolean replay, boolean useAi, boolean allowLocalAi, boolean allowRemoteAi, String driverVariableName)
      Generates, compiles, and optionally replays a SHAFT Playwright TestNG test from a Capture session.
      Parameters:
      sessionPath - persisted Capture JSON path inside the MCP workspace
      outputDirectory - generated project root inside the MCP workspace
      packageName - generated Java package
      className - optional generated class name
      overwrite - whether existing artifacts may be replaced
      replay - whether to execute the generated test
      useAi - whether to request optional AI enrichment preview
      allowLocalAi - explicit approval for local inference
      allowRemoteAi - explicit approval for remote inference
      driverVariableName - Java driver variable name used in extracted snippets
      Returns:
      generation report plus copy-paste code blocks
    • codeBlocks

      @Tool(name="capture_code_blocks", description="generates a Java full-class snippet plus agent guidance for repo-aware insertion") public McpCaptureReplayResult codeBlocks(String sessionPath, String outputDirectory, String packageName, String className, boolean overwrite, String driverVariableName)
      Generates deterministic copy-paste code blocks from a persisted Capture session without replaying.
      Parameters:
      sessionPath - persisted Capture JSON path inside the MCP workspace
      outputDirectory - generated project root inside the MCP workspace
      packageName - generated Java package
      className - optional generated class name
      overwrite - whether existing artifacts may be replaced
      driverVariableName - Java driver variable name used in extracted snippets
      Returns:
      generated snippets and report
    • playwrightCodeBlocks

      @Tool(name="playwright_capture_code_blocks", description="generates a Java full-class snippet plus agent guidance for SHAFT Playwright insertion") public McpCaptureReplayResult playwrightCodeBlocks(String sessionPath, String outputDirectory, String packageName, String className, boolean overwrite, String driverVariableName)
      Generates deterministic copy-paste SHAFT Playwright code blocks from a persisted Capture session.
      Parameters:
      sessionPath - persisted Capture JSON path inside the MCP workspace
      outputDirectory - generated project root inside the MCP workspace
      packageName - generated Java package
      className - optional generated class name
      overwrite - whether existing artifacts may be replaced
      driverVariableName - Java driver variable name used in extracted snippets
      Returns:
      generated snippets and report
    • generate

      public com.shaft.capture.generate.CaptureGenerationResult generate(String sessionPath, String outputDirectory, String packageName, String className, boolean overwrite, boolean replay, boolean aiPreview, String enrichmentPreviewPath, boolean applyEnrichment, boolean approveEnrichment, boolean allowLocalAi, boolean allowRemoteAi)
      Generates a deterministic SHAFT TestNG test from a persisted Capture session.
      Parameters:
      sessionPath - persisted Capture JSON path
      outputDirectory - generated project root
      packageName - generated Java package
      className - optional generated class name
      overwrite - whether existing artifacts may be replaced
      replay - whether to execute the compiled generated test
      aiPreview - whether to request a review-only AI proposal
      enrichmentPreviewPath - preview path to write or apply
      applyEnrichment - whether to apply the reviewed preview
      approveEnrichment - explicit approval to apply the preview
      allowLocalAi - explicit approval for local inference
      allowRemoteAi - explicit approval for remote inference
      Returns:
      generated artifacts and validation report