Class: Senren::Rails::SkillWriter

Inherits:
Object
  • Object
show all
Defined in:
lib/senren/rails/skill_writer.rb

Overview

Writes the centralized .senren/skill.md file for AI agents.

The file contains a generated region delimited by HTML comments:

...generated by SkillWriter...

Anything outside that region is preserved across regeneration.

Constant Summary collapse

START_MARKER =
'<!-- senren:skill:start -->'
END_MARKER =
'<!-- senren:skill:end -->'
GROUP_ORDER =
%w[actions forms overlays navigation layout data saas rich].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(registry: Registry.load!, paths: HostPaths.new) ⇒ SkillWriter

Returns a new instance of SkillWriter.



26
27
28
29
# File 'lib/senren/rails/skill_writer.rb', line 26

def initialize(registry: Registry.load!, paths: HostPaths.new)
  @registry = registry
  @paths    = paths
end

Instance Attribute Details

#pathsObject (readonly)

Returns the value of attribute paths.



24
25
26
# File 'lib/senren/rails/skill_writer.rb', line 24

def paths
  @paths
end

#registryObject (readonly)

Returns the value of attribute registry.



24
25
26
# File 'lib/senren/rails/skill_writer.rb', line 24

def registry
  @registry
end

Instance Method Details

#sync!Object



31
32
33
34
35
36
37
38
39
40
41
# File 'lib/senren/rails/skill_writer.rb', line 31

def sync!
  installed = installed_names
  body = render(installed)

  SafeWrite.mkdir_p!(paths.senren_dir, paths.root, 'skill.md')
  existing = paths.skill_file.exist? ? paths.skill_file.read : default_outer_template

  new_content = inject(existing, body)
  atomic_write(paths.skill_file, new_content)
  paths.skill_file
end