elelem-skills 0.2.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/.agents/backlog/001-enforce-pinned-digests.md +71 -0
  3. data/.agents/backlog/002-refresh-skill-tool-description.md +64 -0
  4. data/.agents/backlog/003-redirect-status-handling.md +47 -0
  5. data/.agents/backlog/004-private-address-fetches.md +58 -0
  6. data/.agents/backlog/005-release-changelog-fixes.md +47 -0
  7. data/.agents/backlog/006-gem-metadata-links.md +65 -0
  8. data/.github/workflows/release.yml +63 -0
  9. data/.release-please-manifest.json +3 -0
  10. data/.rspec +1 -0
  11. data/.rubocop.yml +62 -0
  12. data/CHANGELOG.md +22 -0
  13. data/README.md +3 -0
  14. data/Rakefile +5 -1
  15. data/exe/elelem-skills +6 -0
  16. data/lib/elelem/skills/catalog.rb +74 -0
  17. data/lib/elelem/skills/cli.rb +55 -0
  18. data/lib/elelem/skills/fetcher.rb +164 -0
  19. data/lib/elelem/skills/lockfile.rb +56 -0
  20. data/lib/elelem/skills/setup.rb +88 -0
  21. data/lib/elelem/skills/skill.rb +6 -4
  22. data/lib/elelem/skills/skill_file.rb +42 -0
  23. data/lib/elelem/skills/version.rb +1 -1
  24. data/lib/elelem/skills.rb +13 -0
  25. data/release-please-config.json +12 -0
  26. data/spec/elelem/skills/catalog_spec.rb +122 -0
  27. data/spec/elelem/skills/cli_spec.rb +66 -0
  28. data/spec/elelem/skills/fetcher_spec.rb +282 -0
  29. data/spec/elelem/skills/lockfile_spec.rb +51 -0
  30. data/spec/elelem/skills/setup_spec.rb +124 -0
  31. data/spec/elelem/skills/skill_file_spec.rb +79 -0
  32. data/spec/elelem/skills/skill_spec.rb +11 -0
  33. data/spec/fixtures/skills/no-description/SKILL.md +5 -0
  34. data/spec/fixtures/skills/tdd/SKILL.md +8 -0
  35. data/spec/spec_helper.rb +13 -0
  36. metadata +92 -16
  37. data/lib/elelem/skills/prompts/build.erb +0 -39
  38. data/lib/elelem/skills/prompts/design.erb +0 -41
  39. data/lib/elelem/skills/prompts/plan.erb +0 -59
  40. data/lib/elelem/skills/prompts/review.erb +0 -44
  41. data/lib/elelem/skills/prompts/verify.erb +0 -39
@@ -0,0 +1,164 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "digest"
4
+ require "fileutils"
5
+ require "ipaddr"
6
+ require "socket"
7
+ require "json"
8
+ require "net/http"
9
+ require "uri"
10
+
11
+ module Elelem
12
+ module Skills
13
+ class Fetcher
14
+ SCHEMA = "https://schemas.agentskills.io/discovery/0.2.0/schema.json"
15
+ MAX_REDIRECTS = 5
16
+ LOCAL_NAMES = %w[localhost].freeze
17
+
18
+ class FetchError < StandardError
19
+ end
20
+
21
+ def initialize(install_dir: Catalog::REMOTE_SKILLS, http: Net::HTTP, lockfile: nil)
22
+ @install_dir = install_dir
23
+ @http = http
24
+ @lockfile = lockfile || Lockfile.new(File.join(install_dir, ".skill-lock.json"))
25
+ end
26
+
27
+ # Fetches https://<origin>/.well-known/agent-skills/index.json
28
+ # Skills whose pinned digest changed in the last fetch, as "host/name".
29
+ attr_reader :changed
30
+
31
+ def fetch(origin)
32
+ base = normalize(origin)
33
+ @changed = []
34
+ # Only an origin on this machine may lead to this machine.
35
+ @local_origin = local?(base)
36
+ index, index_url = get_json(URI.join(base, "/.well-known/agent-skills/index.json"))
37
+
38
+ unless index["$schema"] == SCHEMA
39
+ raise FetchError, "unrecognized index schema #{index["$schema"].inspect} at #{index_url} (expected #{SCHEMA})"
40
+ end
41
+
42
+ host = sanitize(base.host)
43
+ # Download and check every skill before writing any, so a bad one
44
+ # leaves nothing half installed.
45
+ downloads = (index["skills"] || []).filter_map { |entry| download(entry, index_url) }
46
+ downloads.each { |skill| install(skill, host) }
47
+ downloads.map { |skill| skill[:name] }
48
+ end
49
+
50
+ private
51
+
52
+ def normalize(origin)
53
+ origin = "https://#{origin}" unless origin.start_with?("http://", "https://")
54
+ URI.parse(origin)
55
+ end
56
+
57
+ def sanitize(host)
58
+ host.to_s.downcase.gsub(/[^a-z0-9.-]/, "_")
59
+ end
60
+
61
+ def download(entry, index_url)
62
+ name, type, url, digest = entry.values_at("name", "type", "url", "digest")
63
+
64
+ unless type == "skill-md"
65
+ Elelem.logger.warn("elelem-skills: fetch: skipping #{name.inspect}, unsupported type #{type.inspect} " \
66
+ "(archives are not implemented)")
67
+ return nil
68
+ end
69
+ raise FetchError, "#{name.inspect} has no digest, so it cannot be checked" if digest.to_s.empty?
70
+
71
+ skill_url = URI.join(index_url, url)
72
+ body, = get(skill_url)
73
+ verify!(name, body, digest)
74
+ { name: name, url: skill_url.to_s, digest: digest, body: body }
75
+ end
76
+
77
+ def install(skill, host)
78
+ warn_if_changed(skill, host)
79
+ dir = File.join(@install_dir, host, sanitize(skill[:name]))
80
+ FileUtils.mkdir_p(dir)
81
+ # Write beside the file, then rename, so a reader never sees half of it.
82
+ tmp = File.join(dir, ".SKILL.md.#{Process.pid}")
83
+ File.binwrite(tmp, skill[:body])
84
+ File.rename(tmp, File.join(dir, "SKILL.md"))
85
+ @lockfile.record(host: host, name: skill[:name], url: skill[:url], digest: skill[:digest])
86
+ end
87
+
88
+ # The first fetch pins a digest. A later, different one is installed, but said out loud.
89
+ def warn_if_changed(skill, host)
90
+ pinned = @lockfile.digest_for(host: host, name: skill[:name])
91
+ return if pinned.nil? || pinned == skill[:digest]
92
+
93
+ Elelem.logger.warn("elelem-skills: #{host}/#{skill[:name]} changed: was #{pinned}, now #{skill[:digest]}")
94
+ @changed << "#{host}/#{skill[:name]}"
95
+ end
96
+
97
+ def verify!(name, body, digest)
98
+ expected = digest.to_s.delete_prefix("sha256:")
99
+ actual = Digest::SHA256.hexdigest(body)
100
+ return if expected == actual
101
+
102
+ raise FetchError, "digest mismatch for #{name.inspect}: expected sha256:#{expected}, got sha256:#{actual}"
103
+ end
104
+
105
+ # Returns the parsed body and the URL it came from after any redirects, so
106
+ # relative skill URLs resolve against where the index really is.
107
+ def get_json(uri)
108
+ body, final = get(uri)
109
+ [JSON.parse(body), final]
110
+ rescue JSON::ParserError => e
111
+ raise FetchError, "invalid JSON at #{uri}: #{e.message}"
112
+ end
113
+
114
+ def get(uri, hops: MAX_REDIRECTS)
115
+ raise FetchError, "refusing #{uri}: use https" unless secure?(uri)
116
+
117
+ response = @http.get_response(uri)
118
+ return redirect(uri, response, hops) if response.is_a?(Net::HTTPRedirection)
119
+ raise FetchError, "GET #{uri} -> #{response.code} #{response.message}" unless response.is_a?(Net::HTTPSuccess)
120
+
121
+ [response.body, uri]
122
+ rescue FetchError
123
+ raise
124
+ rescue StandardError => e
125
+ raise FetchError, "GET #{uri} failed: #{e.class}: #{e.message}"
126
+ end
127
+
128
+ def redirect(uri, response, hops)
129
+ raise FetchError, "GET #{uri}: too many redirects" if hops.zero?
130
+
131
+ get(URI.join(uri, response["location"].to_s), hops: hops - 1)
132
+ end
133
+
134
+ # This machine, by address rather than spelling: localhost names, and any
135
+ # numeric form the resolver accepts (127.1, 0x7f000001, [0:0::1],
136
+ # ::ffff:127.0.0.1, 0.0.0.0). A DNS name that points at this machine is
137
+ # not caught here; its TLS certificate would have to match.
138
+ def local?(uri)
139
+ name = uri.hostname.to_s.downcase.chomp(".")
140
+ return true if LOCAL_NAMES.include?(name) || name.end_with?(".localhost")
141
+
142
+ numeric_addresses(name).any? { |address| address.loopback? || address.to_i.zero? }
143
+ end
144
+
145
+ def numeric_addresses(name)
146
+ Addrinfo.getaddrinfo(name, nil, nil, :STREAM, nil, Socket::AI_NUMERICHOST).map do |info|
147
+ address = IPAddr.new(info.ip_address)
148
+ address.ipv4_mapped? ? address.native : address
149
+ end
150
+ rescue SocketError
151
+ []
152
+ end
153
+
154
+ # https, or plain http for a skill server on this machine. A remote index
155
+ # cannot redirect to this machine, http or https.
156
+ def secure?(uri)
157
+ local = local?(uri)
158
+ return false if local && !@local_origin
159
+
160
+ uri.scheme == "https" || (uri.scheme == "http" && local)
161
+ end
162
+ end
163
+ end
164
+ end
@@ -0,0 +1,56 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "fileutils"
4
+ require "json"
5
+ require "time"
6
+
7
+ module Elelem
8
+ module Skills
9
+ class Lockfile
10
+ VERSION = 1
11
+
12
+ def initialize(path)
13
+ @path = path
14
+ end
15
+
16
+ def record(host:, name:, url:, digest:)
17
+ data = read
18
+ key = "#{host}/#{name}"
19
+ now = Time.now.utc.iso8601
20
+ installed_at = data.dig("skills", key, "installedAt") || now
21
+
22
+ data["skills"][key] = {
23
+ "host" => host,
24
+ "name" => name,
25
+ "url" => url,
26
+ "digest" => digest,
27
+ "installedAt" => installed_at,
28
+ "updatedAt" => now
29
+ }
30
+
31
+ write(data)
32
+ end
33
+
34
+ def digest_for(host:, name:)
35
+ read.dig("skills", "#{host}/#{name}", "digest")
36
+ end
37
+
38
+ def read
39
+ return { "version" => VERSION, "skills" => {} } unless File.exist?(@path)
40
+
41
+ data = JSON.parse(File.read(@path))
42
+ data["skills"] ||= {}
43
+ data
44
+ rescue JSON::ParserError
45
+ { "version" => VERSION, "skills" => {} }
46
+ end
47
+
48
+ private
49
+
50
+ def write(data)
51
+ FileUtils.mkdir_p(File.dirname(@path))
52
+ File.write(@path, JSON.pretty_generate(data))
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,88 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Elelem
4
+ module Skills
5
+ class Setup
6
+ SUMMARY_LIMIT = 400
7
+
8
+ def self.call(agent)
9
+ new(agent, Catalog.new).call
10
+ end
11
+
12
+ def initialize(agent, catalog)
13
+ @agent = agent
14
+ @catalog = catalog
15
+ end
16
+
17
+ def call
18
+ register_tool
19
+ register_command
20
+ end
21
+
22
+ private
23
+
24
+ def register_tool
25
+ catalog = @catalog
26
+
27
+ @agent.toolbox.add("skill",
28
+ description: "Load a skill's instructions by name. Available skills:\n" \
29
+ "#{catalog.index(limit: SUMMARY_LIMIT)}",
30
+ params: { name: { type: "string", description: "the skill name" } },
31
+ required: ["name"]) do |a|
32
+ skill = catalog.find(a["name"])
33
+ next { error: "unknown skill: #{a["name"]}" } unless skill
34
+
35
+ { name: skill.name, dir: skill.dir, content: skill.body }
36
+ end
37
+ end
38
+
39
+ def register_command
40
+ catalog = @catalog
41
+ agent = @agent
42
+ completions = -> { catalog.all.map(&:name) }
43
+
44
+ agent.commands.register("skills",
45
+ description: "List available skills, or `/skills fetch <origin>` to install " \
46
+ "from a remote index",
47
+ completions: completions) do |arg|
48
+ if arg&.start_with?("fetch ")
49
+ fetch(agent, arg.delete_prefix("fetch ").strip)
50
+ elsif arg && !arg.empty?
51
+ skill = catalog.find(arg)
52
+ skill ? agent.output.say(skill.body) : agent.output.say("Unknown skill: #{arg}")
53
+ else
54
+ list = catalog.all.map do |skill|
55
+ "- **#{skill.name}**: #{truncate(skill.description, SUMMARY_LIMIT)}"
56
+ end.join("\n")
57
+ agent.output.say(list.empty? ? "No skills found." : list, as: :markdown)
58
+ end
59
+ end
60
+ end
61
+
62
+ def fetch(agent, origin)
63
+ if origin.empty?
64
+ agent.output.say("Usage: /skills fetch <origin>")
65
+ return
66
+ end
67
+
68
+ fetcher = Fetcher.new
69
+ names = fetcher.fetch(origin)
70
+ return agent.output.say("No skills installed from #{origin}.") if names.empty?
71
+
72
+ agent.output.say("Changed since the last fetch: #{fetcher.changed.join(", ")}") if fetcher.changed.any?
73
+
74
+ @catalog.all(reload: true)
75
+ agent.output.say("Installed: #{names.join(", ")}\nAvailable via /skills and the skill tool now. " \
76
+ "Restart elelem to refresh the skill tool's description with the new catalog.")
77
+ rescue Fetcher::FetchError => e
78
+ agent.output.say(e.message, as: :error)
79
+ end
80
+
81
+ def truncate(text, limit)
82
+ return text if text.length <= limit
83
+
84
+ "#{text[0, limit]}..."
85
+ end
86
+ end
87
+ end
88
+ end
@@ -1,9 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- Elelem.configure do |config|
4
- config.setup(:skill) do |agent|
5
- agent.commands.register("skill", description: "Invoke a skill (not yet implemented)") do |_args|
6
- agent.output.say NotImplementedError.new("skills are not implemented yet").message
3
+ module Elelem
4
+ module Skills
5
+ Skill = Struct.new(:name, :description, :dir, :body) do
6
+ def summary
7
+ "#{name}: #{description}"
8
+ end
7
9
  end
8
10
  end
9
11
  end
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Elelem
4
+ module Skills
5
+ module SkillFile
6
+ def self.load(path)
7
+ # UTF-8 whatever the locale, with any byte order mark dropped.
8
+ parse(File.read(path, encoding: "bom|utf-8"), path: path)
9
+ end
10
+
11
+ def self.parse(text, path:)
12
+ # Files saved on Windows start with a BOM and end lines with \r\n.
13
+ text = text.delete_prefix("\uFEFF").gsub("\r\n", "\n")
14
+ frontmatter, body = split(text)
15
+ unless frontmatter
16
+ Elelem.logger.warn("elelem-skills: #{path} has no frontmatter, skipping")
17
+ return nil
18
+ end
19
+
20
+ attrs = YAML.safe_load(frontmatter)
21
+ name = attrs["name"]
22
+ description = attrs["description"]
23
+ unless name && description
24
+ Elelem.logger.warn("elelem-skills: #{path} is missing name or description, skipping")
25
+ return nil
26
+ end
27
+
28
+ Skill.new(name, description, File.dirname(path), body.strip)
29
+ end
30
+
31
+ def self.split(text)
32
+ return [nil, text] unless text.start_with?("---\n")
33
+
34
+ _, frontmatter, body = text.split(/^---\s*$/, 3)
35
+ return [nil, text] unless frontmatter && body
36
+
37
+ [frontmatter, body]
38
+ end
39
+ private_class_method :split
40
+ end
41
+ end
42
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Elelem
4
4
  module Skills
5
- VERSION = "0.2.0"
5
+ VERSION = "0.4.0"
6
6
  end
7
7
  end
data/lib/elelem/skills.rb CHANGED
@@ -1,6 +1,19 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "elelem"
4
+ require "yaml"
4
5
 
5
6
  require_relative "skills/version"
6
7
  require_relative "skills/skill"
8
+ require_relative "skills/skill_file"
9
+ require_relative "skills/catalog"
10
+ require_relative "skills/lockfile"
11
+ require_relative "skills/fetcher"
12
+ require_relative "skills/setup"
13
+ require_relative "skills/cli"
14
+
15
+ Elelem.configure do |config|
16
+ config.setup(:skills) do |agent|
17
+ Elelem::Skills::Setup.call(agent)
18
+ end
19
+ end
@@ -0,0 +1,12 @@
1
+ {
2
+ "bootstrap-sha": "c09ebbd8b832c0417d8d108435f8506996476483",
3
+ "packages": {
4
+ ".": {
5
+ "release-type": "ruby",
6
+ "package-name": "elelem-skills",
7
+ "version-file": "lib/elelem/skills/version.rb",
8
+ "bump-minor-pre-major": true,
9
+ "include-component-in-tag": false
10
+ }
11
+ }
12
+ }
@@ -0,0 +1,122 @@
1
+ # frozen_string_literal: true
2
+
3
+ RSpec.describe Elelem::Skills::Catalog do
4
+ let(:fixtures) { File.expand_path("../../fixtures/skills", __dir__) }
5
+
6
+ describe "#all" do
7
+ it "discovers skills with valid frontmatter and skips invalid ones" do
8
+ catalog = described_class.new(load_paths: [fixtures])
9
+
10
+ expect(catalog.all.map(&:name)).to eq(["tdd"])
11
+ end
12
+
13
+ it "lets later load paths shadow earlier ones by name" do
14
+ Dir.mktmpdir do |override_root|
15
+ override_dir = File.join(override_root, "tdd")
16
+ FileUtils.mkdir_p(override_dir)
17
+ File.write(File.join(override_dir, "SKILL.md"), <<~SKILL)
18
+ ---
19
+ name: tdd
20
+ description: overridden
21
+ ---
22
+ overridden body
23
+ SKILL
24
+
25
+ catalog = described_class.new(load_paths: [fixtures, override_root])
26
+
27
+ expect(catalog.find("tdd").description).to eq("overridden")
28
+ end
29
+ end
30
+
31
+ it "returns an empty list when no load paths exist" do
32
+ catalog = described_class.new(load_paths: ["/nonexistent/path"])
33
+
34
+ expect(catalog.all).to eq([])
35
+ end
36
+ end
37
+
38
+ describe "REMOTE_SKILLS" do
39
+ it "discovers skills fetched into <remote_skills>/<host>/<name>/SKILL.md" do
40
+ Dir.mktmpdir do |remote_root|
41
+ skill_dir = File.join(remote_root, "example.com", "wrangler")
42
+ FileUtils.mkdir_p(skill_dir)
43
+ File.write(File.join(skill_dir, "SKILL.md"), <<~SKILL)
44
+ ---
45
+ name: wrangler
46
+ description: fetched from example.com
47
+ ---
48
+ body
49
+ SKILL
50
+
51
+ catalog = described_class.new(load_paths: [], remote_skills: remote_root)
52
+
53
+ expect(catalog.find("wrangler")&.description).to eq("fetched from example.com")
54
+ end
55
+ end
56
+
57
+ it "does not use a recursive glob that would pick up a nested SKILL.md" do
58
+ Dir.mktmpdir do |remote_root|
59
+ nested = File.join(remote_root, "example.com", "wrangler", "resources", "nested")
60
+ FileUtils.mkdir_p(nested)
61
+ File.write(File.join(nested, "SKILL.md"), <<~SKILL)
62
+ ---
63
+ name: nested-imposter
64
+ description: should not be discovered
65
+ ---
66
+ body
67
+ SKILL
68
+
69
+ catalog = described_class.new(load_paths: [], remote_skills: remote_root)
70
+
71
+ expect(catalog.find("nested-imposter")).to be_nil
72
+ end
73
+ end
74
+
75
+ it "lets a user-level skill of the same name shadow a remote-fetched one" do
76
+ Dir.mktmpdir do |remote_root|
77
+ skill_dir = File.join(remote_root, "example.com", "tdd")
78
+ FileUtils.mkdir_p(skill_dir)
79
+ File.write(File.join(skill_dir, "SKILL.md"), <<~SKILL)
80
+ ---
81
+ name: tdd
82
+ description: remote version
83
+ ---
84
+ body
85
+ SKILL
86
+
87
+ catalog = described_class.new(load_paths: [fixtures], remote_skills: remote_root)
88
+
89
+ expect(catalog.find("tdd").description)
90
+ .to eq("Test-driven development. Use when the user wants tests written first.")
91
+ end
92
+ end
93
+
94
+ it "is not scanned when remote_skills is nil" do
95
+ catalog = described_class.new(load_paths: [], remote_skills: nil)
96
+
97
+ expect { catalog.all }.not_to raise_error
98
+ end
99
+ end
100
+
101
+ describe "#find" do
102
+ it "returns nil for an unknown skill" do
103
+ catalog = described_class.new(load_paths: [fixtures])
104
+
105
+ expect(catalog.find("nope")).to be_nil
106
+ end
107
+ end
108
+
109
+ describe "#index" do
110
+ it "joins summaries without truncating by default" do
111
+ catalog = described_class.new(load_paths: [fixtures])
112
+
113
+ expect(catalog.index).to eq("tdd: Test-driven development. Use when the user wants tests written first.")
114
+ end
115
+
116
+ it "truncates summaries when a limit is given" do
117
+ catalog = described_class.new(load_paths: [fixtures])
118
+
119
+ expect(catalog.index(limit: 10)).to eq("tdd: Test-...")
120
+ end
121
+ end
122
+ end
@@ -0,0 +1,66 @@
1
+ # frozen_string_literal: true
2
+
3
+ RSpec.describe Elelem::Skills::CLI do
4
+ def capture_stdout
5
+ original = $stdout
6
+ $stdout = StringIO.new
7
+ yield
8
+ $stdout.string
9
+ ensure
10
+ $stdout = original
11
+ end
12
+
13
+ describe "#run" do
14
+ it "fetches skills from an origin and prints the installed names" do
15
+ fetcher = instance_double(Elelem::Skills::Fetcher, fetch: ["example"])
16
+ allow(Elelem::Skills::Fetcher).to receive(:new).and_return(fetcher)
17
+
18
+ output = capture_stdout { described_class.new(["fetch", "example.com"]).run }
19
+
20
+ expect(fetcher).to have_received(:fetch).with("example.com")
21
+ expect(output).to include("Installed: example")
22
+ end
23
+
24
+ it "reports when nothing was installed" do
25
+ fetcher = instance_double(Elelem::Skills::Fetcher, fetch: [])
26
+ allow(Elelem::Skills::Fetcher).to receive(:new).and_return(fetcher)
27
+
28
+ output = capture_stdout { described_class.new(["fetch", "example.com"]).run }
29
+
30
+ expect(output).to include("No skills installed from example.com")
31
+ end
32
+
33
+ it "aborts with the fetch error message on failure" do
34
+ fetcher = instance_double(Elelem::Skills::Fetcher)
35
+ allow(fetcher).to receive(:fetch).and_raise(Elelem::Skills::Fetcher::FetchError, "boom")
36
+ allow(Elelem::Skills::Fetcher).to receive(:new).and_return(fetcher)
37
+
38
+ expect { described_class.new(["fetch", "example.com"]).run }.to raise_error(SystemExit)
39
+ end
40
+
41
+ it "requires an origin for fetch" do
42
+ expect { described_class.new(["fetch"]).run }.to raise_error(SystemExit)
43
+ end
44
+
45
+ it "lists discovered skills" do
46
+ fixtures = File.expand_path("../../fixtures/skills", __dir__)
47
+ catalog = instance_double(Elelem::Skills::Catalog,
48
+ all: [Elelem::Skills::Skill.new("tdd", "Test-driven development.", fixtures, "body")])
49
+ allow(Elelem::Skills::Catalog).to receive(:new).and_return(catalog)
50
+
51
+ output = capture_stdout { described_class.new(["list"]).run }
52
+
53
+ expect(output).to include("tdd: Test-driven development.")
54
+ end
55
+
56
+ it "prints usage for an unknown command" do
57
+ expect { described_class.new(["bogus"]).run }.to raise_error(SystemExit)
58
+ end
59
+
60
+ it "prints usage with no args" do
61
+ output = capture_stdout { described_class.new([]).run }
62
+
63
+ expect(output).to include("Usage: elelem-skills")
64
+ end
65
+ end
66
+ end