Class: ExternalSkillsImporter

Inherits:
Object
  • Object
show all
Defined in:
lib/clacky/default_skills/onboard/scripts/import_external_skills.rb

Overview


Base class for a single-source importer


Direct Known Subclasses

OpenClawImporter

Instance Method Summary collapse

Constructor Details

#initialize(target_skills_dir:, category_subdir:, dry_run: false) ⇒ ExternalSkillsImporter

Returns a new instance of ExternalSkillsImporter.

Parameters:

  • target_skills_dir (Pathname)

    ~/.clacky/skills/

  • category_subdir (String)

    subdirectory name used to group imported skills

  • dry_run (Boolean) (defaults to: false)

    when true, only preview without making changes



36
37
38
39
40
41
42
# File 'lib/clacky/default_skills/onboard/scripts/import_external_skills.rb', line 36

def initialize(target_skills_dir:, category_subdir:, dry_run: false)
  @target_skills_dir = target_skills_dir
  @target_import_dir = target_skills_dir.join(category_subdir)
  @dry_run           = dry_run
  @imported          = []
  @errors            = []
end

Instance Method Details

#errorsArray<String>

Errors encountered during this import run.

Returns:

  • (Array<String>)


65
66
67
# File 'lib/clacky/default_skills/onboard/scripts/import_external_skills.rb', line 65

def errors
  @errors.dup
end

#importedArray<Hash>

Imported skill records for reporting.

Returns:

  • (Array<Hash>)


71
72
73
# File 'lib/clacky/default_skills/onboard/scripts/import_external_skills.rb', line 71

def imported
  @imported.dup
end

#runInteger

Run the import for this source.

Returns:

  • (Integer)

    number of skills imported (or would be imported in dry-run mode)



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/clacky/default_skills/onboard/scripts/import_external_skills.rb', line 46

def run
  unless source_available?
    puts "[INFO] #{source_label} not found - skipping."
    return 0
  end

  skills = discover_skills
  if skills.empty?
    puts "[INFO] No #{source_label} skills found - nothing to import."
    return 0
  end

  skills.each { |skill| process_skill(skill) }

  @imported.size
end