Class: Baid::Commands::Update
- Inherits:
-
Object
- Object
- Baid::Commands::Update
- Defined in:
- lib/baid/commands/update.rb
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(project_dir: ".") ⇒ Update
constructor
A new instance of Update.
Constructor Details
#initialize(project_dir: ".") ⇒ Update
Returns a new instance of Update.
6 7 8 |
# File 'lib/baid/commands/update.rb', line 6 def initialize(project_dir: ".") @project_dir = project_dir end |
Instance Method Details
#execute ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/baid/commands/update.rb', line 10 def execute config = Config.load_project_config installed = config["installed_skills"] || [] if installed.empty? puts "No skills installed." return end client = ApiClient.new agents = (config["agents"] || []).map do |name| AgentDetector::AGENTS.find { |a| a[:name] == name } end.compact installed.each do |skill_name| response = client.get("/skills/resolve", name: skill_name) next if response.code != 200 data = JSON.parse(response.body) SkillWriter.write(data["skill"], agents, @project_dir) puts "Updated #{skill_name}@#{data['skill']['version']}" end end |