Class: Aircana::Generators::AgentsGenerator

Inherits:
BaseGenerator show all
Defined in:
lib/aircana/generators/agents_generator.rb

Constant Summary collapse

PRESET_COLORS =
%w[red blue green cyan yellow magenta purple pink teal orange].freeze

Instance Attribute Summary collapse

Attributes inherited from BaseGenerator

#file_in, #file_out

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseGenerator

#generate

Constructor Details

#initialize(kb_name:, agent_description: nil, color: nil, file_in: nil, file_out: nil) ⇒ AgentsGenerator

Returns a new instance of AgentsGenerator.



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/aircana/generators/agents_generator.rb', line 13

def initialize(kb_name:, agent_description: nil, color: nil, file_in: nil, file_out: nil)
  @kb_name = kb_name
  @agent_name = kb_name
  @agent_description = agent_description || generate_agent_description
  @skill_name = generate_skill_name
  @color = color || PRESET_COLORS.sample

  super(
    file_in: file_in || default_template_path,
    file_out: file_out || default_output_path
  )
end

Instance Attribute Details

#agent_descriptionObject (readonly)

Returns the value of attribute agent_description.



11
12
13
# File 'lib/aircana/generators/agents_generator.rb', line 11

def agent_description
  @agent_description
end

#agent_nameObject (readonly)

Returns the value of attribute agent_name.



11
12
13
# File 'lib/aircana/generators/agents_generator.rb', line 11

def agent_name
  @agent_name
end

#colorObject (readonly)

Returns the value of attribute color.



11
12
13
# File 'lib/aircana/generators/agents_generator.rb', line 11

def color
  @color
end

#kb_nameObject (readonly)

Returns the value of attribute kb_name.



11
12
13
# File 'lib/aircana/generators/agents_generator.rb', line 11

def kb_name
  @kb_name
end

#skill_nameObject (readonly)

Returns the value of attribute skill_name.



11
12
13
# File 'lib/aircana/generators/agents_generator.rb', line 11

def skill_name
  @skill_name
end

Class Method Details

.from_manifest(kb_name) ⇒ Object

Generate agent markdown from manifest data

Raises:



27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/aircana/generators/agents_generator.rb', line 27

def self.from_manifest(kb_name)
  manifest = Contexts::Manifest.read_manifest(kb_name)
  raise Error, "No manifest found for knowledge base '#{kb_name}'" unless manifest

  # Use the same description generation as skills
  agent_description = generate_agent_description_from_manifest(manifest, kb_name)

  new(
    kb_name: kb_name,
    agent_description: agent_description
  )
end

.generate_agent_description_from_manifest(manifest, kb_name) ⇒ Object



40
41
42
43
44
# File 'lib/aircana/generators/agents_generator.rb', line 40

def self.generate_agent_description_from_manifest(manifest, kb_name)
  # Same description as skill - optimized for Claude's agent discovery
  source_count = manifest["sources"]&.size || 0
  "Discover critical context for #{kb_name.split("-").join(" ")} from #{source_count} knowledge sources"
end