class NoirAIContext::SourceReader

Overview

Reads source files once (cached per path) and extracts the contextual snippets the augmentor attaches to AIContext entries: a fixed-radius window around a line, or a heuristic "route scope" that walks a handler block to its end across brace / Python-indent / Ruby-end styles.

Defined in:

ai_context/source_reader.cr

Constant Summary

MAX_LEAD_DECORATOR_LINES = 4

Maximum number of decorator / annotation lines to capture before path_info.line. Lets negative-protection markers (@csrf_exempt, @PreAuthorize, @CrossOrigin) reach the source-scan even when the analyzer sets path_line to the function def rather than the decorator above it.

MAX_ROUTE_SCOPE_LINES = 12
MAX_SNIPPET_CHARS = 240

Constructors

Instance Method Summary

Constructor Detail

def self.new #

[View source]

Instance Method Detail

def lines_for(path : String | Nil) : Array(String) #

[View source]
def route_scope_snippet_for(path : String | Nil, line : Int32 | Nil) : String | Nil #

[View source]
def snippet_for(path : String | Nil, line : Int32 | Nil, radius : Int32) : String | Nil #

[View source]