Class: Evilution::MCP::MutateTool

Inherits:
MCP::Tool
  • Object
show all
Defined in:
lib/evilution/mcp/mutate_tool.rb

Constant Summary collapse

VALID_VERBOSITIES =
%w[full summary minimal].freeze
PASSTHROUGH_KEYS =
%i[target timeout jobs fail_fast suggest_tests incremental integration
isolation baseline save_session].freeze
ALLOWED_OPT_KEYS =
(PASSTHROUGH_KEYS + %i[spec skip_config]).freeze

Class Method Summary collapse

Class Method Details

.call(server_context:, files: [], verbosity: nil, **opts) ⇒ Object



106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# File 'lib/evilution/mcp/mutate_tool.rb', line 106

def call(server_context:, files: [], verbosity: nil, **opts)
  validate_opts!(opts)
  parsed_files, line_ranges = parse_files(Array(files))
  config_opts = build_config_opts(parsed_files, line_ranges, opts)
  config = Evilution::Config.new(**config_opts)
  suggest_tests = opts[:suggest_tests]
  on_result = build_streaming_callback(server_context, suggest_tests, config.integration)
  runner = Evilution::Runner.new(config: config, on_result: on_result)
  summary = runner.call
  report = Evilution::Reporter::JSON.new(suggest_tests: suggest_tests == true, integration: config.integration).call(summary)
  compact = trim_report(report, normalize_verbosity(verbosity), summary.survived_results, config)

  ::MCP::Tool::Response.new([{ type: "text", text: compact }])
rescue Evilution::Error => e
  error_payload = build_error_payload(e)
  ::MCP::Tool::Response.new([{ type: "text", text: ::JSON.generate(error_payload) }], error: true)
end