Commit f5e76ea

mo khan <mo@mokhan.ca>
2026-01-20 23:18:55
feat: add confirm plugin to run before execute tool
1 parent fd861c6
Changed files (2)
lib/elelem/plugins/confirm.rb
@@ -0,0 +1,12 @@
+# frozen_string_literal: true
+
+Elelem::Plugins.register(:confirm) do |toolbox|
+  toolbox.before("execute") do |args|
+    next unless $stdin.tty?
+
+    cmd = args["command"]
+    $stdout.print "  Allow? [Y/n] > "
+    answer = $stdin.gets&.strip&.downcase
+    raise "User denied permission to execute: #{cmd}" if answer == "n"
+  end
+end
elelem.gemspec
@@ -33,6 +33,7 @@ Gem::Specification.new do |spec|
     "lib/elelem/net/ollama.rb",
     "lib/elelem/net/openai.rb",
     "lib/elelem/plugins.rb",
+    "lib/elelem/plugins/confirm.rb",
     "lib/elelem/plugins/verify.rb",
     "lib/elelem/terminal.rb",
     "lib/elelem/toolbox.rb",