Class: Rubino::Context::FileDiscovery
- Inherits:
-
Object
- Object
- Rubino::Context::FileDiscovery
- Defined in:
- lib/rubino/context/file_discovery.rb
Overview
Discovers and loads project context files from the working directory. Supports multiple file conventions (.rubino.md, AGENTS.md, etc.)
Constant Summary collapse
- CONTEXT_FILES =
%w[ .rubino.md RUBINO.md AGENTS.md CLAUDE.md .cursorrules ].freeze
Instance Method Summary collapse
-
#discover_files ⇒ Object
Returns list of discovered context file paths.
-
#initialize(base_path: nil) ⇒ FileDiscovery
constructor
A new instance of FileDiscovery.
-
#load_project_context ⇒ Object
Loads and concatenates all found project context files.
-
#local_context(subdir) ⇒ Object
Checks a subdirectory for local context files.
Constructor Details
#initialize(base_path: nil) ⇒ FileDiscovery
Returns a new instance of FileDiscovery.
16 17 18 |
# File 'lib/rubino/context/file_discovery.rb', line 16 def initialize(base_path: nil) @base_path = base_path || Dir.pwd end |
Instance Method Details
#discover_files ⇒ Object
Returns list of discovered context file paths
29 30 31 32 33 34 |
# File 'lib/rubino/context/file_discovery.rb', line 29 def discover_files CONTEXT_FILES.filter_map do |filename| path = File.join(@base_path, filename) path if File.exist?(path) end end |
#load_project_context ⇒ Object
Loads and concatenates all found project context files
21 22 23 24 25 26 |
# File 'lib/rubino/context/file_discovery.rb', line 21 def load_project_context files = discover_files return nil if files.empty? files.map { |f| File.read(f) }.join("\n\n---\n\n") end |
#local_context(subdir) ⇒ Object
Checks a subdirectory for local context files
37 38 39 40 41 42 |
# File 'lib/rubino/context/file_discovery.rb', line 37 def local_context(subdir) CONTEXT_FILES.filter_map do |filename| path = File.join(@base_path, subdir, filename) File.read(path) if File.exist?(path) end.join("\n") end |