Class: Aidp::Init::AgentInstructionsGenerator
- Inherits:
-
Object
- Object
- Aidp::Init::AgentInstructionsGenerator
- Includes:
- MessageDisplay
- Defined in:
- lib/aidp/init/agent_instructions_generator.rb
Overview
Generates agent instruction files for AI coding assistants.
This generator creates a master AGENTS.md file and symlinks it to provider-specific locations (e.g., CLAUDE.md, .github/copilot-instructions.md).
Constant Summary collapse
- MASTER_FILE =
"AGENTS.md"- PROVIDER_CLASSES =
Known provider classes for instruction file generation
%w[ Anthropic GithubCopilot Cursor Gemini Aider Kilocode Opencode Codex ].freeze
Constants included from MessageDisplay
MessageDisplay::COLOR_MAP, MessageDisplay::CRITICAL_TYPES
Instance Method Summary collapse
-
#exists? ⇒ Boolean
Check if master AGENTS.md exists.
-
#generate(analysis:, preferences: {}) ⇒ Array<String>
Generate agent instruction files.
-
#initialize(project_dir = Dir.pwd, prompt: nil) ⇒ AgentInstructionsGenerator
constructor
A new instance of AgentInstructionsGenerator.
-
#preview ⇒ Hash
Preview what files would be generated.
-
#provider_instruction_files ⇒ Array<Hash>
Get all provider instruction file paths.
Methods included from MessageDisplay
#display_message, included, #message_display_prompt, #quiet_mode?
Constructor Details
#initialize(project_dir = Dir.pwd, prompt: nil) ⇒ AgentInstructionsGenerator
Returns a new instance of AgentInstructionsGenerator.
34 35 36 37 |
# File 'lib/aidp/init/agent_instructions_generator.rb', line 34 def initialize(project_dir = Dir.pwd, prompt: nil) @project_dir = project_dir @prompt = prompt end |
Instance Method Details
#exists? ⇒ Boolean
Check if master AGENTS.md exists
78 79 80 |
# File 'lib/aidp/init/agent_instructions_generator.rb', line 78 def exists? File.exist?(File.join(@project_dir, MASTER_FILE)) end |
#generate(analysis:, preferences: {}) ⇒ Array<String>
Generate agent instruction files
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/aidp/init/agent_instructions_generator.rb', line 44 def generate(analysis:, preferences: {}) Aidp.log_debug("agent_instructions_generator", "starting_generation", project_dir: @project_dir) generated_files = [] skipped_files = [] symlinked_files = [] # Generate master AGENTS.md master_path = File.join(@project_dir, MASTER_FILE) if generate_master_file(master_path, analysis, preferences) generated_files << MASTER_FILE end # Create symlinks to provider-specific locations provider_instruction_files.each do |file_info| result = create_provider_symlink(file_info, master_path) case result[:status] when :created symlinked_files << file_info[:path] when :skipped skipped_files << {path: file_info[:path], reason: result[:reason]} end end # Report results report_generation_results(generated_files, symlinked_files, skipped_files) generated_files + symlinked_files end |
#preview ⇒ Hash
Preview what files would be generated
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/aidp/init/agent_instructions_generator.rb', line 92 def preview existing = [] to_create = [] to_symlink = [] master_path = File.join(@project_dir, MASTER_FILE) if File.exist?(master_path) existing << MASTER_FILE else to_create << MASTER_FILE end provider_instruction_files.each do |file_info| full_path = File.join(@project_dir, file_info[:path]) if File.exist?(full_path) || File.symlink?(full_path) existing << file_info[:path] else to_symlink << file_info[:path] end end { existing: existing, to_create: to_create, to_symlink: to_symlink } end |
#provider_instruction_files ⇒ Array<Hash>
Get all provider instruction file paths
85 86 87 |
# File 'lib/aidp/init/agent_instructions_generator.rb', line 85 def provider_instruction_files @provider_instruction_files ||= collect_provider_instruction_files end |