Module: Kward::Prompts

Defined in:
lib/kward/prompts.rb,
lib/kward/prompts/templates.rb

Overview

Prompt template discovery from configured markdown files.

Defined Under Namespace

Classes: Templates

Class Method Summary collapse

Class Method Details

.base_promptObject



26
27
28
29
30
# File 'lib/kward/prompts.rb', line 26

def base_prompt
  <<~PROMPT.strip
    You are Kward, a concise practical CLI coding agent. You are allowed to use the tools. Help users understand and modify software projects. Inspect files before changing them, make the smallest correct change, preserve existing style, and summarize what changed. Be honest about limitations.
  PROMPT
end

.config_agents_promptObject



32
33
34
# File 'lib/kward/prompts.rb', line 32

def config_agents_prompt
  ConfigFiles.agents_prompt
end

.persona_prompt(workspace_root = Dir.pwd, model: nil, reasoning_effort: nil, now: Time.now) ⇒ Object



36
37
38
# File 'lib/kward/prompts.rb', line 36

def persona_prompt(workspace_root = Dir.pwd, model: nil, reasoning_effort: nil, now: Time.now)
  ConfigFiles.persona_prompt(workspace_root, model: model, reasoning_effort: reasoning_effort, now: now)
end

.prompt_parts(workspace_root: Dir.pwd, include_workspace_personality: true, model: nil, reasoning_effort: nil, now: Time.now, memory_context: nil, plugin_context: nil) ⇒ Object



16
17
18
19
20
21
22
23
24
# File 'lib/kward/prompts.rb', line 16

def prompt_parts(workspace_root: Dir.pwd, include_workspace_personality: true, model: nil, reasoning_effort: nil, now: Time.now, memory_context: nil, plugin_context: nil)
  parts = [base_prompt, config_agents_prompt]
  parts << memory_context unless memory_context.to_s.empty?
  parts << persona_prompt(workspace_root, model: model, reasoning_effort: reasoning_effort, now: now) if include_workspace_personality
  parts << plugin_context unless plugin_context.to_s.empty? || !include_workspace_personality
  parts << skills_prompt
  parts << workspace_agents_prompt(workspace_root)
  parts
end

.skills_promptObject



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/kward/prompts.rb', line 44

def skills_prompt
  skills = ConfigFiles.skills
  return nil if skills.empty?

  lines = [
    "Configured skills are available in the Kward config directory.",
    "When a task matches a skill, use read_skill to load its instructions before proceeding.",
    "Available skills:"
  ]
  skills.each do |skill|
    description = skill.description.empty? ? "No description provided." : skill.description
    lines << "- #{skill.name}: #{description}"
  end
  lines.join("\n")
end

.system_message(workspace_root: Dir.pwd, include_workspace_personality: true, model: nil, reasoning_effort: nil, now: Time.now, memory_context: nil, plugin_context: nil) ⇒ Object



9
10
11
12
13
14
# File 'lib/kward/prompts.rb', line 9

def system_message(workspace_root: Dir.pwd, include_workspace_personality: true, model: nil, reasoning_effort: nil, now: Time.now, memory_context: nil, plugin_context: nil)
  {
    role: "system",
    content: prompt_parts(workspace_root: workspace_root, include_workspace_personality: include_workspace_personality, model: model, reasoning_effort: reasoning_effort, now: now, memory_context: memory_context, plugin_context: plugin_context).compact.join("\n\n")
  }
end

.workspace_agents_prompt(workspace_root = Dir.pwd) ⇒ Object



40
41
42
# File 'lib/kward/prompts.rb', line 40

def workspace_agents_prompt(workspace_root = Dir.pwd)
  ConfigFiles.workspace_agents_prompt(workspace_root)
end