Class: XAeonAgents::Agents::GitDiffInterpreterAgent

Inherits:
ComposableAgents::Agent
  • Object
show all
Includes:
XAeonAgents::AgentDefaults
Defined in:
lib/x_aeon_agents/agents/git_diff_interpreter_agent.rb

Overview

Agent responsible for analyzing git differences with a given git ref base. The git ref base is given in the git_ref_base input artifact. For the staging area diff, use cached as the git_ref_base content.

Instance Method Summary collapse

Methods included from XAeonAgents::AgentDefaults

#new_agent, prepended, singleton_session_id

Constructor Details

#initialize(**agent_params) ⇒ GitDiffInterpreterAgent

Constructor

Parameters:

  • agent_params (Hash{Symbol => Object})

    Extra agent parameters



29
30
31
# File 'lib/x_aeon_agents/agents/git_diff_interpreter_agent.rb', line 29

def initialize(**agent_params)
  super(name: 'Git Diff Interpreter', **agent_params)
end

Instance Method Details

#diff_interpreter_agentAgent

Get a Diff Interpreter agent.

Returns:

  • (Agent)

    The Diff Interpreter agent



52
53
54
# File 'lib/x_aeon_agents/agents/git_diff_interpreter_agent.rb', line 52

def diff_interpreter_agent
  @diff_interpreter_agent ||= new_agent(DiffInterpreterAgent, **Config.agent_options['free_simple'])
end

#input_artifacts_contractsHash{Symbol => Object}

Define input artifacts contracts

Returns:

  • (Hash{Symbol => Object})

    Set of input artifacts description, per artifact name



12
13
14
# File 'lib/x_aeon_agents/agents/git_diff_interpreter_agent.rb', line 12

def input_artifacts_contracts
  { git_ref_base: 'Git reference used to diff with' }
end

#output_artifacts_contractsHash{Symbol => Object}

Define output artifacts contracts

Returns:

  • (Hash{Symbol => Object})

    Set of output artifacts description, per artifact name



19
20
21
22
23
24
# File 'lib/x_aeon_agents/agents/git_diff_interpreter_agent.rb', line 19

def output_artifacts_contracts
  {
    change_intent: 'Full description of the code changes, their meaning and intent',
    one_line_summary: '1-line summary of the code change intent'
  }
end

#run(git_ref_base:) ⇒ Hash{Symbol => Object}

Execute the agent to generate some output artifacts based on some input artifacts.

Parameters:

  • git_ref_base (String)

    The git reference to diff with. Use 'cached' for the staging area.

Returns:

  • (Hash{Symbol => Object})

    Output artifacts content



37
38
39
40
41
42
43
44
45
46
47
# File 'lib/x_aeon_agents/agents/git_diff_interpreter_agent.rb', line 37

def run(git_ref_base:)
  step_agent(
    diff_interpreter_agent,
    files_diff: Helpers.artifact_files_diffs(git_ref_base == 'cached' ? :cached : git_ref_base)
  )
  step_agent(new_agent(OneLineCodeDiffSummarizerAgent, **Config.agent_options['free_simple']))
  {
    change_intent: @artifacts[:change_intent],
    one_line_summary: @artifacts[:one_line_summary]
  }
end