Class: LcpRuby::SkillsInstaller
- Inherits:
-
Object
- Object
- LcpRuby::SkillsInstaller
- Defined in:
- lib/lcp_ruby/skills_installer.rb
Overview
Installs (copies/refreshes) the gem-bundled ‘lcp-*` AI authoring skills into a target agent skills directory (for example `.claude/skills/` or `.codex/skills/`). Rails-free.
Refresh is an exact mirror of the gem’s ‘lcp-*` set: each shipped skill dir is replaced wholesale, orphaned `lcp-*` dirs are pruned (when `prune: true`), and non-`lcp-*` skills are NEVER touched. The installer does no I/O logging —the caller (CLI prints, generator maps to Thor `say`) reports from Result.
Defined Under Namespace
Classes: Result
Constant Summary collapse
- AGENT_DIRECTORIES =
{ "claude" => ".claude", "codex" => ".codex" }.freeze
- DEFAULT_AGENTS =
AGENT_DIRECTORIES.keys.freeze
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(target:, source: LcpRuby::GemPaths.skills, prune: true) ⇒ SkillsInstaller
constructor
A new instance of SkillsInstaller.
Constructor Details
#initialize(target:, source: LcpRuby::GemPaths.skills, prune: true) ⇒ SkillsInstaller
Returns a new instance of SkillsInstaller.
34 35 36 37 38 |
# File 'lib/lcp_ruby/skills_installer.rb', line 34 def initialize(target:, source: LcpRuby::GemPaths.skills, prune: true) @target = target @source = source @prune = prune end |
Class Method Details
.agent_skill_targets(root:, agents: DEFAULT_AGENTS) ⇒ Object
28 29 30 31 32 |
# File 'lib/lcp_ruby/skills_installer.rb', line 28 def self.agent_skill_targets(root:, agents: DEFAULT_AGENTS) agents.each_with_object({}) do |agent, targets| targets[agent] = File.join(root, AGENT_DIRECTORIES.fetch(agent), "skills") end end |
Instance Method Details
#call ⇒ Object
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 |
# File 'lib/lcp_ruby/skills_installer.rb', line 40 def call created = [] updated = [] removed = [] FileUtils.mkdir_p(@target) shipped = source_skill_names shipped.each do |name| dest = File.join(@target, name) existed = Dir.exist?(dest) FileUtils.rm_rf(dest) FileUtils.cp_r(File.join(@source, name), dest) (existed ? updated : created) << name end if @prune target_skill_names.each do |name| next if shipped.include?(name) FileUtils.rm_rf(File.join(@target, name)) removed << name end end Result.new(created: created.sort, updated: updated.sort, removed: removed.sort) end |