Class: RubynCode::Skills::Loader
- Inherits:
-
Object
- Object
- RubynCode::Skills::Loader
- Defined in:
- lib/rubyn_code/skills/loader.rb
Instance Attribute Summary collapse
-
#catalog ⇒ Object
readonly
Returns the value of attribute catalog.
Instance Method Summary collapse
- #descriptions_for_prompt ⇒ Object
-
#initialize(catalog) ⇒ Loader
constructor
A new instance of Loader.
- #load(name) ⇒ Object
- #loaded ⇒ Object
-
#suggest_skills(codebase_index: nil, project_profile: nil) ⇒ Array<String>
Suggest skills based on what the codebase index reveals about the project.
Constructor Details
#initialize(catalog) ⇒ Loader
Returns a new instance of Loader.
8 9 10 11 |
# File 'lib/rubyn_code/skills/loader.rb', line 8 def initialize(catalog) @catalog = catalog @loaded = {} end |
Instance Attribute Details
#catalog ⇒ Object (readonly)
Returns the value of attribute catalog.
6 7 8 |
# File 'lib/rubyn_code/skills/loader.rb', line 6 def catalog @catalog end |
Instance Method Details
#descriptions_for_prompt ⇒ Object
32 33 34 |
# File 'lib/rubyn_code/skills/loader.rb', line 32 def descriptions_for_prompt catalog.descriptions end |
#load(name) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/rubyn_code/skills/loader.rb', line 13 def load(name) name = name.to_s return @loaded[name] if @loaded.key?(name) path = catalog.find(name) raise Error, "Skill not found: #{name}" unless path doc = Document.parse_file(path) content = format_skill(doc) @loaded[name] = content content end |
#loaded ⇒ Object
28 29 30 |
# File 'lib/rubyn_code/skills/loader.rb', line 28 def loaded @loaded.keys end |
#suggest_skills(codebase_index: nil, project_profile: nil) ⇒ Array<String>
Suggest skills based on what the codebase index reveals about the project.
Inspects class names, parent classes, and file paths in the index to detect common Rails patterns (Devise, ActionMailer, ActiveJob, etc.) and returns matching skill names.
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/rubyn_code/skills/loader.rb', line 45 def suggest_skills(codebase_index: nil, project_profile: nil) # rubocop:disable Lint/UnusedMethodArgument, Metrics/CyclomaticComplexity -- project_profile reserved for future use return [] unless codebase_index suggestions = [] node_names = codebase_index.nodes.map { |n| n['name'].to_s } node_files = codebase_index.nodes.map { |n| n['file'].to_s } suggestions << 'authentication' if detect_devise?(node_names, node_files) suggestions << 'mailer' if detect_action_mailer?(node_names, node_files) suggestions << 'background-job' if detect_active_job?(node_names, node_files) suggestions rescue StandardError [] end |