Class: RosettAi::PathResolver

Inherits:
Object
  • Object
show all
Defined in:
lib/rosett_ai/path_resolver.rb

Overview

Resolves filesystem paths for rai configuration directories. Uses instance methods for future multi-engine support (ADR-006).

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(engine: :claude) ⇒ PathResolver

Create a new path resolver for the given engine.

Parameters:

  • engine (Symbol) (defaults to: :claude)

    engine name



17
18
19
# File 'lib/rosett_ai/path_resolver.rb', line 17

def initialize(engine: :claude)
  @engine = engine
end

Instance Attribute Details

#engineObject (readonly)

Returns the value of attribute engine.



11
12
13
# File 'lib/rosett_ai/path_resolver.rb', line 11

def engine
  @engine
end

Class Method Details

.defaultPathResolver

Memoized default instance for single-engine usage.

Returns:



111
112
113
# File 'lib/rosett_ai/path_resolver.rb', line 111

def self.default
  @default ||= new
end

Instance Method Details

#claude_code_config_dirPathname

Claude engine configuration source directory.

Returns:

  • (Pathname)

    conf/engines/claude/config/ relative to Rosett-AI root



95
# File 'lib/rosett_ai/path_resolver.rb', line 95

def claude_code_config_dir = RosettAi.root.join('conf', 'engines', 'claude', 'config')

#content_cache_dirPathname

Content pack cache directory.

Returns:

  • (Pathname)

    cache/content/ inside the rosett-ai config directory



71
# File 'lib/rosett_ai/path_resolver.rb', line 71

def content_cache_dir = rai_config_dir.join('cache', 'content')

#global_dirPathname

Global configuration directory.

Returns:

  • (Pathname)

    ~/.claude/



25
# File 'lib/rosett_ai/path_resolver.rb', line 25

def global_dir = Pathname.new(File.expand_path('~/.claude'))

#license_filePathname

Ed25519-signed JWT license key file.

Returns:

  • (Pathname)

    license.key inside the rosett-ai config directory



63
# File 'lib/rosett_ai/path_resolver.rb', line 63

def license_file = rai_config_dir.join('license.key')

#local_dirPathname

Project-local configuration directory.

Returns:

  • (Pathname)

    .claude/ in the user's working directory



33
# File 'lib/rosett_ai/path_resolver.rb', line 33

def local_dir = Pathname.new(user_pwd).join('.claude')

#local_settings_pathPathname

Local settings override (gitignored).

Returns:

  • (Pathname)

    settings.local.json inside .claude/



91
# File 'lib/rosett_ai/path_resolver.rb', line 91

def local_settings_path = local_dir.join('settings.local.json')

#managed_settings_pathPathname

System-wide managed settings (enterprise).

Returns:

  • (Pathname)

    /etc/claude-code/managed-settings.json



77
78
79
# File 'lib/rosett_ai/path_resolver.rb', line 77

def managed_settings_path
  Pathname.new('/etc/claude-code/managed-settings.json')
end

#packaged_conf_dirPathname

Packaged defaults directory (from .deb install).

Returns:

  • (Pathname)

    /opt/rosett-ai/app/conf



55
# File 'lib/rosett_ai/path_resolver.rb', line 55

def packaged_conf_dir = Pathname.new('/opt/rosett-ai/app/conf')

#premium_content_dirPathname

Premium content packs directory.

Returns:

  • (Pathname)

    premium/ inside the rosett-ai config directory



67
# File 'lib/rosett_ai/path_resolver.rb', line 67

def premium_content_dir = rai_config_dir.join('premium')

#project_claude_mdPathname

Project-level CLAUDE.md file.

Returns:

  • (Pathname)

    CLAUDE.md in the user's working directory



37
# File 'lib/rosett_ai/path_resolver.rb', line 37

def project_claude_md = Pathname.new(user_pwd).join('CLAUDE.md')

#project_settings_pathPathname

Project-level settings file.

Returns:

  • (Pathname)

    settings.json inside .claude/



87
# File 'lib/rosett_ai/path_resolver.rb', line 87

def project_settings_path = local_dir.join('settings.json')

#rai_conf_dirPathname

XDG-compliant rai behaviour/design conf directory. This is where user-level behaviours live — the global compile source.

Returns:

  • (Pathname)

    $XDG_CONFIG_HOME/rosett-ai/conf or ~/.config/rosett-ai/conf



51
# File 'lib/rosett_ai/path_resolver.rb', line 51

def rai_conf_dir = rai_config_dir.join('conf')

#rai_config_dirPathname

XDG-compliant rai configuration directory.

Returns:

  • (Pathname)

    $XDG_CONFIG_HOME/rosett-ai or ~/.config/rosett-ai



43
44
45
46
# File 'lib/rosett_ai/path_resolver.rb', line 43

def rai_config_dir
  xdg = ENV.fetch('XDG_CONFIG_HOME', File.join(Dir.home, '.config'))
  Pathname.new(xdg).join('rosett-ai')
end

#rules_dirPathname

Compiled rules output directory.

Returns:

  • (Pathname)

    ~/.claude/rules/



29
# File 'lib/rosett_ai/path_resolver.rb', line 29

def rules_dir = global_dir.join('rules')

#rules_display_pathString

Tilde-form display path for lockfile output.

Returns:

  • (String)

    ~/.claude/rules



99
# File 'lib/rosett_ai/path_resolver.rb', line 99

def rules_display_path = '~/.claude/rules'

#secrets_filePathname

Encrypted secrets store.

Returns:

  • (Pathname)

    secrets.yml inside the rosett-ai config directory



59
# File 'lib/rosett_ai/path_resolver.rb', line 59

def secrets_file = rai_config_dir.join('secrets.yml')

#user_pwdString

The user's original working directory. When running from the .deb wrapper, Dir.pwd is /opt/rosett-ai/app, so RAI_ORIGINAL_PWD (set by the wrapper) preserves the real directory.

Returns:

  • (String)

    user's working directory



105
106
107
# File 'lib/rosett_ai/path_resolver.rb', line 105

def user_pwd
  ENV.fetch('RAI_ORIGINAL_PWD', Dir.pwd)
end

#user_settings_pathPathname

Global user settings file.

Returns:

  • (Pathname)

    settings.json inside ~/.claude/



83
# File 'lib/rosett_ai/path_resolver.rb', line 83

def  = global_dir.join('settings.json')