Class: CovLoupe::Tools::HelpTool

Inherits:
BaseTool
  • Object
show all
Defined in:
lib/cov_loupe/tools/help_tool.rb

Constant Summary collapse

TOOL_GUIDE =
[
  {
    tool:       FileCoverageSummaryTool,
    label:      'Single-file coverage summary',
    use_when:   'User wants covered/total line counts or percentage for one file.',
    avoid_when: 'User needs repo-wide stats or specific uncovered lines.',
    inputs:     ['path (required)', 'root/resultset/raise_on_stale (optional)'],
  },
  {
    tool:       FileUncoveredLinesTool,
    label:      'Uncovered line numbers',
    use_when:   'User asks which lines in a file still lack tests.',
    avoid_when: 'User only wants overall percentages or detailed per-line hit data.',
    inputs:     ['path (required)', 'root/resultset/raise_on_stale (optional)'],
  },
  {
    tool:       FileCoverageDetailedTool,
    label:      'Per-line coverage details',
    use_when:   'User needs per-line hit counts for a file.',
    avoid_when: 'User only wants totals or uncovered line numbers.',
    inputs:     ['path (required)', 'root/resultset/raise_on_stale (optional)'],
  },
  {
    tool:       FileCoverageRawTool,
    label:      'Raw SimpleCov lines array',
    use_when:   'User needs the raw SimpleCov `lines` array for a file.',
    avoid_when: 'User expects human-friendly summaries or explanations.',
    inputs:     ['path (required)', 'root/resultset/raise_on_stale (optional)'],
  },
  {
    tool:       ProjectCoverageTool,
    label:      'Project coverage (JSON, table, YAML, etc.)',
    use_when:   'User wants coverage data for every tracked file in their preferred format.',
    avoid_when: 'User asks about a single file or only wants totals.',
    inputs:     ['root/resultset (optional)', 'sort_order', 'raise_on_stale', 'tracked_globs',
      'format (json/pretty_json/yaml/amazing_print/inspect/puts/pretty_print/table)'],
  },
  {
    tool:       ProjectCoverageTotalsTool,
    label:      'Project coverage totals',
    use_when:   'User wants total/covered/uncovered line counts or the average percent.',
    avoid_when: 'User needs per-file breakdowns.',
    inputs:     ['root/resultset (optional)', 'raise_on_stale', 'tracked_globs'],
  },
  {
    tool:       ProjectValidateTool,
    label:      'Validate coverage policy',
    use_when:   'User needs to enforce coverage rules (e.g., minimum percentage) in CI.',
    avoid_when: 'User just wants to view coverage data.',
    inputs:     ['code OR file (one required)', 'root/resultset/raise_on_stale (optional)'],
  },
  {
    tool:       VersionTool,
    label:      'cov-loupe --version',
    use_when:   'User needs to confirm the running gem version.',
    avoid_when: 'User is asking for coverage information.',
    inputs:     ['(no arguments)'],
  },
].freeze

Constants inherited from BaseTool

BaseTool::COMMON_PROPERTIES, BaseTool::DEFAULT_SORT_ORDER, BaseTool::ERROR_MODE_PROPERTY, BaseTool::FILE_INPUT_SCHEMA, BaseTool::PATH_PROPERTY, BaseTool::SORT_ORDER_PROPERTY, BaseTool::TRACKED_GLOBS_PROPERTY

Class Method Summary collapse

Methods inherited from BaseTool

call_with_file_payload, coverage_schema, create_configured_model, create_model, default_model_options, handle_mcp_error, input_schema_def, model_config_for, resolve_output_chars, respond_json, with_error_handling

Class Method Details

.call(error_mode: 'log', output_chars: nil, server_context:, **_unused) ⇒ Object



84
85
86
87
88
89
90
91
92
93
# File 'lib/cov_loupe/tools/help_tool.rb', line 84

def call(error_mode: 'log', output_chars: nil, server_context:, **_unused)
  # Normalize output_chars before error handling so errors also get converted
  output_chars_sym = resolve_output_chars(output_chars, server_context)
  with_error_handling('HelpTool', error_mode: error_mode, output_chars: output_chars_sym) do
    entries = TOOL_GUIDE.map { |guide| format_entry(guide) }

    respond_json({ tools: entries, resources: Resources::RESOURCE_MAP }, name: 'tools_help.json',
      output_chars: output_chars_sym)
  end
end