Class: Senren::Rails::AgentRulesWriter
- Inherits:
-
Object
- Object
- Senren::Rails::AgentRulesWriter
- Defined in:
- lib/senren/rails/agent_rules_writer.rb
Overview
Generates a single source-of-truth rules file plus adapter files for Copilot, Cursor, Claude, and Codex.
Adapter files are marker-managed to avoid overwriting existing project instructions outside Senren’s generated block.
Constant Summary collapse
- START_MARKER =
'<!-- senren:agent:start -->'- END_MARKER =
'<!-- senren:agent:end -->'
Instance Attribute Summary collapse
-
#paths ⇒ Object
readonly
Returns the value of attribute paths.
-
#registry ⇒ Object
readonly
Returns the value of attribute registry.
Instance Method Summary collapse
-
#initialize(registry: Registry.load!, paths: HostPaths.new) ⇒ AgentRulesWriter
constructor
A new instance of AgentRulesWriter.
- #sync! ⇒ Object
Constructor Details
#initialize(registry: Registry.load!, paths: HostPaths.new) ⇒ AgentRulesWriter
Returns a new instance of AgentRulesWriter.
18 19 20 21 |
# File 'lib/senren/rails/agent_rules_writer.rb', line 18 def initialize(registry: Registry.load!, paths: HostPaths.new) @registry = registry @paths = paths end |
Instance Attribute Details
#paths ⇒ Object (readonly)
Returns the value of attribute paths.
16 17 18 |
# File 'lib/senren/rails/agent_rules_writer.rb', line 16 def paths @paths end |
#registry ⇒ Object (readonly)
Returns the value of attribute registry.
16 17 18 |
# File 'lib/senren/rails/agent_rules_writer.rb', line 16 def registry @registry end |
Instance Method Details
#sync! ⇒ Object
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/senren/rails/agent_rules_writer.rb', line 23 def sync! paths.ensure_agent_dirs! files = [] files << write_full_file(paths.agent_rules_file, render_source_rules) files << write_adapter_file(paths.codex_agents_md, render_codex_adapter) files << write_adapter_file(paths.claude_md, render_claude_adapter) files << write_adapter_file(paths.copilot_instructions, render_copilot_adapter) files << write_adapter_file(paths.cursor_rule_file, render_cursor_adapter, prefix: cursor_frontmatter) files end |