Class: SkillBench::Services::PromptBuilderService

Inherits:
Object
  • Object
show all
Defined in:
lib/skill_bench/services/prompt_builder_service.rb

Overview

Builds system prompts for baseline and context agent runs.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.build_baselineString

Builds the baseline system prompt (no skill context).

Returns:

  • (String)

    The baseline system prompt



14
15
16
# File 'lib/skill_bench/services/prompt_builder_service.rb', line 14

def self.build_baseline
  new.build_baseline
end

.build_context(evaluation, skills, skill_context) ⇒ String

Builds the context-aware system prompt based on eval metadata.

For ‘skill_bundle_xml` context mode, combines SKILL.md with source code via ContextHydrator. Falls back to SKILL.md-only if source is unavailable.

Parameters:

Returns:

  • (String)

    The context system prompt



27
28
29
# File 'lib/skill_bench/services/prompt_builder_service.rb', line 27

def self.build_context(evaluation, skills, skill_context)
  new.build_context(evaluation, skills, skill_context)
end

Instance Method Details

#build_baselineString

Builds the baseline system prompt (no skill context).

Returns:

  • (String)

    The baseline system prompt



34
35
36
37
38
39
40
# File 'lib/skill_bench/services/prompt_builder_service.rb', line 34

def build_baseline
  <<~PROMPT
    You are an expert Ruby on Rails developer. Your job is to read the task,
    modify the codebase using the tools provided to meet the requirements,
    and then explain what you did.
  PROMPT
end

#build_context(evaluation, _skills, skill_context) ⇒ String

Builds the context-aware system prompt based on eval metadata.

For ‘skill_bundle_xml` context mode, combines SKILL.md with source code via ContextHydrator. Falls back to SKILL.md-only if source is unavailable.

Parameters:

Returns:

  • (String)

    The context system prompt



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/skill_bench/services/prompt_builder_service.rb', line 51

def build_context(evaluation, _skills, skill_context)
  return skill_context unless evaluation.['context_mode'] == 'skill_bundle_xml'

  source_path = resolve_source_path(evaluation)
  return skill_context unless source_path

  xml_result = Execution::ContextHydrator.call(source_path: source_path, base_path: Pathname.new(Dir.pwd))
  hydrator_response = xml_result[:response]
  xml_context = hydrator_response[:context]
  return skill_context unless xml_result[:success] && !xml_context.empty?

  <<~PROMPT
    You are an expert Ruby on Rails developer.
    You have access to a skill file and source code wrapped in <agent_context> tags.
    Use the skill instructions and the provided source code to solve the task.

    ## Skill Instructions
    #{skill_context}

    ## Source Code
    #{xml_context}
  PROMPT
end