Commit 6784324

mo khan <mo@mokhan.ca>
2026-09-07 00:17:16
fix: add missing Verifiers class
1 parent 99a0bcc
Changed files (2)
lib
lib/elelem/tools/verify.rb
@@ -1,13 +1,39 @@
 # frozen_string_literal: true
 
 Elelem::Plugins.register(:verify) do |agent|
+  class Verifiers
+    SYNTAX = {
+      ".rb" => "ruby -c %{path}",
+      ".erb" => "erb -x %{path} | ruby -c",
+      ".py" => "python -m py_compile %{path}",
+      ".go" => "go vet %{path}",
+      ".rs" => "cargo check --quiet",
+      ".ts" => "npx tsc --noEmit %{path}",
+      ".js" => "node --check %{path}",
+    }.freeze
+
+    def self.for(path)
+      return [] unless path
+
+      cmds = []
+      ext = File.extname(path)
+      cmds << (SYNTAX[ext] % { path: path }) if SYNTAX[ext]
+      cmds << test_runner
+      cmds.compact
+    end
+
+    def self.test_runner
+      %w[bin/test script/test].find { |s| File.executable?(s) }
+    end
+  end
+
   agent.toolbox.add("verify",
     description: "Verify file syntax and run tests",
     params: { path: { type: "string" } },
     required: ["path"]
   ) do |args|
     path = args["path"]
-    Elelem::Plugins::Verifiers.for(path).inject({ verified: [] }) do |memo, cmd|
+    Verifiers.for(path).inject({ verified: [] }) do |memo, cmd|
       agent.terminal.say agent.toolbox.header("execute", { "command" => cmd })
       v = agent.toolbox.run("execute", { "command" => cmd })
       break v.merge(path: path, command: cmd) if v[:exit_status] != 0
lib/elelem/tools/version.rb
@@ -2,6 +2,6 @@
 
 module Elelem
   module Tools
-    VERSION = "0.1.0"
+    VERSION = "0.1.1"
   end
 end