Class: XAeonAgents::Agents::DeveloperAgent
- Inherits:
-
ComposableAgents::Agent
- Object
- ComposableAgents::Agent
- XAeonAgents::Agents::DeveloperAgent
- Includes:
- XAeonAgents::AgentDefaults
- Defined in:
- lib/x_aeon_agents/agents/developer_agent.rb
Overview
Agent responsible for developing some requirements
Instance Method Summary collapse
-
#initialize(commit: false, pull_request: false, **agent_params) ⇒ DeveloperAgent
constructor
Constructor.
-
#input_artifacts_contracts ⇒ Hash{Symbol => Object}
Define input artifacts contracts.
-
#run(requirements:) ⇒ Hash{Symbol => Object}
Execute the agent to generate some output artifacts based on some input artifacts.
Methods included from XAeonAgents::AgentDefaults
#new_agent, prepended, singleton_session_id
Constructor Details
#initialize(commit: false, pull_request: false, **agent_params) ⇒ DeveloperAgent
Constructor
21 22 23 24 25 |
# File 'lib/x_aeon_agents/agents/developer_agent.rb', line 21 def initialize(commit: false, pull_request: false, **agent_params) super(name: 'Developer', **agent_params) @commit = commit @pull_request = pull_request end |
Instance Method Details
#input_artifacts_contracts ⇒ Hash{Symbol => Object}
Define input artifacts contracts
12 13 14 |
# File 'lib/x_aeon_agents/agents/developer_agent.rb', line 12 def input_artifacts_contracts { requirements: 'The initial requirements that need to be implemented' } end |
#run(requirements:) ⇒ Hash{Symbol => Object}
Execute the agent to generate some output artifacts based on some input artifacts.
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 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 |
# File 'lib/x_aeon_agents/agents/developer_agent.rb', line 31 def run(requirements:) # Initial artifacts step(:setup_requirements) do @artifacts.merge!( requirements:, base_sha: Helpers.git.gcommit('HEAD').sha ) end planner_agent = new_agent(PlannerAgent) step_agent(planner_agent) coder_agent = new_agent(CoderAgent, **Config.['free_complex']) step_agent( coder_agent, user_instructions: "Follow all the steps of the implementation plan described in the artifact named `#{coder_agent.artifact_ref(:plan)}`." ) puts "===== Coder changes: #{Helpers.git.status.changed.keys.join(', ')}" step_agent(new_agent(CommitterAgent, user_review: false, stage: :all, authors: [coder_agent])) if @commit tester_agent = new_agent(TesterAgent, **Config.['free_complex']) step(:test) do tests_cmd = 'bundle exec rspec --format documentation' @artifacts[:tests_cmd] = tests_cmd idx_test = 0 loop do puts puts "===== Run tests ##{idx_test}..." test_result = Helpers.run_cmd(tests_cmd, expected_exit_status: nil) puts "Tests ##{idx_test} exit status: #{test_result[:exit_status]}" @artifacts[:tests_output] = <<~EO_ARTIFACT ``` #{test_result[:stdout]} ``` EO_ARTIFACT break if test_result[:exit_status].zero? @artifacts[:files_diffs] = Helpers.artifact_files_diffs(@artifacts[:base_sha]) step_agent( tester_agent, user_instructions: { ordered_list: [ <<~EO_STEP, <<~EO_STEP, <<~EO_STEP, <<~EO_STEP, 'Fix any issue that unit tests are surfacing, while keeping the original intent of the requirements', 'Remember any inconsistency and modification you need to make to the implementation plan ' \ 'so that your fixes are in-line with a better implementation plan', <<~EO_STEP Make sure all tests are running without issue after your fixes - You can run tests again using the provided tests command from the artifact named `#{tester_agent.artifact_ref(:tests_cmd)}` to test your own fixes. EO_STEP ] } ) puts "===== Tester changes: #{Helpers.git.status.changed.keys.join(', ')}" # Integrate potential implementation plan modifications unless @artifacts[:plan_modifications].strip.empty? plan_modifications = @artifacts.delete(:plan_modifications) @artifacts[:plan] = <<~EO_PLAN #{@artifacts[:plan].strip} # Revision ##{idx_test} to the implementation plan #{ComposableAgents::Utils::Markdown.align_markdown_headers(plan_modifications, level: 2)} EO_PLAN end step_agent(new_agent(CommitterAgent, user_review: false, stage: :all, authors: [tester_agent])) if @commit idx_test += 1 end end step_agent(new_agent(CommitterAgent, user_review: false, stage: :all, authors: [tester_agent])) if @commit documenter_agent = new_agent(DocumenterAgent, **Config.['free_complex']) @artifacts[:files_diffs] = Helpers.artifact_files_diffs(@artifacts[:base_sha]) step_agent( documenter_agent, user_instructions: { ordered_list: [ <<~EO_STEP, <<~EO_STEP, <<~EO_STEP, <<~EO_STEP, <<~EO_STEP, <<~EO_STEP Update the relevant documentation files - Only perform this step if you think documentation is required. - Use artifacts as the source of truth for understanding the changes to be documented. - Use the filesystem to locate where documentation should be updated. - After exploring the filesystem, if relevant documentation files are found: update them. When updating documentation: - Modify existing sections if they already describe related functionality. - Add new sections if the feature is not documented. - Keep consistency with existing documentation style. - Prefer minimal, precise updates over large rewrites. EO_STEP ] } ) puts "===== Documenter changes: #{Helpers.git.status.changed.keys.join(', ')}" if @commit || @pull_request step_agent( new_agent( CommitterAgent, user_review: false, stage: :all, authors: (@commit ? [] : [coder_agent, tester_agent]) + [documenter_agent] ) ) end if @pull_request step_agent( new_agent( PullRequestCreatorAgent, authors: [ planner_agent.plan_generator_agent, coder_agent, tester_agent, documenter_agent ] ) ) end puts puts 'Requirements implemented successfully' @artifacts end |