Commit 131253b

mo khan <mo@mokhan.ca>
2026-01-21 19:53:44
refactor: small code changes
1 parent 00db2f1
Changed files (4)
lib/elelem/plugins/mcp.rb
@@ -2,13 +2,13 @@
 
 Elelem::Plugins.register(:mcp) do |toolbox|
   mcp = Elelem::MCP.new
+  at_exit { mcp.close }
   mcp.tools.each do |name, tool|
-    fn = tool[:fn]
     toolbox.add(name,
       description: tool[:description],
       params: tool[:params],
       required: tool[:required],
-      &fn
+      &tool[:fn]
     )
   end
 end
lib/elelem/plugins/read.rb
@@ -14,8 +14,8 @@ Elelem::Plugins.register(:read) do |toolbox|
   toolbox.after("read") do |_, result|
     if result[:error]
       $stdout.puts "  ! #{result[:error]}"
-    else
-      system("bat", "--style=plain", "--paging=never", result[:path])
+    elsif !system("bat", "--style=plain", "--paging=never", result[:path])
+      $stdout.puts result[:content]
     end
   end
 end
lib/elelem/plugins/verify.rb
@@ -33,7 +33,7 @@ module Elelem
       Verifiers.for(result[:path]).each do |cmd|
         $stdout.puts "\n  -> verify: #{cmd}"
         v = Elelem.sh("bash", args: ["-c", cmd]) { |x| $stdout.print(x) }
-        status = v[:exit_status] == 0 ? "\u2713" : "\u2717"
+        status = v[:exit_status] == 0 ? "ok" : "FAIL"
         $stdout.puts "  #{status} #{cmd}"
         if v[:exit_status] != 0
           $stdout.puts v[:content].lines.first(5).map { |l| "    #{l}" }.join
lib/elelem/agent.rb
@@ -71,13 +71,12 @@ module Elelem
     end
 
     def register_task_tool
-      agent = self
       @toolbox.add("task",
         description: "Delegate subtask to focused agent (complex searches, multi-file analysis)",
         params: { prompt: { type: "string" } },
         required: ["prompt"]
       ) do |a|
-        sub = Agent.new(agent.client, agent.toolbox, terminal: agent.terminal, history: [
+        sub = Agent.new(client, toolbox, terminal: terminal, history: [
           { role: "system", content: "Research agent. Search, analyze, report. Be concise." }
         ])
         sub.turn(a["prompt"])