Commit 6aa8722

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 3e75126
Changed files (3)
lib/elelem/tools/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/tools/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/tools/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