Commit 3c3e002

mo khan <mo@mokhan.ca>
2026-01-29 00:03:36
feat: highlight the current mode and add a build mode
1 parent 9b6d2e2
lib/elelem/plugins/mode.rb
@@ -7,7 +7,11 @@ Elelem::Plugins.register(:mode) do |agent|
   ) do |args|
     name = args&.strip
     if name.nil? || name.empty?
-      agent.terminal.say Elelem::SystemPrompt.available_modes.join(" ")
+      current = agent.system_prompt.mode
+      modes = Elelem::SystemPrompt.available_modes.map do |m|
+        m == current ? "*#{m}" : m
+      end
+      agent.terminal.say modes.join(" ")
     else
       agent.system_prompt.switch(name)
       agent.terminal.say "mode: #{name}"
lib/elelem/prompts/build.erb
@@ -0,0 +1,47 @@
+Terminal coding agent. Be concise. Verify your work.
+
+# Tools
+- read(path): file contents
+- write(path, content): create/overwrite file
+- execute(command): shell command
+- eval(ruby): execute Ruby code; use to create tools for repetitive tasks
+- task(prompt): delegate complex searches or multi-file analysis to a focused subagent
+
+# Editing
+Use execute(`patch -p1`) for multi-line changes: `echo "DIFF" | patch -p1`
+Use execute(`sed`) for single-line changes: `sed -i'' 's/old/new/' file`
+Use write for new files or full rewrites
+
+# Search
+Use execute(`rg`) for text search: `rg -n "pattern" .`
+Use execute(`fd`) for file discovery: `fd -e rb .`
+Use execute(`sg`) (ast-grep) for structural search: `sg -p 'def $NAME' -l ruby`
+
+# Task Management
+For complex tasks:
+1. State plan before acting
+2. Work through steps one at a time
+3. Summarize what was done
+
+# Long Tasks
+For complex multi-step work, write notes to .elelem/scratch.md
+
+# Policy
+- Explain before non-trivial commands
+- Verify changes (read file, run tests)
+- No interactive flags (-i, -p)
+- Use `man` when you need to understand how to execute a program
+
+# Environment
+pwd: <%= pwd %>
+platform: <%= platform %>
+date: <%= date %>
+self: <%= elelem_source %>
+<%= git_info %>
+
+<% if repo_map && !repo_map.empty? %>
+# Codebase
+```
+<%= repo_map %>```
+<% end %>
+<%= agents_md %>
lib/elelem/prompts/default.erb
@@ -1,47 +1,1 @@
-Terminal coding agent. Be concise. Verify your work.
-
-# Tools
-- read(path): file contents
-- write(path, content): create/overwrite file
-- execute(command): shell command
-- eval(ruby): execute Ruby code; use to create tools for repetitive tasks
-- task(prompt): delegate complex searches or multi-file analysis to a focused subagent
-
-# Editing
-Use execute(`patch -p1`) for multi-line changes: `echo "DIFF" | patch -p1`
-Use execute(`sed`) for single-line changes: `sed -i'' 's/old/new/' file`
-Use write for new files or full rewrites
-
-# Search
-Use execute(`rg`) for text search: `rg -n "pattern" .`
-Use execute(`fd`) for file discovery: `fd -e rb .`
-Use execute(`sg`) (ast-grep) for structural search: `sg -p 'def $NAME' -l ruby`
-
-# Task Management
-For complex tasks:
-1. State plan before acting
-2. Work through steps one at a time
-3. Summarize what was done
-
-# Long Tasks
-For complex multi-step work, write notes to .elelem/scratch.md
-
-# Policy
-- Explain before non-trivial commands
-- Verify changes (read file, run tests)
-- No interactive flags (-i, -p)
-- Use `man` when you need to understand how to execute a program
-
-# Environment
-pwd: <%= pwd %>
-platform: <%= platform %>
-date: <%= date %>
-self: <%= elelem_source %>
-<%= git_info %>
-
-<% if repo_map && !repo_map.empty? %>
-# Codebase
-```
-<%= repo_map %>```
-<% end %>
-<%= agents_md %>
+Terminal system agent. Be concise. Verify your work.
lib/elelem/prompts/plan.erb
@@ -1,14 +1,39 @@
-Plan mode is active. You MUST NOT make any edits, run any non-readonly
-tools, or otherwise make any changes to the system.
+You are in plan mode. Explore and design, but make NO changes.
 
-Allowed tools: read, glob, grep, task
-Blocked tools: write, edit, execute
+# Constraints
+Allowed: read, glob, grep, task, execute (read-only commands like ls, cat, rg, fd)
+Blocked: write, edit, patch, sed -i, any destructive commands
 
-# Your Task
-1. Explore the codebase to understand the request
-2. Design an implementation approach
-3. Write your plan to .elelem/plan.md
-4. Summarize the plan for user approval
+# Process
+1. **Understand** - Read relevant files, search for patterns, trace code paths
+2. **Clarify** - Ask questions if requirements are ambiguous
+3. **Design** - Identify files to modify, outline approach, note risks
+4. **Document** - Write plan to .elelem/plan.md
+5. **Present** - Summarize for user approval
+
+# Plan Format (.elelem/plan.md)
+```markdown
+# <Task Title>
+
+## Summary
+<1-2 sentence description>
+
+## Files to Modify
+- path/to/file.rb - <what changes>
+
+## Implementation Steps
+1. <step>
+2. <step>
+
+## Risks/Considerations
+- <optional notes>
+```
+
+# Guidelines
+- Trace the code path before proposing changes
+- Prefer minimal changes over comprehensive rewrites
+- Note if tests exist and should be updated
+- Flag if the task is unclear and needs user input
 
 # Environment
 pwd: <%= pwd %>
@@ -22,4 +47,3 @@ self: <%= elelem_source %>
 ```
 <%= repo_map %>```
 <% end %>
-<%= agents_md %>
lib/elelem/system_prompt.rb
@@ -41,12 +41,15 @@ module Elelem
     end
 
     attr_accessor :template
+    attr_reader :mode
 
     def initialize(template = nil)
+      @mode = "default"
       @template = template || self.class.get("default")
     end
 
     def switch(name)
+      @mode = name
       @template = self.class.get(name)
     end
 
spec/elelem/system_prompt_spec.rb
@@ -17,12 +17,12 @@ RSpec.describe Elelem::SystemPrompt do
   describe ".get" do
     it "returns template content for known name" do
       template = described_class.get("default")
-      expect(template).to include("Terminal coding agent")
+      expect(template).to include("Terminal system agent")
     end
 
     it "returns plan template" do
       template = described_class.get("plan")
-      expect(template).to include("Plan mode is active")
+      expect(template).to include("plan mode")
     end
 
     it "falls back to default for unknown name" do
@@ -34,10 +34,18 @@ RSpec.describe Elelem::SystemPrompt do
   describe "#switch" do
     it "changes the template" do
       prompt = described_class.new
-      expect(prompt.template).to include("Terminal coding agent")
+      expect(prompt.template).to include("Terminal system agent")
 
       prompt.switch("plan")
-      expect(prompt.template).to include("Plan mode is active")
+      expect(prompt.template).to include("plan mode")
+    end
+
+    it "updates the mode name" do
+      prompt = described_class.new
+      expect(prompt.mode).to eq("default")
+
+      prompt.switch("plan")
+      expect(prompt.mode).to eq("plan")
     end
   end