Class: Ocak::AgentGenerator

Inherits:
Object
  • Object
show all
Defined in:
lib/ocak/agent_generator.rb

Constant Summary collapse

AGENT_TEMPLATES =
%w[
  implementer reviewer security_reviewer documenter
  merger pipeline planner auditor
].freeze
SKILL_TEMPLATES =
%w[design audit scan_file debt].freeze

Instance Method Summary collapse

Constructor Details

#initialize(stack:, project_dir:, use_ai: true, logger: nil) ⇒ AgentGenerator

Returns a new instance of AgentGenerator.



17
18
19
20
21
22
# File 'lib/ocak/agent_generator.rb', line 17

def initialize(stack:, project_dir:, use_ai: true, logger: nil)
  @stack = stack
  @project_dir = project_dir
  @use_ai = use_ai
  @logger = logger
end

Instance Method Details

#generate_agents(output_dir) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/ocak/agent_generator.rb', line 24

def generate_agents(output_dir)
  FileUtils.mkdir_p(output_dir)

  AGENT_TEMPLATES.each do |agent|
    template_path = File.join(Ocak.templates_dir, 'agents', "#{agent}.md.erb")
    output_name = agent.tr('_', '-')
    output_path = File.join(output_dir, "#{output_name}.md")

    content = render_template(template_path)
    File.write(output_path, content)
    @logger&.info("Generated agent: #{output_name}.md")
  end

  enhance_with_ai(output_dir) if @use_ai
end

#generate_config(output_path) ⇒ Object



69
70
71
72
73
74
# File 'lib/ocak/agent_generator.rb', line 69

def generate_config(output_path)
  template_path = File.join(Ocak.templates_dir, 'ocak.yml.erb')
  content = render_template(template_path)
  File.write(output_path, content)
  @logger&.info('Generated ocak.yml')
end

#generate_hooks(output_dir) ⇒ Object



54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/ocak/agent_generator.rb', line 54

def generate_hooks(output_dir)
  FileUtils.mkdir_p(output_dir)

  %w[post_edit_lint task_completed_test].each do |hook|
    template_path = File.join(Ocak.templates_dir, 'hooks', "#{hook}.sh.erb")
    output_name = hook.tr('_', '-')
    output_path = File.join(output_dir, "#{output_name}.sh")

    content = render_template(template_path)
    File.write(output_path, content)
    File.chmod(0o755, output_path)
    @logger&.info("Generated hook: #{output_name}.sh")
  end
end

#generate_skills(output_dir) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/ocak/agent_generator.rb', line 40

def generate_skills(output_dir)
  SKILL_TEMPLATES.each do |skill|
    skill_dir = File.join(output_dir, skill.tr('_', '-'))
    FileUtils.mkdir_p(skill_dir)

    template_path = File.join(Ocak.templates_dir, 'skills', skill, 'SKILL.md.erb')
    output_path = File.join(skill_dir, 'SKILL.md')

    content = render_template(template_path)
    File.write(output_path, content)
    @logger&.info("Generated skill: #{skill.tr('_', '-')}/SKILL.md")
  end
end