Class: TheLocal::ProcessDocWriter

Inherits:
Object
  • Object
show all
Defined in:
lib/the_local/process_doc_writer.rb

Overview

Writes the canonical develop-process rules into a host’s CLAUDE.md as a managed block, read at the start of every session so the host agent always follows one source of truth. Re-propagated on every install/refresh. Uses its own markers so it coexists with the delegation trigger in the same file.

Constant Summary collapse

BEGIN_MARKER =
"<!-- the_local:process:begin -->"
END_MARKER =
"<!-- the_local:process:end -->"
RULES_FILENAME =
"develop_process_rules.md"

Instance Method Summary collapse

Constructor Details

#initialize(destination:, filename: "CLAUDE.md") ⇒ ProcessDocWriter

Returns a new instance of ProcessDocWriter.



15
16
17
18
# File 'lib/the_local/process_doc_writer.rb', line 15

def initialize(destination:, filename: "CLAUDE.md")
  @destination = destination
  @filename = filename
end

Instance Method Details

#blockObject



27
28
29
30
31
32
33
34
35
36
# File 'lib/the_local/process_doc_writer.rb', line 27

def block
  <<~MARKDOWN.chomp
    #{BEGIN_MARKER}
    Read and follow this develop process for all work in this project. It is
    also written verbatim to `#{RULES_FILENAME}` — reference that file directly.

    #{ProcessRules.content}
    #{END_MARKER}
  MARKDOWN
end

#callObject



20
21
22
23
24
25
# File 'lib/the_local/process_doc_writer.rb', line 20

def call
  File.write(File.join(@destination, RULES_FILENAME), "#{ProcessRules.content}\n")
  path = File.join(@destination, @filename)
  existing = File.exist?(path) ? File.read(path) : ""
  File.write(path, "#{merge(existing)}\n")
end