Class: Reviewer::Capabilities

Inherits:
Object
  • Object
show all
Defined in:
lib/reviewer/capabilities.rb

Overview

Provides machine-readable output describing available tools and usage patterns. Designed for AI agents and automation tools to discover and use Reviewer correctly.

Examples:

puts Reviewer::Capabilities.new.to_json

Constant Summary collapse

KEYWORD_DESCRIPTIONS =

Descriptions for the reserved keywords. The keys are derived from Arguments::Keywords::RESERVED rather than restated, so a keyword can never exist in one place and be invisible in the other -- agents are told to use only names this payload lists.

{
  'staged' => 'Files staged for commit',
  'unstaged' => 'Files with unstaged changes',
  'modified' => 'All changed files',
  'untracked' => 'New files not yet tracked',
  'failed' => 'Tools whose last executed review failed and have not passed since'
}.freeze
KEYWORDS =
Arguments::Keywords::RESERVED.to_h do |keyword|
  [keyword.to_sym, KEYWORD_DESCRIPTIONS.fetch(keyword)]
end.freeze
SCENARIOS =
{
  before_commit: 'rvw staged',
  during_development: 'rvw modified',
  full_review: 'rvw'
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(tools:) ⇒ Capabilities

Creates a capabilities report for machine-readable tool discovery

Parameters:

  • tools (Tools)

    the tools collection to report on



18
19
20
# File 'lib/reviewer/capabilities.rb', line 18

def initialize(tools:)
  @tools = tools
end

Instance Attribute Details

#toolsObject (readonly)

Returns the value of attribute tools.



12
13
14
# File 'lib/reviewer/capabilities.rb', line 12

def tools
  @tools
end

Instance Method Details

#to_hHash

Convert capabilities to a hash representation

Returns:

  • (Hash)

    structured capabilities data



47
48
49
50
51
52
53
54
55
# File 'lib/reviewer/capabilities.rb', line 47

def to_h
  {
    version: VERSION,
    tools: tools_data,
    tags: tag_list,
    keywords: KEYWORDS,
    scenarios: SCENARIOS
  }
end

#to_json(*_args) ⇒ String

Convert capabilities to formatted JSON string

Returns:

  • (String)

    JSON representation of capabilities



60
61
62
# File 'lib/reviewer/capabilities.rb', line 60

def to_json(*_args)
  JSON.pretty_generate(to_h)
end