Class: Aidp::PromptOptimization::ProjectKnowledgeIndexer

Inherits:
Object
  • Object
show all
Defined in:
lib/aidp/prompt_optimization/project_knowledge_indexer.rb

Overview

Indexes concise feature and tool notes stored under docs/

These notes use inline path markers like <feature_id:lib/file.rb> so they can be found quickly by ripgrep and loaded for matching files.

Constant Summary collapse

KNOWLEDGE_DIRS =
{
  feature: File.join("docs", "features"),
  tool: File.join("docs", "tools")
}.freeze
MARKER_PATTERN =
/<([a-z0-9_]+):([^>\n]+)>/

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(project_dir:) ⇒ ProjectKnowledgeIndexer

Returns a new instance of ProjectKnowledgeIndexer.



19
20
21
22
# File 'lib/aidp/prompt_optimization/project_knowledge_indexer.rb', line 19

def initialize(project_dir:)
  @project_dir = project_dir
  @fragments = []
end

Instance Attribute Details

#fragmentsObject (readonly)

Returns the value of attribute fragments.



17
18
19
# File 'lib/aidp/prompt_optimization/project_knowledge_indexer.rb', line 17

def fragments
  @fragments
end

#project_dirObject (readonly)

Returns the value of attribute project_dir.



17
18
19
# File 'lib/aidp/prompt_optimization/project_knowledge_indexer.rb', line 17

def project_dir
  @project_dir
end

Instance Method Details

#index!Object



24
25
26
27
28
29
30
31
32
# File 'lib/aidp/prompt_optimization/project_knowledge_indexer.rb', line 24

def index!
  @fragments = []

  KNOWLEDGE_DIRS.each do |note_type, relative_dir|
    index_directory(note_type, File.join(project_dir, relative_dir))
  end

  @fragments
end