Class: TheLocal::Author
- Inherits:
-
Object
- Object
- TheLocal::Author
- Defined in:
- lib/the_local/author.rb
Constant Summary collapse
- FACETS =
%w[info install develop].freeze
- CREATORS =
File.("creators", __dir__)
- ClaudeRunner =
lambda do |prompt, dir| system(*claude_command(prompt), chdir: dir) || raise(Error, "the_local: the creator run failed in #{dir} (is the `claude` CLI installed?)") end
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(gem_root:, runner: ClaudeRunner) ⇒ Author
constructor
A new instance of Author.
- #prompt_for(facet) ⇒ Object
Constructor Details
#initialize(gem_root:, runner: ClaudeRunner) ⇒ Author
Returns a new instance of Author.
20 21 22 23 |
# File 'lib/the_local/author.rb', line 20 def initialize(gem_root:, runner: ClaudeRunner) @gem_root = gem_root @runner = runner end |
Class Method Details
.claude_command(prompt) ⇒ Object
10 11 12 13 |
# File 'lib/the_local/author.rb', line 10 def self.claude_command(prompt) ["claude", "-p", "--allowedTools", "Read,Grep,Write", "--permission-mode", "acceptEdits", "--", prompt] end |
Instance Method Details
#call ⇒ Object
25 26 27 28 |
# File 'lib/the_local/author.rb', line 25 def call require_declared_interface FACETS.each { |facet| @runner.call(prompt_for(facet), @gem_root) } end |
#prompt_for(facet) ⇒ Object
30 31 32 |
# File 'lib/the_local/author.rb', line 30 def prompt_for(facet) File.read(File.join(CREATORS, "#{facet}.md")) end |