Class: RosettAi::Retrofit::Parsers::CursorParser

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

Overview

Retrofit parser for Cursor configuration files.

Discovers and parses .cursor/settings.json and .cursorrules into Rosett-AI YAML structure.

Author:

  • hugo

  • claude

Constant Summary collapse

KNOWN_KEYS =

Returns Configuration keys recognized by this parser.

Returns:

  • (Array)

    Configuration keys recognized by this parser.

[
  'rules', 'model', 'temperature', 'maxTokens', 'contextFiles', 'ignoreFiles'
].freeze

Instance Method Summary collapse

Methods inherited from BaseParser

#available?

Instance Method Details

#discoverArray<String>

Discover native config files for this engine.

Returns:

  • (Array<String>)


32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/rosett_ai/retrofit/parsers/cursor_parser.rb', line 32

def discover
  paths = []
  project_root = Pathname.new(ENV.fetch('RAI_ORIGINAL_PWD', Dir.pwd))

  settings = project_root.join('.cursor', 'settings.json')
  paths << settings if settings.exist? && safe_path?(settings)

  rules = project_root.join('.cursorrules')
  paths << rules if rules.exist? && safe_path?(rules)

  paths
end

#engine_nameString

Return the engine identifier string.

Returns:

  • (String)


26
27
28
# File 'lib/rosett_ai/retrofit/parsers/cursor_parser.rb', line 26

def engine_name
  'cursor'
end

#parse(path) ⇒ Hash

Parse a native config file into rosett-ai format.

Parameters:

  • path (Object)

    the path

Returns:

  • (Hash)


49
50
51
52
53
54
55
56
57
# File 'lib/rosett_ai/retrofit/parsers/cursor_parser.rb', line 49

def parse(path)
  validate_path!(path)

  if path.extname == '.json'
    parse_json(path)
  else
    parse_rules(path)
  end
end