Class: XAeonAgents::Agents::CommitterAgent
- Inherits:
-
ComposableAgents::Agent
- Object
- ComposableAgents::Agent
- XAeonAgents::Agents::CommitterAgent
- Includes:
- XAeonAgents::AgentDefaults
- Defined in:
- lib/x_aeon_agents/agents/committer_agent.rb
Overview
Agent responsible for git committing locally staged or modified files
Instance Method Summary collapse
-
#initialize(user_review: true, stage: :if_empty, authors: [], **agent_params) ⇒ CommitterAgent
constructor
Constructor.
-
#run ⇒ 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(user_review: true, stage: :if_empty, authors: [], **agent_params) ⇒ CommitterAgent
Constructor
16 17 18 19 20 21 |
# File 'lib/x_aeon_agents/agents/committer_agent.rb', line 16 def initialize(user_review: true, stage: :if_empty, authors: [], **agent_params) super(name: 'Committer', **agent_params) @user_review = user_review @stage = stage @authors = end |
Instance Method Details
#run ⇒ Hash{Symbol => Object}
Execute the agent to generate some output artifacts based on some input artifacts.
26 27 28 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 68 |
# File 'lib/x_aeon_agents/agents/committer_agent.rb', line 26 def run case @stage when :all Helpers.git.add(all: true) when :if_empty Helpers.git.add(all: true) if Helpers.git_diff_cached.empty? when :none # Do nothing else raise "Unknown staging strategy: #{@stage}" end if Helpers.git_diff_cached.empty? log_debug 'Nothing to commit' else git_diff_interpreter_agent = GitDiffInterpreterAgent.new git_diff_interpreter_agent_output = git_diff_interpreter_agent.run(git_ref_base: 'cached') content = <<~EO_COMMIT #{git_diff_interpreter_agent_output[:one_line_summary].strip} #{git_diff_interpreter_agent_output[:change_intent].strip} Co-authored by X-Aeon AI Agents: #{ (@authors + [git_diff_interpreter_agent.diff_interpreter_agent]).map do |agent| "* #{agent.full_name}" end.join("\n") } EO_COMMIT if @user_review content, _user_prompt = Helpers.review_content( name: 'commit.md', description: 'Git commit comment', editable: true, content: ) end Helpers.git.commit(content) puts puts 'Commit created successfully.' end {} end |