Class: AgentSkills::CLI
- Inherits:
-
Thor
- Object
- Thor
- AgentSkills::CLI
- Defined in:
- lib/agent_skills/cli.rb
Class Method Summary collapse
Instance Method Summary collapse
- #info(path) ⇒ Object
- #list ⇒ Object
- #new(name) ⇒ Object
- #pack(path) ⇒ Object
- #unpack(file) ⇒ Object
- #validate(path) ⇒ Object
- #version ⇒ Object
Class Method Details
.exit_on_failure? ⇒ Boolean
7 8 9 |
# File 'lib/agent_skills/cli.rb', line 7 def self.exit_on_failure? true end |
Instance Method Details
#info(path) ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/agent_skills/cli.rb', line 74 def info(path) skill = Skill.load(path) say "Name: ", :green, false say skill.name say "Description: ", :green, false say skill.description say "Path: ", :green, false say skill.path || "(none)" if skill.license say "License: ", :green, false say skill.license end if skill.compatibility say "Compat: ", :green, false say skill.compatibility end unless skill.scripts.empty? say "Scripts: ", :green, false say skill.scripts.map { |s| File.basename(s) }.join(", ") end unless skill.references.empty? say "References: ", :green, false say skill.references.map { |r| File.basename(r) }.join(", ") end # Validation status validator = Validator.new(skill) say "Valid: ", :green, false say validator.valid? ? "Yes" : "No (#{validator.errors.join(', ')})" rescue NotFoundError, ParseError => e say "Error: #{e.message}", :red exit 1 end |
#list ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/agent_skills/cli.rb', line 53 def list paths = [:path] || Loader::DEFAULT_PATHS loader = Loader.new(paths: paths) skills = loader.discover if skills.empty? say "No skills found in: #{paths.join(', ')}", :yellow return end say "Found #{skills.size} skill(s):\n\n" skills.each do |name, skill| say name, :green say " #{truncate(skill.description, 60)}" say " Path: #{skill.path}" if skill.path say "" end end |
#new(name) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/agent_skills/cli.rb', line 17 def new(name) path = Generator.create( path: [:path], name: name, description: [:description], with_scripts: [:scripts], with_references: [:references], with_assets: [:assets] ) say "Created skill at #{path}/", :green say " SKILL.md" say " scripts/" if [:scripts] say " references/" if [:references] say " assets/" if [:assets] end |
#pack(path) ⇒ Object
115 116 117 118 119 120 121 |
# File 'lib/agent_skills/cli.rb', line 115 def pack(path) output = Packager.pack(path, output: [:output]) say "Created #{output}", :green rescue NotFoundError, ParseError, ValidationError => e say "Error: #{e.message}", :red exit 1 end |
#unpack(file) ⇒ Object
125 126 127 128 129 130 131 |
# File 'lib/agent_skills/cli.rb', line 125 def unpack(file) extracted = Packager.unpack(file, output: [:output]) say "Extracted to #{extracted}", :green rescue NotFoundError => e say "Error: #{e.message}", :red exit 1 end |
#validate(path) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/agent_skills/cli.rb', line 35 def validate(path) skill = Skill.load(path) validator = Validator.new(skill) if validator.valid? say "#{skill.name} is valid", :green else say "#{skill.name} has errors:", :red validator.errors.each { |e| say " - #{e}", :red } exit 1 end rescue NotFoundError, ParseError => e say "Error: #{e.message}", :red exit 1 end |
#version ⇒ Object
134 135 136 |
# File 'lib/agent_skills/cli.rb', line 134 def version say "agent_skills #{VERSION}" end |