Class: Erb::Generators::AgentGenerator

Inherits:
Base
  • Object
show all
Defined in:
lib/generators/erb/agent_generator.rb

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initialize(*args, **kwargs) ⇒ AgentGenerator

Returns a new instance of AgentGenerator.



14
15
16
17
18
19
20
# File 'lib/generators/erb/agent_generator.rb', line 14

def initialize(*args, **kwargs)
  super(*args, **kwargs)

  # We must duplicate due to immutable hash
  dup_options = options.dup
  @options = dup_options.merge(template_engine: :erb)
end

Instance Method Details

#copy_view_filesObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/generators/erb/agent_generator.rb', line 22

def copy_view_files
  view_base_path = File.join("app/views/agents", class_path, file_name)
  empty_directory view_base_path

  # Create instructions file with the specified format (no .erb extension)
  file_extension = format == "markdown" ? "md" : format
  instructions_file = "instructions.#{file_extension}"
  instructions_path = File.join(view_base_path, instructions_file)
  template "instructions.#{file_extension}.tt", instructions_path

  # Create action view files
  actions.each do |action|
    @action = action

    # Create message file in specified format
    action_file = "#{action}.#{file_extension}.erb"
    action_path = File.join(view_base_path, action_file)
    template "message.#{file_extension}.erb.tt", action_path

    # Create schema file if requested
    if json_schema?
      schema_file = "#{action}.json"
      schema_path = File.join(view_base_path, schema_file)
      template "schema.json.tt", schema_path
    end
  end
end