Class: XAeonAgents::Agents::IssueImplementerAgent

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

Overview

Agent responsible for implementing a GitHub issue using AI.

Instance Method Summary collapse

Methods included from XAeonAgents::AgentDefaults

#new_agent, prepended, singleton_session_id

Constructor Details

#initialize(commit: false, pull_request: false, **agent_params) ⇒ IssueImplementerAgent

Constructor

Parameters:

  • commit (Boolean) (defaults to: false)

    Whether to commit changes automatically

  • pull_request (Boolean) (defaults to: false)

    Whether to create a pull request automatically

  • agent_params (Hash{Symbol => Object})

    Extra agent parameters



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

def initialize(commit: false, pull_request: false, **agent_params)
  super(name: 'Issue Implementer', **agent_params)
  @commit = commit
  @pull_request = pull_request
end

Instance Method Details

#input_artifacts_contractsHash{Symbol => Object}

Define input artifacts contracts

Returns:

  • (Hash{Symbol => Object})

    Set of input artifacts description, per artifact name



10
11
12
# File 'lib/x_aeon_agents/agents/issue_implementer_agent.rb', line 10

def input_artifacts_contracts
  { github_issue_number: 'GitHub issue number to implement' }
end

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

Execute the agent to implement a GitHub issue.

Parameters:

  • github_issue_number (Integer)

    The GitHub issue number

Returns:

  • (Hash{Symbol => Object})

    Output artifacts content



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/x_aeon_agents/agents/issue_implementer_agent.rb', line 29

def run(github_issue_number:)
  raise 'Unable to find the Github repository' unless Helpers.github_repo

  issue = Helpers.github.issue(Helpers.github_repo, github_issue_number)
  issue_comments = Helpers.github.issue_comments(Helpers.github_repo, github_issue_number)
  sections = [
    <<~EO_SECTION
      # #{issue.title}

      #{ComposableAgents::Utils::Markdown.align_markdown_headers(issue.body, level: 2)}
    EO_SECTION
  ]
  unless issue_comments.empty?
    sections << <<~EO_SECTION
      # Comments

      This is the conversation log that happened in this issue.
      This is provided as a reference to better understand the requirements.

      #{format_comments_for_artifact(issue_comments)}
    EO_SECTION
  end
  issue_properties = ["Number: #{issue.number}"]
  issue_properties << "Labels: #{issue.labels.map(&:name).join(', ')}" unless issue.labels.empty?
  issue_properties.push(
    "State: #{issue.state}",
    "URL: #{issue.html_url}"
  )
  sections << <<~EO_SECTION
    # Associated Github issue

    #{issue_properties.map { |line| "- #{line}" }.join("\n")}
  EO_SECTION
  step_agent(
    new_agent(DeveloperAgent, commit: @commit, pull_request: @pull_request),
    requirements: sections.map(&:strip).join("\n\n")
  )
  {}
end