Class: Wiq::Commands::Setup

Inherits:
Base
  • Object
show all
Defined in:
lib/wiq/commands/setup.rb

Constant Summary collapse

SKILL_FILENAME =
"SKILL.md"
BUNDLED_SKILL_PATH =
File.expand_path("../../../../share/skills/wiq/#{SKILL_FILENAME}", __FILE__)

Instance Method Summary collapse

Methods inherited from Base

exit_on_failure?

Instance Method Details

#claudeObject



35
36
37
38
39
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
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/wiq/commands/setup.rb', line 35

def claude
  unless File.exist?(BUNDLED_SKILL_PATH)
    raise Wiq::Error.new(
      "Bundled SKILL.md not found at #{BUNDLED_SKILL_PATH}.",
      code: "skill_missing",
      hint: "Reinstall wiq-cli — the gem package may be incomplete."
    )
  end

  if options[:print]
    puts File.read(BUNDLED_SKILL_PATH)
    return
  end

  target_dir = options[:project] ? File.join(Dir.pwd, ".claude", "skills", "wiq")
                                 : File.join(Dir.home, ".claude", "skills", "wiq")
  target_path = File.join(target_dir, SKILL_FILENAME)

  if File.exist?(target_path) && !options[:force]
    raise Wiq::Error.new(
      "#{target_path} already exists.",
      code: "skill_exists",
      hint: "Pass --force to overwrite, or --print to inspect the bundled version first."
    )
  end

  FileUtils.mkdir_p(target_dir)
  FileUtils.cp(BUNDLED_SKILL_PATH, target_path)

  render(
    {
      "scope" => options[:project] ? "project" : "user-global",
      "target_path" => target_path,
      "size_bytes" => File.size(target_path),
      "claude_will_auto_detect" => true
    },
    summary: "Installed Claude Code skill to #{target_path}.",
    breadcrumbs: [
      { "cmd" => "wiq setup claude --print",
        "description" => "Inspect the bundled skill content" },
      { "cmd" => "wiq setup claude --force",
        "description" => "Re-install (e.g. after upgrading wiq-cli)" }
    ]
  )
end