Class: RailsTracepointStack::SkillInstaller

Inherits:
Object
  • Object
show all
Defined in:
lib/rails_tracepoint_stack/skill_installer.rb

Overview

Copies the packaged agent skill into the host app.

A skill living in this gem's repository only helps someone working on the gem. Agents look for skills inside the project they are working on, so the file has to land there for the gem to ever get picked up on its own.

Constant Summary collapse

SKILL_PATH =
".claude/skills/debug-with-tracepoint/SKILL.md".freeze
TEMPLATE_PATH =
File.expand_path("templates/skill.md", __dir__).freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(destination: Dir.pwd, force: false) ⇒ SkillInstaller

Returns a new instance of SkillInstaller.



15
16
17
18
# File 'lib/rails_tracepoint_stack/skill_installer.rb', line 15

def initialize(destination: Dir.pwd, force: false)
  @destination = destination
  @force = force
end

Instance Attribute Details

#destinationObject (readonly)

Returns the value of attribute destination.



13
14
15
# File 'lib/rails_tracepoint_stack/skill_installer.rb', line 13

def destination
  @destination
end

#forceObject (readonly)

Returns the value of attribute force.



13
14
15
# File 'lib/rails_tracepoint_stack/skill_installer.rb', line 13

def force
  @force
end

Instance Method Details

#installObject

Returns the path written, or nil when a skill was already there.



21
22
23
24
25
26
27
# File 'lib/rails_tracepoint_stack/skill_installer.rb', line 21

def install
  return nil if File.exist?(target_path) && !force

  FileUtils.mkdir_p(File.dirname(target_path))
  File.write(target_path, template)
  target_path
end

#target_pathObject



29
30
31
# File 'lib/rails_tracepoint_stack/skill_installer.rb', line 29

def target_path
  File.join(destination, SKILL_PATH)
end