Class: CLISkills

Inherits:
Thor
  • Object
show all
Defined in:
lib/rage/cli/skills.rb

Constant Summary collapse

SKILLS_DIR =
"rage-framework"
VERSION_FILE =
".version"

Instance Method Summary collapse

Instance Method Details

#installObject



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/rage/cli/skills.rb', line 9

def install
  installation_path = choose_installation_path
  return unless installation_path

  skills_version = fetch_skills_version
  say "Downloading skills..."
  install_skills(installation_path, skills_version)

  say "#{set_color("", :green)} Installed Rage skills #{set_color(skills_version, :bold)} to #{set_color(installation_path, :cyan)}."
  say "#{set_color("", :green)} Skills are now available to your coding agent."
rescue => e
  say_error(e)
end

#updateObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/rage/cli/skills.rb', line 26

def update
  skills_destinations = Dir.glob(".*/skills/#{SKILLS_DIR}")
  debug { "Existing skills installations found: #{skills_destinations}" }

  if skills_destinations.empty?
    log "No existing installation found. Running fresh install...\n\n"
    return install
  end

  skills_version = fetch_skills_version
  updated_paths = []

  skills_destinations.each do |destination|
    version_file = File.join(destination, VERSION_FILE)
    current_version = File.exist?(version_file) ? File.read(version_file).strip : nil

    if current_version == skills_version
      log "#{set_color(destination, :cyan)}: already up to date."
      next
    end

    log "Updating #{set_color(destination, :cyan)}..."
    install_skills(destination, skills_version)
    updated_paths << destination
  end

  if updated_paths.any?
    log "#{set_color("", :green)} Updated #{updated_paths.size} installation#{"s" if updated_paths.size > 1} to #{set_color(skills_version, :bold)}."
  end

  json_output(
    status: updated_paths.any? ? "updated" : "up_to_date",
    version: skills_version,
    paths: skills_destinations
  )
rescue => e
  if options[:json]
    json_output(status: "error", message: e.message)
    exit 1
  else
    say_error(e)
  end
end