Commit 203c8c7
Changed files (3)
lib
elelem
lib/elelem/agent.rb
@@ -2,7 +2,7 @@
module Elelem
class Agent
- COMMANDS = %w[/clear /context /init /shell /exit /help].freeze
+ COMMANDS = %w[/clear /context /init /reload /shell /exit /help].freeze
MAX_CONTEXT_MESSAGES = 50
INIT_PROMPT = <<~PROMPT
AGENTS.md generator. Analyze codebase and write AGENTS.md to project root.
@@ -52,6 +52,7 @@ module Elelem
case input
when "/exit" then exit(0)
when "/init" then init_agents_md
+ when "/reload" then reload_source!
when "/shell"
transcript = start_shell
history << { role: "user", content: transcript } unless transcript.strip.empty?
@@ -114,6 +115,16 @@ module Elelem
sub.turn("Generate AGENTS.md for this project")
end
+ def reload_source!
+ lib_dir = File.expand_path("..", __dir__)
+ original_verbose, $VERBOSE = $VERBOSE, nil
+ Dir["#{lib_dir}/**/*.rb"].sort.each { |f| load(f) }
+ $VERBOSE = original_verbose
+ @toolbox = Toolbox.new
+ Plugins.reload!(@toolbox)
+ register_task_tool
+ end
+
def start_shell
Tempfile.create do |file|
system("script", "-q", file.path, chdir: Dir.pwd)
lib/elelem/plugins.rb
@@ -9,6 +9,17 @@ module Elelem
].freeze
def self.setup!(toolbox)
+ load_plugins
+ registry.each_value { |plugin| plugin.call(toolbox) }
+ end
+
+ def self.reload!(toolbox)
+ @registry = {}
+ load_plugins
+ registry.each_value { |plugin| plugin.call(toolbox) }
+ end
+
+ def self.load_plugins
LOAD_PATHS.each do |path|
dir = File.expand_path(path)
next unless File.directory?(dir)
@@ -19,7 +30,6 @@ module Elelem
warn "elelem: failed to load plugin #{file}: #{e.message}"
end
end
- registry.each_value { |plugin| plugin.call(toolbox) }
end
def self.register(name, &block)
CHANGELOG.md
@@ -9,6 +9,7 @@
- **AGENTS.md** file support - searches up directory tree for project instructions
- **`/init` command** to generate an AGENTS.md file for the current project
- **`/shell` command** to drop into a shell session and capture the transcript to context
+- **`/reload` command** to hot-reload source code without restarting the process
- **`task` tool** for delegating subtasks to focused sub-agents
- **`edit` tool** for replacing first occurrence of text in a file
- **`eval` tool** for executing Ruby code and dynamically registering new tools
@@ -39,7 +40,7 @@
- **Breaking**: Tool definitions use `description:` key (was `desc:`)
- **Breaking**: Removed modes and permissions system entirely
- **Breaking**: Removed slash commands (`/mode`, `/env`, `/provider`, `/model`)
- - Remaining: `/clear`, `/context`, `/init`, `/shell`, `/exit`, `/help`
+ - Remaining: `/clear`, `/context`, `/init`, `/reload`, `/shell`, `/exit`, `/help`
- **Breaking**: Removed many dependencies
- Removed: `thor`, `cli-ui`, `erb`, `cgi`, `set`, `timeout`, `logger`, `net-llm`, `json-schema`
- Added: `json_schemer`, `optparse`, `tempfile`, `stringio`, `uri`