Commit 95c5d03

mo khan <mo@mokhan.ca>
2026-01-29 23:10:52
refactor: demote plugins to project local until they are mature enough to be promoted to the gem
1 parent b5a85dd
.elelem/plugins/compact.rb
@@ -0,0 +1,10 @@
+# frozen_string_literal: true
+
+Elelem::Plugins.register(:compact) do |agent|
+  agent.commands.register("compact", description: "Compress context") do
+    response = agent.turn("Summarize: accomplishments, state, next steps. Brief.")
+    agent.conversation.clear!
+    agent.conversation.add(role: "user", content: "Context: #{response}")
+    agent.terminal.say "  → compacted"
+  end
+end
lib/elelem/plugins/eval.rb → .elelem/plugins/eval.rb
File renamed without changes
lib/elelem/plugins/git.rb → .elelem/plugins/git.rb
File renamed without changes
lib/elelem/plugins/glob.rb → .elelem/plugins/glob.rb
File renamed without changes
lib/elelem/plugins/grep.rb → .elelem/plugins/grep.rb
File renamed without changes
.elelem/plugins/init.rb
@@ -0,0 +1,29 @@
+# frozen_string_literal: true
+
+Elelem::Plugins.register(:init) do |agent|
+  agent.commands.register("init", description: "Generate AGENTS.md") do
+    system_prompt = <<~PROMPT
+      AGENTS.md generator. Analyze codebase and write AGENTS.md to project root.
+
+      # AGENTS.md Spec (https://agents.md/)
+      A file providing context and instructions for AI coding agents.
+
+      ## Recommended Sections
+      - Commands: build, test, lint commands
+      - Code Style: conventions, patterns
+      - Architecture: key components and flow
+      - Testing: how to run tests
+
+      ## Process
+      1. Read README.md if present
+      2. Identify language (Gemfile, package.json, go.mod)
+      3. Find test scripts (bin/test, npm test)
+      4. Check linter configs
+      5. Write concise AGENTS.md
+
+      Keep it minimal. No fluff.
+    PROMPT
+
+    agent.fork(system_prompt: system_prompt).turn("Generate AGENTS.md for this project")
+  end
+end
lib/elelem/plugins/interview.rb → .elelem/plugins/interview.rb
File renamed without changes
lib/elelem/plugins/list.rb → .elelem/plugins/list.rb
File renamed without changes
lib/elelem/plugins/mode.rb → .elelem/plugins/mode.rb
@@ -15,11 +15,4 @@ Elelem::Plugins.register(:mode) do |agent|
       agent.terminal.say "mode: #{name}"
     end
   end
-
-  agent.commands.register("compact", description: "Compress context") do
-    response = agent.turn("Summarize: accomplishments, state, next steps. Brief.")
-    agent.conversation.clear!
-    agent.conversation.add(role: "user", content: "Context: #{response}")
-    agent.terminal.say "  → compacted"
-  end
 end
.elelem/plugins/reload.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+Elelem::Plugins.register(:reload) do |agent|
+  agent.commands.register("reload", description: "Reload plugins and source") do
+    lib_dir = File.join(Dir.pwd, "lib")
+    original_verbose, $VERBOSE = $VERBOSE, nil
+    Dir["#{lib_dir}/**/*.rb"].sort.each { |f| load(f) }
+    $VERBOSE = original_verbose
+    agent.toolbox = Elelem::Toolbox.new
+    agent.commands = Elelem::Commands.new
+    Elelem::Plugins.reload!(agent)
+  end
+end
.elelem/plugins/shell.rb
@@ -0,0 +1,23 @@
+# frozen_string_literal: true
+
+Elelem::Plugins.register(:shell) do |agent|
+  strip_ansi = ->(text) do
+    text
+      .gsub(/^Script started.*?\n/, "")
+      .gsub(/\nScript done.*$/, "")
+      .gsub(/\e\].*?(?:\a|\e\\)/, "")
+      .gsub(/\e\[[0-9;?]*[A-Za-z]/, "")
+      .gsub(/\e[PX^_].*?\e\\/, "")
+      .gsub(/\e./, "")
+      .gsub(/[\b]/, "")
+      .gsub(/\r/, "")
+  end
+
+  agent.commands.register("shell", description: "Start interactive shell") do
+    transcript = Tempfile.create do |file|
+      system("script", "-q", file.path, chdir: Dir.pwd)
+      strip_ansi.call(File.read(file.path))
+    end
+    agent.conversation.add(role: "user", content: transcript) unless transcript.strip.empty?
+  end
+end
lib/elelem/plugins/task.rb → .elelem/plugins/task.rb
File renamed without changes
lib/elelem/plugins/verify.rb → .elelem/plugins/verify.rb
File renamed without changes
lib/elelem/plugins/builtins.rb
@@ -8,88 +8,6 @@ Elelem::Plugins.register(:builtins) do |agent|
     agent.terminal.say "  → context cleared"
   end
 
-  agent.commands.register("context", description: "Show conversation context") do |args|
-    messages = agent.context
-
-    case args
-    when nil, ""
-      messages.each_with_index do |msg, i|
-        role = msg[:role]
-        preview = msg[:content].to_s.lines.first&.strip&.slice(0, 60) || ""
-        preview += "..." if msg[:content].to_s.length > 60
-        agent.terminal.say "  #{i + 1}. #{role}: #{preview}"
-      end
-    when "json"
-      agent.terminal.say JSON.pretty_generate(messages)
-    when /^\d+$/
-      index = args.to_i - 1
-      if index >= 0 && index < messages.length
-        content = messages[index][:content].to_s
-        agent.terminal.say(agent.terminal.markdown(content))
-      else
-        agent.terminal.say "  Invalid index: #{args}"
-      end
-    else
-      agent.terminal.say "  Usage: /context [json|<number>]"
-    end
-  end
-
-  strip_ansi = ->(text) do
-    text
-      .gsub(/^Script started.*?\n/, "")
-      .gsub(/\nScript done.*$/, "")
-      .gsub(/\e\].*?(?:\a|\e\\)/, "")
-      .gsub(/\e\[[0-9;?]*[A-Za-z]/, "")
-      .gsub(/\e[PX^_].*?\e\\/, "")
-      .gsub(/\e./, "")
-      .gsub(/[\b]/, "")
-      .gsub(/\r/, "")
-  end
-
-  agent.commands.register("shell", description: "Start interactive shell") do
-    transcript = Tempfile.create do |file|
-      system("script", "-q", file.path, chdir: Dir.pwd)
-      strip_ansi.call(File.read(file.path))
-    end
-    agent.conversation.add(role: "user", content: transcript) unless transcript.strip.empty?
-  end
-
-  agent.commands.register("init", description: "Generate AGENTS.md") do
-    system_prompt = <<~PROMPT
-      AGENTS.md generator. Analyze codebase and write AGENTS.md to project root.
-
-      # AGENTS.md Spec (https://agents.md/)
-      A file providing context and instructions for AI coding agents.
-
-      ## Recommended Sections
-      - Commands: build, test, lint commands
-      - Code Style: conventions, patterns
-      - Architecture: key components and flow
-      - Testing: how to run tests
-
-      ## Process
-      1. Read README.md if present
-      2. Identify language (Gemfile, package.json, go.mod)
-      3. Find test scripts (bin/test, npm test)
-      4. Check linter configs
-      5. Write concise AGENTS.md
-
-      Keep it minimal. No fluff.
-    PROMPT
-
-    agent.fork(system_prompt: system_prompt).turn("Generate AGENTS.md for this project")
-  end
-
-  agent.commands.register("reload", description: "Reload plugins and source") do
-    lib_dir = File.expand_path("../..", __dir__)
-    original_verbose, $VERBOSE = $VERBOSE, nil
-    Dir["#{lib_dir}/**/*.rb"].sort.each { |f| load(f) }
-    $VERBOSE = original_verbose
-    agent.toolbox = Elelem::Toolbox.new
-    agent.commands = Elelem::Commands.new
-    Elelem::Plugins.reload!(agent)
-  end
-
   agent.commands.register("help", description: "Show available commands") do
     agent.terminal.say agent.commands.names.join(" ")
   end
lib/elelem/plugins/context.rb
@@ -0,0 +1,29 @@
+# frozen_string_literal: true
+
+Elelem::Plugins.register(:context) do |agent|
+  agent.commands.register("context", description: "Show conversation context") do |args|
+    messages = agent.context
+
+    case args
+    when nil, ""
+      messages.each_with_index do |msg, i|
+        role = msg[:role]
+        preview = msg[:content].to_s.lines.first&.strip&.slice(0, 60) || ""
+        preview += "..." if msg[:content].to_s.length > 60
+        agent.terminal.say "  #{i + 1}. #{role}: #{preview}"
+      end
+    when "json"
+      agent.terminal.say JSON.pretty_generate(messages)
+    when /^\d+$/
+      index = args.to_i - 1
+      if index >= 0 && index < messages.length
+        content = messages[index][:content].to_s
+        agent.terminal.say(agent.terminal.markdown(content))
+      else
+        agent.terminal.say "  Invalid index: #{args}"
+      end
+    else
+      agent.terminal.say "  Usage: /context [json|<number>]"
+    end
+  end
+end