Module: Brute::Prompts
- Defined in:
- lib/brute/prompts.rb,
lib/brute/prompts/base.rb,
lib/brute/prompts/skills.rb,
lib/brute/prompts/autonomy.rb,
lib/brute/prompts/identity.rb,
lib/brute/prompts/max_steps.rb,
lib/brute/prompts/code_style.rb,
lib/brute/prompts/git_safety.rb,
lib/brute/prompts/tool_usage.rb,
lib/brute/prompts/conventions.rb,
lib/brute/prompts/doing_tasks.rb,
lib/brute/prompts/environment.rb,
lib/brute/prompts/objectivity.rb,
lib/brute/prompts/build_switch.rb,
lib/brute/prompts/instructions.rb,
lib/brute/prompts/plan_reminder.rb,
lib/brute/prompts/proactiveness.rb,
lib/brute/prompts/frontend_tasks.rb,
lib/brute/prompts/tone_and_style.rb,
lib/brute/prompts/code_references.rb,
lib/brute/prompts/task_management.rb,
lib/brute/prompts/editing_approach.rb,
lib/brute/prompts/editing_constraints.rb,
lib/brute/prompts/security_and_safety.rb
Defined Under Namespace
Modules: Autonomy, BuildSwitch, CodeReferences, CodeStyle, Conventions, DoingTasks, EditingApproach, EditingConstraints, Environment, FrontendTasks, GitSafety, Identity, Instructions, MaxSteps, Objectivity, PlanReminder, Proactiveness, SecurityAndSafety, Skills, TaskManagement, ToneAndStyle, ToolUsage Classes: Context
Constant Summary collapse
- TEXT_DIR =
File.("text", __dir__)
- TEMPLATES =
Compiled templates, keyed by absolute path. Compilation is idempotent, so a racy double-assign under Async is harmless.
{}
Class Method Summary collapse
-
.agent_prompt(name) ⇒ Object
Read a named agent prompt (e.g. "explore", "compaction").
-
.read(section, provider_name) ⇒ Object
Resolve a provider-specific text file.
-
.render(section, ctx) ⇒ Object
Resolve and render text/
/ .erb, falling back to default.erb, then to the legacy plain .txt files.
Class Method Details
.agent_prompt(name) ⇒ Object
Read a named agent prompt (e.g. "explore", "compaction").
23 24 25 26 |
# File 'lib/brute/prompts/base.rb', line 23 def self.agent_prompt(name) path = File.join(TEXT_DIR, "agents", "#{name}.txt") File.exist?(path) ? File.read(path) : nil end |
.read(section, provider_name) ⇒ Object
Resolve a provider-specific text file.
Looks for section/provider_name.txt, falls back to section/default.txt.
14 15 16 17 18 19 20 |
# File 'lib/brute/prompts/base.rb', line 14 def self.read(section, provider_name) provider = provider_name.to_s path = File.join(TEXT_DIR, section, "#{provider}.txt") path = File.join(TEXT_DIR, section, "default.txt") unless File.exist?(path) return nil unless File.exist?(path) File.read(path) end |
.render(section, ctx) ⇒ Object
Resolve and render text/
Templates are ERB: arbitrary Ruby. Only ship templates with the gem or load them from paths you trust.
67 68 69 70 71 72 73 74 75 76 |
# File 'lib/brute/prompts/base.rb', line 67 def self.render(section, ctx) provider = ctx[:provider_name].to_s path = [provider, "default"] .map { |variant| File.join(TEXT_DIR, section, "#{variant}.erb") } .find { |candidate| File.exist?(candidate) } return read(section, provider) unless path erb = TEMPLATES[path] ||= ERB.new(File.read(path), trim_mode: "-") erb.result(Context.new(ctx).get_binding) end |