Class: Coat::Install

Inherits:
Object
  • Object
show all
Defined in:
lib/coat/install.rb

Overview

Puts coat's hooks into Claude Code's settings, so the harness collects the scraps and nobody has to remember to. Everything already in the file is left alone, and installing twice changes nothing the second time.

Constant Summary collapse

COMMAND =
"coat hook"
SETTINGS =
File.join(".claude", "settings.json")
DEFAULT_TOOLS =
"Task"

Instance Method Summary collapse

Constructor Details

#initialize(path: SETTINGS, tools: DEFAULT_TOOLS) ⇒ Install

Returns a new instance of Install.



15
16
17
18
# File 'lib/coat/install.rb', line 15

def initialize(path: SETTINGS, tools: DEFAULT_TOOLS)
  @path = path
  @tools = tools
end

Instance Method Details

#runObject

Returns the events it had to change, so a second run can say it had nothing to do.



22
23
24
25
26
27
28
# File 'lib/coat/install.rb', line 22

def run
  settings = read
  hooks = settings["hooks"] ||= {}
  changed = wiring.select { |event, matcher| add(hooks, event, matcher) }.keys
  write(settings) unless changed.empty?
  changed
end

#wiringObject

PreToolUse pins the working tree, PostToolUse adds what the tool produced and asks the pin what moved, Stop stitches whatever was collected. Stop matches nothing because it is not about a tool.



33
34
35
# File 'lib/coat/install.rb', line 33

def wiring
  { "PreToolUse" => @tools, "PostToolUse" => @tools, "Stop" => nil }
end