Module: Legion::Extensions::Coldstart::Runners::Ingest
- Includes:
- Helpers::Lex
- Defined in:
- lib/legion/extensions/coldstart/runners/ingest.rb
Instance Method Summary collapse
-
#ingest_directory(dir_path:, pattern: '**/{CLAUDE,MEMORY}.md', store_traces: true) ⇒ Hash
Ingest all CLAUDE.md and MEMORY.md files under a directory.
-
#ingest_file(file_path:, store_traces: true) ⇒ Hash
Ingest a single Claude memory or CLAUDE.md file into agentic memory traces.
-
#preview_ingest(file_path:) ⇒ Hash
Preview what traces would be created from a file without storing them.
Instance Method Details
#ingest_directory(dir_path:, pattern: '**/{CLAUDE,MEMORY}.md', store_traces: true) ⇒ Hash
Ingest all CLAUDE.md and MEMORY.md files under a directory.
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/legion/extensions/coldstart/runners/ingest.rb', line 44 def ingest_directory(dir_path:, pattern: '**/{CLAUDE,MEMORY}.md', store_traces: true, **) unless Dir.exist?(dir_path) log.warn "[coldstart:ingest] directory not found: #{dir_path}" return { directory: dir_path, error: 'directory not found' } end candidates = Helpers::ClaudeParser.parse_directory(dir_path, pattern: pattern) files = candidates.map { |c| c[:source_file] }.uniq log.info "[coldstart:ingest] parsed #{candidates.size} traces from #{files.size} files in #{dir_path}" stored = store_traces ? store_candidates(candidates) : [] { directory: dir_path, files_found: files.size, total_parsed: candidates.size, total_stored: stored.size, files: files } end |
#ingest_file(file_path:, store_traces: true) ⇒ Hash
Ingest a single Claude memory or CLAUDE.md file into agentic memory traces. If lex-agentic-memory is not loaded, returns the parsed traces without storing.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/legion/extensions/coldstart/runners/ingest.rb', line 17 def ingest_file(file_path:, store_traces: true, **) unless File.exist?(file_path) log.warn "[coldstart:ingest] file not found: #{file_path}" return { file: file_path, error: 'file not found' } end candidates = Helpers::ClaudeParser.parse_file(file_path) file_type = Helpers::ClaudeParser.detect_file_type(file_path) log.info "[coldstart:ingest] parsed #{candidates.size} traces from #{file_path} (#{file_type})" stored = store_traces ? store_candidates(candidates) : [] { file: file_path, file_type: file_type, traces_parsed: candidates.size, traces_stored: stored.size, traces: stored.empty? ? candidates : stored } end |
#preview_ingest(file_path:) ⇒ Hash
Preview what traces would be created from a file without storing them.
69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/legion/extensions/coldstart/runners/ingest.rb', line 69 def preview_ingest(file_path:, **) return { file: file_path, error: 'file not found' } unless File.exist?(file_path) candidates = Helpers::ClaudeParser.parse_file(file_path) file_type = Helpers::ClaudeParser.detect_file_type(file_path) { file: file_path, file_type: file_type, traces: candidates } end |