Class: Coat::Install
- Inherits:
-
Object
- Object
- Coat::Install
- 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
-
#initialize(path: SETTINGS, tools: DEFAULT_TOOLS) ⇒ Install
constructor
A new instance of Install.
-
#run ⇒ Object
Returns the events it had to change, so a second run can say it had nothing to do.
-
#wiring ⇒ Object
PreToolUse pins the working tree, PostToolUse adds what the tool produced and asks the pin what moved, Stop stitches whatever was collected.
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
#run ⇒ Object
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 |
#wiring ⇒ Object
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 |