Class: LcpRuby::Generators::AgentSetupGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/lcp_ruby/agent_setup_generator.rb

Overview

Sets up agent affordances in a host app: copies/refreshes the bundled ‘lcp-*` Claude Code skills and writes the two thin entrypoint files (`CLAUDE.md` canonical orientation + `AGENTS.md` pointer) at the project root.

Idempotent and non-clobbering: the entrypoint files are written through a delimited ‘<!– lcp:begin –>…<!– lcp:end –>` managed block, so a host’s own ‘CLAUDE.md`/`AGENTS.md` content outside the block is never touched. Auto-invoked by `lcp new` and `lcp_ruby:install`; safe to re-run after `bundle update lcp` to refresh skills and the managed block.

Constant Summary collapse

BEGIN_MARK =
"<!-- lcp:begin -->"
END_MARK =
"<!-- lcp:end -->"

Instance Method Summary collapse

Instance Method Details

#install_skillsObject



26
27
28
29
30
31
32
33
34
# File 'lib/generators/lcp_ruby/agent_setup_generator.rb', line 26

def install_skills
  result = LcpRuby::SkillsInstaller.new(
    target: File.join(destination_root, ".claude", "skills")
  ).call

  result.created.each { |n| say_status :create, ".claude/skills/#{n}", :green }
  result.updated.each { |n| say_status :update, ".claude/skills/#{n}", :yellow }
  result.removed.each { |n| say_status :remove, ".claude/skills/#{n}", :red }
end

#show_post_install_messageObject



44
45
46
47
48
49
50
51
52
# File 'lib/generators/lcp_ruby/agent_setup_generator.rb', line 44

def show_post_install_message
  say ""
  say "LCP agent affordances ready.", :green
  say "  - .claude/skills/lcp-* (authoring skills, auto-trigger in Claude Code)"
  say "  - CLAUDE.md / AGENTS.md (orientation for AI agents)"
  say ""
  say "Re-run after `bundle update lcp` to refresh: rails generate lcp_ruby:agent_setup"
  say ""
end

#write_agents_mdObject



40
41
42
# File 'lib/generators/lcp_ruby/agent_setup_generator.rb', line 40

def write_agents_md
  write_managed_block "AGENTS.md", read_template("agents_md.md")
end

#write_claude_mdObject



36
37
38
# File 'lib/generators/lcp_ruby/agent_setup_generator.rb', line 36

def write_claude_md
  write_managed_block "CLAUDE.md", read_template("claude_md.md")
end