Class: RosettAi::Retrofit::Parsers::ClaudeParser
- Inherits:
-
BaseParser
- Object
- BaseParser
- RosettAi::Retrofit::Parsers::ClaudeParser
- Defined in:
- lib/rosett_ai/retrofit/parsers/claude_parser.rb
Overview
Retrofit parser for Claude Code configuration files.
Discovers and parses ~/.claude/settings.json and project-level .claude/settings.json into Rosett-AI YAML structure.
Constant Summary collapse
- KNOWN_KEYS =
Returns Configuration keys recognized by this parser.
[ 'permissions', 'allowedTools', 'deniedTools', 'trustedTools', 'env', 'hooks', 'mcpServers', 'customApiKeyResponses', 'contextProviders', 'preferences' ].freeze
Instance Method Summary collapse
-
#discover ⇒ Array<String>
Discover native config files for this engine.
-
#engine_name ⇒ String
Return the engine identifier string.
-
#parse(path) ⇒ Hash
Parse a native config file into rosett-ai format.
Methods inherited from BaseParser
Instance Method Details
#discover ⇒ Array<String>
Discover native config files for this engine.
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/rosett_ai/retrofit/parsers/claude_parser.rb', line 33 def discover paths = [] global = Pathname.new(Dir.home).join('.claude', 'settings.json') paths << global if global.exist? && safe_path?(global) local = Pathname.new(ENV.fetch('RAI_ORIGINAL_PWD', Dir.pwd)).join('.claude', 'settings.json') paths << local if local.exist? && safe_path?(local) && local != global paths end |
#engine_name ⇒ String
Return the engine identifier string.
27 28 29 |
# File 'lib/rosett_ai/retrofit/parsers/claude_parser.rb', line 27 def engine_name 'claude' end |
#parse(path) ⇒ Hash
Parse a native config file into rosett-ai format.
48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/rosett_ai/retrofit/parsers/claude_parser.rb', line 48 def parse(path) validate_path!(path) content = File.read(path) data = JSON.parse(content) unknown_keys = data.keys.reject { |key| KNOWN_KEYS.include?(key) } { data: data, unknown_keys: unknown_keys.map { |key| sanitize(key) }, source_file: path.to_s, scope: detect_scope(path) } end |