Module: Docforge::Prompt

Defined in:
lib/docforge/prompt.rb

Overview

Builds the user message wrapping the feature’s inputs (PRD, SPEC, notes, asset list). The system prompt itself is resolved through Config so it can be overridden per-project.

Class Method Summary collapse

Class Method Details

.assets_section(inputs) ⇒ Object



58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/docforge/prompt.rb', line 58

def assets_section(inputs)
  return "" if inputs.assets.empty?

  list = inputs.assets.map { |p| "- #{File.basename(p)}" }.join("\n")
  <<~SECTION

    ---

    ## Available assets (filenames you may reference)

    #{list}
  SECTION
end

.interview_section(answers) ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/docforge/prompt.rb', line 44

def interview_section(answers)
  return "" if answers.nil? || answers.empty?

  lines = answers.map { |q, a| "**Q: #{q}**\nA: #{a}" }.join("\n\n")
  <<~SECTION

    ---

    ## Interview answers

    #{lines}
  SECTION
end

.notes_section(inputs) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
# File 'lib/docforge/prompt.rb', line 32

def notes_section(inputs)
  return "" unless inputs.notes
  <<~SECTION

    ---

    ## Author's notes ("what I'm most proud of")

    #{inputs.notes}
  SECTION
end

.system_prompt(config:) ⇒ Object



10
11
12
# File 'lib/docforge/prompt.rb', line 10

def system_prompt(config:)
  config.system_prompt_content
end

.user_message(inputs:, interview_answers: {}) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/docforge/prompt.rb', line 14

def user_message(inputs:, interview_answers: {})
  <<~MSG
    ## PRD

    #{inputs.prd}

    ---

    ## SPEC

    #{inputs.spec}

    #{notes_section(inputs)}
    #{interview_section(interview_answers)}
    #{assets_section(inputs)}
  MSG
end