Class: SolidAgent::AgentManifest::Parsers::BaseParser

Inherits:
Object
  • Object
show all
Defined in:
lib/solid_agent/agent_manifest/parsers/base_parser.rb

Overview

BaseParser provides common functionality for all format parsers.

Subclasses should implement:

  • .parse_string(content) - Parse content string into a Manifest
  • .format_name - Return the format identifier symbol

Constant Summary collapse

FRONTMATTER_REGEX =
/\A---\s*\n(.*?)\n---\s*\n(.*)\z/m

Class Method Summary collapse

Class Method Details

.format_nameSymbol

Get the format name for this parser

Returns:

  • (Symbol)

Raises:

  • (NotImplementedError)


49
50
51
# File 'lib/solid_agent/agent_manifest/parsers/base_parser.rb', line 49

def format_name
  raise NotImplementedError, "#{self}.format_name must be implemented by subclass"
end

.parse(path) ⇒ Manifest

Parse a file into a Manifest

Parameters:

  • path (String)

    Path to the file

Returns:



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/solid_agent/agent_manifest/parsers/base_parser.rb', line 20

def parse(path)
  content = File.read(path, encoding: "UTF-8")
  manifest = parse_string(content)

  # Handle array results (e.g., CrewAI with multiple agents)
  if manifest.is_a?(Array)
    manifest.each do |m|
      m.source_path = path
      m.source_format = format_name
    end
  else
    manifest.source_path = path
    manifest.source_format = format_name
  end

  manifest
end

.parse_string(content) ⇒ Manifest

Parse content string into a Manifest

Parameters:

  • content (String)

    File content

Returns:

Raises:

  • (NotImplementedError)


42
43
44
# File 'lib/solid_agent/agent_manifest/parsers/base_parser.rb', line 42

def parse_string(content)
  raise NotImplementedError, "#{self}.parse_string must be implemented by subclass"
end