Skip to content

Commit cc420b0

Browse files
committed
feat: wire tree-sitter AstSummarizer into summary mode pipeline
Connect the existing AstSummarizer as the preferred backend for --mode=summary, with automatic fallback to the regex-based SummaryExtractor for unsupported languages or empty results. AST-based summaries are now active for Rust, Python, JavaScript, and TypeScript. All other languages continue using regex extraction.
1 parent 4d0c428 commit cc420b0

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

src/processor.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
//! detecting encoding, handling truncation limits, and coordinating with other
55
//! modules for language detection, summarization, and tokenization.
66
7+
use crate::ast_summarizer::AstSummarizer;
78
use crate::config::BatlessConfig;
89
use crate::error::{BatlessError, BatlessResult};
910
use crate::file_info::FileInfo;
@@ -65,11 +66,21 @@ impl FileProcessor {
6566
// Process summary if requested
6667
let summary_level = config.effective_summary_level();
6768
if summary_level.is_enabled() {
68-
let summary_lines = SummaryExtractor::extract_summary(
69-
&lines,
69+
let content = lines.join("\n");
70+
let mut summary_lines = AstSummarizer::extract_summary(
71+
&content,
7072
file_info.language.as_deref(),
7173
summary_level,
7274
);
75+
// Fall back to regex-based summarizer if AST returned nothing
76+
// (unsupported language, parse failure, or empty file)
77+
if summary_lines.is_empty() {
78+
summary_lines = SummaryExtractor::extract_summary(
79+
&lines,
80+
file_info.language.as_deref(),
81+
summary_level,
82+
);
83+
}
7384
// In summary mode, replace the output lines with summary
7485
file_info = file_info
7586
.with_original_lines(Some(lines.clone()))

0 commit comments

Comments
 (0)