Commit b157106
Changed files (5)
lib/elelem/states/idle.rb
@@ -0,0 +1,23 @@
+# frozen_string_literal: true
+
+module Elelem
+ module States
+ class Idle
+ def run(agent)
+ agent.logger.debug("Idling...")
+ agent.tui.say("#{Dir.pwd} (#{agent.model}) [#{git_branch}]", colour: :magenta, newline: true)
+ input = agent.tui.prompt("モ ")
+ agent.quit if input.nil? || input.empty? || input == "exit" || input == "quit"
+
+ agent.conversation.add(role: :user, content: input)
+ agent.transition_to(Working.new)
+ end
+
+ private
+
+ def git_branch
+ `git branch --no-color --show-current --no-abbrev`.strip
+ end
+ end
+ end
+end
lib/elelem/agent.rb
@@ -11,7 +11,7 @@ module Elelem
@model = configuration.model
@conversation = configuration.conversation
@logger = configuration.logger
- transition_to(Idle.new)
+ transition_to(States::Idle.new)
end
def repl
lib/elelem/state.rb
@@ -1,24 +1,6 @@
# frozen_string_literal: true
module Elelem
- class Idle
- def run(agent)
- agent.logger.debug("Idling...")
- agent.tui.say("#{Dir.pwd} (#{agent.model}) [#{git_branch}]", colour: :magenta, newline: true)
- input = agent.tui.prompt("モ ")
- agent.quit if input.nil? || input.empty? || input == "exit" || input == "quit"
-
- agent.conversation.add(role: :user, content: input)
- agent.transition_to(Working.new)
- end
-
- private
-
- def git_branch
- `git branch --no-color --show-current --no-abbrev`.strip
- end
- end
-
class Working
class State
attr_reader :agent
@@ -122,7 +104,7 @@ module Elelem
break if done && agent.conversation.history.last[:role] != :tool
end
- agent.transition_to(Idle.new)
+ agent.transition_to(States::Idle.new)
end
private
lib/elelem.rb
@@ -17,6 +17,7 @@ require_relative "elelem/configuration"
require_relative "elelem/conversation"
require_relative "elelem/mcp_client"
require_relative "elelem/state"
+require_relative "elelem/states/idle"
require_relative "elelem/tool"
require_relative "elelem/toolbox/bash"
require_relative "elelem/toolbox/mcp"
elelem.gemspec
@@ -41,6 +41,7 @@ Gem::Specification.new do |spec|
"lib/elelem/conversation.rb",
"lib/elelem/mcp_client.rb",
"lib/elelem/state.rb",
+ "lib/elelem/states/idle.rb",
"lib/elelem/system_prompt.erb",
"lib/elelem/tool.rb",
"lib/elelem/toolbox/bash.rb",