Commit 8dc33be

mo khan <mo@mokhan.ca>
2026-01-27 23:45:21
fix: pretty print MCP response data
1 parent 240d8e7
Changed files (5)
.elelem/plugins/gitlab.rb
@@ -2,6 +2,10 @@
 
 Elelem::Plugins.register(:gitlab) do |agent|
   agent.toolbox.after("gitlab_search") do |_args, result|
-    agent.terminal.say(agent.terminal.markdown(result))
+    IO.popen(["jq", "-C", "."], "r+") do |io|
+      io.write(result.to_json)
+      io.close_write
+      agent.terminal.say(io.read)
+    end
   end
 end
lib/elelem/mcp.rb
@@ -4,6 +4,7 @@ require_relative "mcp/token_storage"
 require_relative "mcp/oauth"
 
 module Elelem
+  # https://modelcontextprotocol.io/specification/2025-11-25/server/tools.md
   class MCP
     CONFIG_PATHS = [
       "~/.elelem/mcp.json",
@@ -74,7 +75,7 @@ module Elelem
 
       def extract_content(result)
         if (structured = result["structuredContent"])
-          JSON.pretty_generate(structured)
+          structured
         else
           result["content"]&.map { |c| c["text"] }&.join("\n")
         end
lib/elelem/terminal.rb
@@ -72,7 +72,7 @@ module Elelem
     private
 
     def blank?(text)
-      text.nil? || text.strip.empty?
+      text.nil? || text.to_s.strip.empty?
     end
 
     def stop_dots
Rakefile
@@ -5,15 +5,4 @@ require "rspec/core/rake_task"
 
 RSpec::Core::RakeTask.new(:spec)
 
-task :files do
-  IO.popen(%w[git ls-files], chdir: __dir__, err: IO::NULL) do |ls|
-    ls.readlines.each do |f|
-      next if f.start_with?(*%w[bin/ spec/ pkg/ .git .rspec Gemfile Rakefile])
-      next if f.strip.end_with?(*%w[.toml .txt .md])
-
-      puts f
-    end
-  end
-end
-
 task default: %i[spec]
README.md
@@ -36,12 +36,13 @@ Elelem relies on several external tools. Install the ones you need:
 | [fd](https://github.com/sharkdp/fd) | File discovery | `brew install fd` / `apt install fd-find` |
 | [git](https://git-scm.com/) | Version control | `brew install git` / `apt install git` |
 | [glow](https://github.com/charmbracelet/glow) | Markdown rendering | `brew install glow` / `go install github.com/charmbracelet/glow@latest` |
+| [jq](https://jqlang.github.io/jq/) | JSON processing | `brew install jq` / `apt install jq` |
 | [ollama](https://ollama.ai/) | Default LLM provider | https://ollama.ai/download |
 | [ripgrep](https://github.com/BurntSushi/ripgrep) | Text search (`rg`) | `brew install ripgrep` / `apt install ripgrep` |
 
 **Required:** Git, Ollama (or another LLM provider)
 
-**Recommended:** glow, ctags, ripgrep, fd
+**Recommended:** glow, jq, ctags, ripgrep, fd
 
 **Optional:** ast-grep (for structural code search)