Module: Clacky::Agent::SystemPromptBuilder
- Included in:
- Clacky::Agent
- Defined in:
- lib/clacky/agent/system_prompt_builder.rb
Overview
System prompt construction Builds system prompt by composing layers:
1. Agent-specific system_prompt.md (role & responsibilities)
2. base_prompt.md (universal rules: todo manager, tool usage, etc.)
3. Project rules (.clackyrules / .cursorrules / CLAUDE.md)
4. SOUL.md (agent personality — user override or built-in default)
5. USER.md (user profile — user override or built-in default)
6. Skills context (available skills list)
Constant Summary collapse
- MAX_MEMORY_FILE_CHARS =
Max characters loaded from each agent file (SOUL.md / USER.md)
1000
Instance Method Summary collapse
-
#build_system_prompt ⇒ String
Build complete system prompt with project rules and skills.
Instance Method Details
#build_system_prompt ⇒ String
Build complete system prompt with project rules and skills
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/clacky/agent/system_prompt_builder.rb', line 21 def build_system_prompt parts = [] # Layer 1: agent-specific role & responsibilities parts << @agent_profile.system_prompt # Layer 2: universal behavioral rules (todo manager, tool usage, etc.) base = @agent_profile.base_prompt parts << base unless base.empty? # Layer 3: project-specific rules from working directory project_rules = load_project_rules if project_rules parts << format_section("PROJECT-SPECIFIC RULES (from #{project_rules[:source]})", project_rules[:content], footer: "IMPORTANT: Follow these project-specific rules at all times!") end # Layer 4 & 5: SOUL.md and USER.md (with built-in defaults as fallback) soul = truncate(@agent_profile.soul, MAX_MEMORY_FILE_CHARS) parts << format_section("AGENT SOUL (from ~/.clacky/agents/SOUL.md)", soul) unless soul.empty? user_profile = truncate(@agent_profile.user_profile, MAX_MEMORY_FILE_CHARS) parts << format_section("USER PROFILE (from ~/.clacky/agents/USER.md)", user_profile) unless user_profile.empty? # Layer 6: skills context skill_context = build_skill_context parts << skill_context if skill_context && !skill_context.empty? parts.join("\n\n") end |