Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ Changing provider, model, dimensions, or embedding strategy can make an existing
| `maxDepth` | `5` | Directory traversal depth; `-1` is unlimited |
| `maxFilesPerDirectory` | `100` | Per-directory file cap |
| `fallbackToTextOnMaxChunks` | `true` | Fall back to line chunks when the semantic cap is reached |
| `linesPerChunk` | `30` | Max lines per chunk for line-based parsing (`.jsonl`, `.txt`, unknown extensions, and the AST fallback). Lower it for finer-grained retrieval on line-delimited files. Only the line-based path is affected; AST-parsed languages are unchanged |
| `gitBlame.enabled` | `false` | Store git blame metadata for filtering |

Example:
Expand Down
41 changes: 34 additions & 7 deletions native/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,47 @@ pub use parser::*;
pub use store::*;
pub use types::*;

/// Default lines-per-chunk window used when a napi caller omits the argument
/// (undefined -> None). The config layer always supplies a value, so this only
/// covers direct native callers and tests. Must stay in sync with
/// `getDefaultIndexingConfig().linesPerChunk` in src/config/defaults.ts.
const DEFAULT_LINES_PER_CHUNK: u32 = 30;

#[napi]
pub fn parse_file(file_path: String, content: String) -> Result<Vec<CodeChunk>> {
parser::parse_file_internal(&file_path, &content).map_err(|e| Error::from_reason(e.to_string()))
pub fn parse_file(
file_path: String,
content: String,
lines_per_chunk: Option<u32>,
) -> Result<Vec<CodeChunk>> {
parser::parse_file_internal(
&file_path,
&content,
lines_per_chunk.unwrap_or(DEFAULT_LINES_PER_CHUNK) as usize,
)
.map_err(|e| Error::from_reason(e.to_string()))
}

#[napi]
pub fn parse_file_as_text(file_path: String, content: String) -> Result<Vec<CodeChunk>> {
parser::parse_file_as_text_internal(&file_path, &content)
.map_err(|e| Error::from_reason(e.to_string()))
pub fn parse_file_as_text(
file_path: String,
content: String,
lines_per_chunk: Option<u32>,
) -> Result<Vec<CodeChunk>> {
parser::parse_file_as_text_internal(
&file_path,
&content,
lines_per_chunk.unwrap_or(DEFAULT_LINES_PER_CHUNK) as usize,
)
.map_err(|e| Error::from_reason(e.to_string()))
}

#[napi]
pub fn parse_files(files: Vec<FileInput>) -> Result<Vec<ParsedFile>> {
parser::parse_files_parallel(files).map_err(|e| Error::from_reason(e.to_string()))
pub fn parse_files(files: Vec<FileInput>, lines_per_chunk: Option<u32>) -> Result<Vec<ParsedFile>> {
parser::parse_files_parallel(
files,
lines_per_chunk.unwrap_or(DEFAULT_LINES_PER_CHUNK) as usize,
)
.map_err(|e| Error::from_reason(e.to_string()))
}

#[napi]
Expand Down
Loading