Commit 7fc5935

mo khan <mo@mokhan.ca>
2025-11-14 18:20:28
feat: add files subcommand to produce Claude XML
1 parent 47b033b
Changed files (1)
lib
lib/elelem/application.rb
@@ -13,7 +13,6 @@ module Elelem
                   type: :string,
                   desc: "Ollama model",
                   default: ENV.fetch("OLLAMA_MODEL", "gpt-oss")
-
     def chat(*)
       client = Net::Llm::Ollama.new(
         host: options[:host],
@@ -24,6 +23,20 @@ module Elelem
       agent.repl
     end
 
+    desc "files", "Generate CXML of the files"
+    def files
+      puts '<documents>'
+      $stdin.read.split("\n").map(&:strip).reject(&:empty?).each_with_index do |file, i|
+        next unless File.file?(file)
+
+        puts "  <document index=\"#{i + 1}\">"
+        puts "    <source><![CDATA[#{file}]]></source>"
+        puts "    <document_content><![CDATA[#{File.read(file)}]]></document_content>"
+        puts "  </document>"
+      end
+      puts '</documents>'
+    end
+
     desc "version", "The version of this CLI"
     def version
       say "v#{Elelem::VERSION}"