Commit a061feb

mo khan <mo@mokhan.ca>
2026-01-19 23:00:10
refactor: use ctags based repo map
1 parent 1403f22
Changed files (1)
lib
elelem
lib/elelem/agent.rb
@@ -157,26 +157,13 @@ module Elelem
     end
 
     def repo_map
-      exts = %w[.rb .js .ts .py .go .rs]
-      patterns = {
-        ".rb" => /^\s*(class |module |def )/,
-        ".js" => /^\s*(function |class |const \w+ = (?:async )?\(|export )/,
-        ".ts" => /^\s*(function |class |const |export |interface )/,
-        ".py" => /^\s*(class |def |async def )/,
-        ".go" => /^\s*(func |type )/,
-        ".rs" => /^\s*(fn |struct |impl |pub fn )/
-      }
-
-      Dir.glob("**/*.{rb,js,ts,py,go,rs}").reject { |f| f.start_with?("vendor/", "node_modules/") }
-        .flat_map do |path|
-          pattern = patterns[File.extname(path)]
-          next [] unless pattern
-          File.readlines(path).filter_map.with_index do |line, i|
-            "#{path}:#{i + 1}: #{line.strip}" if line.match?(pattern)
-          end
-        rescue
-          []
-        end.first(100).join("\n")
+      `ctags -x --sort=no --languages=Ruby,Python,JavaScript,TypeScript,Go,Rust -R . 2>/dev/null`
+        .lines
+        .reject { |l| l.include?("vendor/") || l.include?("node_modules/") || l.include?("spec/") }
+        .first(100)
+        .join
+    rescue
+      ""
     end
   end
 end