Module: Kward::Prompts

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

Defined Under Namespace

Classes: Templates

Class Method Summary collapse

Class Method Details

.base_promptObject



24
25
26
27
28
# File 'lib/kward/prompts.rb', line 24

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



30
31
32
# File 'lib/kward/prompts.rb', line 30

def config_agents_prompt
  ConfigFiles.agents_prompt
end

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



34
35
36
# File 'lib/kward/prompts.rb', line 34

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



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

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



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

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



7
8
9
10
11
12
# File 'lib/kward/prompts.rb', line 7

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



38
39
40
# File 'lib/kward/prompts.rb', line 38

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