Class: DiscourseCli::Commands::Skill

Inherits:
Base
  • Object
show all
Defined in:
lib/discourse_cli/commands/skill.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

exit_on_failure?

Class Method Details

.agent_pathsObject



8
9
10
11
12
13
14
# File 'lib/discourse_cli/commands/skill.rb', line 8

def self.agent_paths
  {
    claude: File.expand_path("~/.claude/skills/dsc"),
    codex:  File.expand_path("~/.codex/skills/dsc"),
    gemini: File.expand_path("~/.gemini/skills/dsc"),
  }
end

.skill_sourceObject



43
44
45
46
47
48
# File 'lib/discourse_cli/commands/skill.rb', line 43

def self.skill_source
  spec = Gem::Specification.find_by_name("discourse_cli_tool")
  File.join(spec.gem_dir, "skill", "dsc")
rescue Gem::MissingSpecError
  File.expand_path("../../../skill/dsc", __dir__)
end

Instance Method Details

#installObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/discourse_cli/commands/skill.rb', line 20

def install
  targets = selected_agents
  skill_source = self.class.skill_source

  unless File.exist?(skill_source)
    $stderr.puts "Skill source not found at #{skill_source}"
    exit 1
  end

  targets.each do |agent, path|
    FileUtils.mkdir_p(File.dirname(path))

    if File.symlink?(path) && File.readlink(path) == skill_source
      puts "#{agent}: already installed"
      next
    end

    File.unlink(path) if File.symlink?(path) || File.exist?(path)
    File.symlink(skill_source, path)
    puts "#{agent}: installed → #{path}"
  end
end