Class: TheLocal::Agent

Inherits:
Data
  • Object
show all
Defined in:
lib/the_local/agent.rb

Overview

An immutable description of one Claude Code subagent contributed by a provider (a gem or the app). Renders to a ‘.claude/agents/*.md` definition.

gem_name is the providing gem (used to filter to a host’s direct dependencies). prefix is the filename namespace (often a shorter alias, e.g. gem “keystone_ui” → prefix “keystone”). knowledge is a string or array of strings appended below the role body — the provider’s reference(s). source_path is the absolute path to the provider’s committed, pre-rendered .md file; the host installer copies it verbatim. It stays nil until a provider supplies an agents_dir, so existing providers keep working.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source_path: nil, **args) ⇒ Agent

Returns a new instance of Agent.



15
16
17
# File 'lib/the_local/agent.rb', line 15

def initialize(source_path: nil, **args)
  super
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body

Returns:

  • (Object)

    the current value of body



14
15
16
# File 'lib/the_local/agent.rb', line 14

def body
  @body
end

#descriptionObject (readonly)

Returns the value of attribute description

Returns:

  • (Object)

    the current value of description



14
15
16
# File 'lib/the_local/agent.rb', line 14

def description
  @description
end

#gem_nameObject (readonly)

Returns the value of attribute gem_name

Returns:

  • (Object)

    the current value of gem_name



14
15
16
# File 'lib/the_local/agent.rb', line 14

def gem_name
  @gem_name
end

#knowledgeObject (readonly)

Returns the value of attribute knowledge

Returns:

  • (Object)

    the current value of knowledge



14
15
16
# File 'lib/the_local/agent.rb', line 14

def knowledge
  @knowledge
end

#nameObject (readonly)

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



14
15
16
# File 'lib/the_local/agent.rb', line 14

def name
  @name
end

#prefixObject (readonly)

Returns the value of attribute prefix

Returns:

  • (Object)

    the current value of prefix



14
15
16
# File 'lib/the_local/agent.rb', line 14

def prefix
  @prefix
end

#source_pathObject (readonly)

Returns the value of attribute source_path

Returns:

  • (Object)

    the current value of source_path



14
15
16
# File 'lib/the_local/agent.rb', line 14

def source_path
  @source_path
end

#toolsObject (readonly)

Returns the value of attribute tools

Returns:

  • (Object)

    the current value of tools



14
15
16
# File 'lib/the_local/agent.rb', line 14

def tools
  @tools
end

Instance Method Details

#filenameObject



23
24
25
# File 'lib/the_local/agent.rb', line 23

def filename
  "#{qualified_name}.md"
end

#qualified_nameObject



19
20
21
# File 'lib/the_local/agent.rb', line 19

def qualified_name
  "#{prefix}-#{name}"
end

#to_markdownObject



27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/the_local/agent.rb', line 27

def to_markdown
  <<~MARKDOWN
    ---
    name: #{qualified_name}
    description: #{description}
    tools: #{tools}
    ---

    #{body}

    #{Array(knowledge).join("\n\n")}
  MARKDOWN
end