Class: MonkeysPaw::PromptManager

Inherits:
Object
  • Object
show all
Defined in:
lib/monkeyspaw/prompt_manager.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ PromptManager

Returns a new instance of PromptManager.



6
7
8
9
# File 'lib/monkeyspaw/prompt_manager.rb', line 6

def initialize(app)
  @app = app
  load_default_components
end

Instance Attribute Details

#appObject (readonly)

Returns the value of attribute app.



3
4
5
# File 'lib/monkeyspaw/prompt_manager.rb', line 3

def app
  @app
end

#layout_promptObject

Returns the value of attribute layout_prompt.



4
5
6
# File 'lib/monkeyspaw/prompt_manager.rb', line 4

def layout_prompt
  @layout_prompt
end

#style_promptObject

Returns the value of attribute style_prompt.



4
5
6
# File 'lib/monkeyspaw/prompt_manager.rb', line 4

def style_prompt
  @style_prompt
end

Instance Method Details

#default_layout_promptObject



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

def default_layout_prompt
  <<~LAYOUT
    # Layout Component

    Create a simple and clean layout with:
    - A responsive header at the top with the page title
    - A main content area that contains the primary content
    - A footer with copyright information
    - Navigation links if appropriate for the context

    The layout should be responsive and work well on mobile and desktop devices.
  LAYOUT
end

#default_style_promptObject



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

def default_style_prompt
  <<~STYLE
    # Style Component

    Apply these styling guidelines:
    - Use a clean, minimalist design with ample white space
    - Color scheme: soft blues (#4A90E2) for primary elements, light gray (#F5F5F5) for backgrounds
    - Typography: Sans-serif fonts (system-ui) with good readability
    - Interactive elements should have subtle hover effects
    - Content should be well-structured with clear hierarchy
    - Ensure good contrast for accessibility
  STYLE
end

#get_component_prompt(component_name) ⇒ Object



16
17
18
19
# File 'lib/monkeyspaw/prompt_manager.rb', line 16

def get_component_prompt(component_name)
  component_file = app.components_dir.join("#{component_name}.md")
  component_file if component_file.exist?
end

#get_page_prompt(path) ⇒ Object



11
12
13
14
# File 'lib/monkeyspaw/prompt_manager.rb', line 11

def get_page_prompt(path)
  path = "/" if path.empty?
  app.router.get_file(path)
end

#load_default_componentsObject



39
40
41
42
# File 'lib/monkeyspaw/prompt_manager.rb', line 39

def load_default_components
  load_layout_prompt
  load_style_prompt
end

#load_layout_promptObject



21
22
23
24
25
26
27
28
# File 'lib/monkeyspaw/prompt_manager.rb', line 21

def load_layout_prompt
  layout_file = get_component_prompt('layout')
  if layout_file
    @layout_prompt = File.read(layout_file)
  else
    @layout_prompt = default_layout_prompt
  end
end

#load_style_promptObject



30
31
32
33
34
35
36
37
# File 'lib/monkeyspaw/prompt_manager.rb', line 30

def load_style_prompt
  style_file = get_component_prompt('style')
  if style_file
    @style_prompt = File.read(style_file)
  else
    @style_prompt = default_style_prompt
  end
end