Class: RosettAi::Retrofit::Parsers::AgentsMdParser

Inherits:
BaseParser
  • Object
show all
Defined in:
lib/rosett_ai/retrofit/parsers/agents_md_parser.rb

Overview

Retrofit parser for AGENTS.md files.

Discovers and parses AGENTS.md in the project root into a structured Rosett-AI YAML representation.

Author:

  • hugo

  • claude

Instance Method Summary collapse

Methods inherited from BaseParser

#available?

Instance Method Details

#discoverArray<String>

Discover native config files for this engine.

Returns:

  • (Array<String>)


25
26
27
28
29
30
31
32
# File 'lib/rosett_ai/retrofit/parsers/agents_md_parser.rb', line 25

def discover
  project_root = Pathname.new(ENV.fetch('RAI_ORIGINAL_PWD', Dir.pwd))
  agents_md = project_root.join('AGENTS.md')

  return [agents_md] if agents_md.exist? && safe_path?(agents_md)

  []
end

#engine_nameString

Return the engine identifier string.

Returns:

  • (String)


19
20
21
# File 'lib/rosett_ai/retrofit/parsers/agents_md_parser.rb', line 19

def engine_name
  'agents_md'
end

#parse(path) ⇒ Hash

Parse a native config file into rosett-ai format.

Parameters:

  • path (Object)

    the path

Returns:

  • (Hash)


38
39
40
41
42
43
44
45
46
47
48
# File 'lib/rosett_ai/retrofit/parsers/agents_md_parser.rb', line 38

def parse(path)
  validate_path!(path)
  content = File.read(path)

  {
    data: { 'agents_md_content' => content },
    unknown_keys: [],
    source_file: path.to_s,
    scope: 'project'
  }
end