@ff-labs/fff-node 0.1.0-nightly.5809316

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,47 @@
1
+ /**
2
+ * fff - Fast File Finder
3
+ *
4
+ * High-performance fuzzy file finder for Node.js, powered by Rust.
5
+ * Perfect for LLM agent tools that need to search through codebases.
6
+ *
7
+ * Each `FileFinder` instance is backed by an independent native file picker.
8
+ * Create as many as you need and destroy them when done.
9
+ *
10
+ * Uses ffi-rs to load the same native libfff_c binary used by @ff-labs/fff-bun.
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * import { FileFinder } from "@ff-labs/fff-node";
15
+ *
16
+ * // Create a file finder instance
17
+ * const result = FileFinder.create({ basePath: "/path/to/project" });
18
+ * if (!result.ok) {
19
+ * console.error(result.error);
20
+ * process.exit(1);
21
+ * }
22
+ * const finder = result.value;
23
+ *
24
+ * // Wait for initial scan
25
+ * finder.waitForScan(5000);
26
+ *
27
+ * // Search for files
28
+ * const search = finder.fileSearch("main.ts");
29
+ * if (search.ok) {
30
+ * for (const item of search.value.items) {
31
+ * console.log(item.relativePath);
32
+ * }
33
+ * }
34
+ *
35
+ * // Cleanup when done
36
+ * finder.destroy();
37
+ * ```
38
+ *
39
+ * @packageDocumentation
40
+ */
41
+ export { binaryExists, findBinary, } from "./binary.js";
42
+ export { closeLibrary } from "./ffi.js";
43
+ export { FileFinder } from "./finder.js";
44
+ export { getLibExtension, getLibFilename, getNpmPackageName, getTriple, } from "./platform.js";
45
+ export type { DbHealth, FileItem, GrepCursor, GrepMatch, GrepMode, GrepOptions, GrepResult, HealthCheck, InitOptions, Location, MultiGrepOptions, Result, ScanProgress, Score, SearchOptions, SearchResult, } from "./types.js";
46
+ export { err, ok } from "./types.js";
47
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AAEH,OAAO,EACL,YAAY,EACZ,UAAU,GACX,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EACL,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,SAAS,GACV,MAAM,eAAe,CAAC;AAEvB,YAAY,EACV,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,SAAS,EACT,QAAQ,EACR,WAAW,EACX,UAAU,EACV,WAAW,EACX,WAAW,EACX,QAAQ,EACR,gBAAgB,EAChB,MAAM,EACN,YAAY,EACZ,KAAK,EACL,aAAa,EACb,YAAY,GACb,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,YAAY,CAAC"}
@@ -0,0 +1,47 @@
1
+ /**
2
+ * fff - Fast File Finder
3
+ *
4
+ * High-performance fuzzy file finder for Node.js, powered by Rust.
5
+ * Perfect for LLM agent tools that need to search through codebases.
6
+ *
7
+ * Each `FileFinder` instance is backed by an independent native file picker.
8
+ * Create as many as you need and destroy them when done.
9
+ *
10
+ * Uses ffi-rs to load the same native libfff_c binary used by @ff-labs/fff-bun.
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * import { FileFinder } from "@ff-labs/fff-node";
15
+ *
16
+ * // Create a file finder instance
17
+ * const result = FileFinder.create({ basePath: "/path/to/project" });
18
+ * if (!result.ok) {
19
+ * console.error(result.error);
20
+ * process.exit(1);
21
+ * }
22
+ * const finder = result.value;
23
+ *
24
+ * // Wait for initial scan
25
+ * finder.waitForScan(5000);
26
+ *
27
+ * // Search for files
28
+ * const search = finder.fileSearch("main.ts");
29
+ * if (search.ok) {
30
+ * for (const item of search.value.items) {
31
+ * console.log(item.relativePath);
32
+ * }
33
+ * }
34
+ *
35
+ * // Cleanup when done
36
+ * finder.destroy();
37
+ * ```
38
+ *
39
+ * @packageDocumentation
40
+ */
41
+ export { binaryExists, findBinary, } from "./binary.js";
42
+ export { closeLibrary } from "./ffi.js";
43
+ export { FileFinder } from "./finder.js";
44
+ export { getLibExtension, getLibFilename, getNpmPackageName, getTriple, } from "./platform.js";
45
+ // Result helpers
46
+ export { err, ok } from "./types.js";
47
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AAEH,OAAO,EACL,YAAY,EACZ,UAAU,GACX,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EACL,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,SAAS,GACV,MAAM,eAAe,CAAC;AAoBvB,iBAAiB;AACjB,OAAO,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,YAAY,CAAC"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Platform detection utilities for downloading the correct binary
3
+ */
4
+ /**
5
+ * Get the platform triple (e.g., "x86_64-unknown-linux-gnu")
6
+ */
7
+ export declare function getTriple(): string;
8
+ /**
9
+ * Get the library file extension for the current platform
10
+ */
11
+ export declare function getLibExtension(): "dylib" | "so" | "dll";
12
+ /**
13
+ * Get the library filename prefix (empty on Windows)
14
+ */
15
+ export declare function getLibPrefix(): string;
16
+ /**
17
+ * Get the full library filename for the current platform
18
+ */
19
+ export declare function getLibFilename(): string;
20
+ /**
21
+ * Get the npm package name for the current platform's native binary.
22
+ *
23
+ * @returns Package name like "@ff-labs/fff-bin-darwin-arm64"
24
+ * @throws If the current platform is not supported
25
+ */
26
+ export declare function getNpmPackageName(): string;
27
+ //# sourceMappingURL=platform.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"platform.d.ts","sourceRoot":"","sources":["../../src/platform.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH;;GAEG;AACH,wBAAgB,SAAS,IAAI,MAAM,CAiBlC;AAqCD;;GAEG;AACH,wBAAgB,eAAe,IAAI,OAAO,GAAG,IAAI,GAAG,KAAK,CASxD;AAED;;GAEG;AACH,wBAAgB,YAAY,IAAI,MAAM,CAErC;AAED;;GAEG;AACH,wBAAgB,cAAc,IAAI,MAAM,CAIvC;AAkBD;;;;;GAKG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CAO1C"}
@@ -0,0 +1,117 @@
1
+ /**
2
+ * Platform detection utilities for downloading the correct binary
3
+ */
4
+ import { execSync } from "node:child_process";
5
+ /**
6
+ * Get the platform triple (e.g., "x86_64-unknown-linux-gnu")
7
+ */
8
+ export function getTriple() {
9
+ const platform = process.platform;
10
+ const arch = process.arch;
11
+ let osName;
12
+ if (platform === "darwin") {
13
+ osName = "apple-darwin";
14
+ }
15
+ else if (platform === "linux") {
16
+ osName = detectLinuxLibc();
17
+ }
18
+ else if (platform === "win32") {
19
+ osName = "pc-windows-msvc";
20
+ }
21
+ else {
22
+ throw new Error(`Unsupported platform: ${platform}`);
23
+ }
24
+ const archName = normalizeArch(arch);
25
+ return `${archName}-${osName}`;
26
+ }
27
+ /**
28
+ * Detect whether we're on musl or glibc Linux
29
+ */
30
+ function detectLinuxLibc() {
31
+ try {
32
+ const lddOutput = execSync("ldd --version 2>&1", {
33
+ encoding: "utf-8",
34
+ timeout: 5000,
35
+ });
36
+ if (lddOutput.toLowerCase().includes("musl")) {
37
+ return "unknown-linux-musl";
38
+ }
39
+ }
40
+ catch {
41
+ // ldd failed, assume glibc
42
+ }
43
+ return "unknown-linux-gnu";
44
+ }
45
+ /**
46
+ * Normalize architecture name to Rust target format
47
+ */
48
+ function normalizeArch(arch) {
49
+ switch (arch) {
50
+ case "x64":
51
+ case "amd64":
52
+ return "x86_64";
53
+ case "arm64":
54
+ return "aarch64";
55
+ case "arm":
56
+ return "arm";
57
+ default:
58
+ throw new Error(`Unsupported architecture: ${arch}`);
59
+ }
60
+ }
61
+ /**
62
+ * Get the library file extension for the current platform
63
+ */
64
+ export function getLibExtension() {
65
+ switch (process.platform) {
66
+ case "darwin":
67
+ return "dylib";
68
+ case "win32":
69
+ return "dll";
70
+ default:
71
+ return "so";
72
+ }
73
+ }
74
+ /**
75
+ * Get the library filename prefix (empty on Windows)
76
+ */
77
+ export function getLibPrefix() {
78
+ return process.platform === "win32" ? "" : "lib";
79
+ }
80
+ /**
81
+ * Get the full library filename for the current platform
82
+ */
83
+ export function getLibFilename() {
84
+ const prefix = getLibPrefix();
85
+ const ext = getLibExtension();
86
+ return `${prefix}fff_c.${ext}`;
87
+ }
88
+ /**
89
+ * Map from Rust target triple to npm platform package name.
90
+ * The @ff-labs/fff-bin-* packages contain the pre-built libfff_c
91
+ * shared library and are runtime-agnostic (used by both Bun and Node).
92
+ */
93
+ const TRIPLE_TO_NPM_PACKAGE = {
94
+ "aarch64-apple-darwin": "@ff-labs/fff-bin-darwin-arm64",
95
+ "x86_64-apple-darwin": "@ff-labs/fff-bin-darwin-x64",
96
+ "x86_64-unknown-linux-gnu": "@ff-labs/fff-bin-linux-x64-gnu",
97
+ "aarch64-unknown-linux-gnu": "@ff-labs/fff-bin-linux-arm64-gnu",
98
+ "x86_64-unknown-linux-musl": "@ff-labs/fff-bin-linux-x64-musl",
99
+ "aarch64-unknown-linux-musl": "@ff-labs/fff-bin-linux-arm64-musl",
100
+ "x86_64-pc-windows-msvc": "@ff-labs/fff-bin-win32-x64",
101
+ "aarch64-pc-windows-msvc": "@ff-labs/fff-bin-win32-arm64",
102
+ };
103
+ /**
104
+ * Get the npm package name for the current platform's native binary.
105
+ *
106
+ * @returns Package name like "@ff-labs/fff-bin-darwin-arm64"
107
+ * @throws If the current platform is not supported
108
+ */
109
+ export function getNpmPackageName() {
110
+ const triple = getTriple();
111
+ const packageName = TRIPLE_TO_NPM_PACKAGE[triple];
112
+ if (!packageName) {
113
+ throw new Error(`No npm package available for platform: ${triple}`);
114
+ }
115
+ return packageName;
116
+ }
117
+ //# sourceMappingURL=platform.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"platform.js","sourceRoot":"","sources":["../../src/platform.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,430 @@
1
+ /**
2
+ * Result type for all operations - follows the Result pattern
3
+ */
4
+ export type Result<T> = {
5
+ ok: true;
6
+ value: T;
7
+ } | {
8
+ ok: false;
9
+ error: string;
10
+ };
11
+ /**
12
+ * Helper to create a successful result
13
+ */
14
+ export declare function ok<T>(value: T): Result<T>;
15
+ /**
16
+ * Helper to create an error result
17
+ */
18
+ export declare function err<T>(error: string): Result<T>;
19
+ /**
20
+ * Initialization options for the file finder
21
+ */
22
+ export interface InitOptions {
23
+ /** Base directory to index (required) */
24
+ basePath: string;
25
+ /** Path to frecency database (optional, omit to skip frecency initialization) */
26
+ frecencyDbPath?: string;
27
+ /** Path to query history database (optional, omit to skip query tracker initialization) */
28
+ historyDbPath?: string;
29
+ /** Use unsafe no-lock mode for databases (optional, defaults to false) */
30
+ useUnsafeNoLock?: boolean;
31
+ /**
32
+ * Pre-populate mmap caches for all files after the initial scan completes.
33
+ * When enabled, the first grep search will be as fast as subsequent ones
34
+ * at the cost of a longer scan time and higher initial memory usage.
35
+ * (default: false)
36
+ */
37
+ warmupMmapCache?: boolean;
38
+ /** enables optimizations for AI agent assistants. Provide as true if running via mcp/agent */
39
+ aiMode?: boolean;
40
+ }
41
+ /**
42
+ * Search options for fuzzy file search
43
+ */
44
+ export interface SearchOptions {
45
+ /** Maximum threads for parallel search (0 = auto) */
46
+ maxThreads?: number;
47
+ /** Current file path (for deprioritization in results) */
48
+ currentFile?: string;
49
+ /** Combo boost score multiplier (default: 100) */
50
+ comboBoostMultiplier?: number;
51
+ /** Minimum combo count for boost (default: 3) */
52
+ minComboCount?: number;
53
+ /** Page index for pagination (default: 0) */
54
+ pageIndex?: number;
55
+ /** Page size for pagination (default: 100) */
56
+ pageSize?: number;
57
+ }
58
+ /**
59
+ * A file item in search results
60
+ */
61
+ export interface FileItem {
62
+ /** Absolute path to the file */
63
+ path: string;
64
+ /** Path relative to the indexed directory */
65
+ relativePath: string;
66
+ /** File name only */
67
+ fileName: string;
68
+ /** File size in bytes */
69
+ size: number;
70
+ /** Last modified timestamp (Unix seconds) */
71
+ modified: number;
72
+ /** Frecency score based on access patterns */
73
+ accessFrecencyScore: number;
74
+ /** Frecency score based on modification time */
75
+ modificationFrecencyScore: number;
76
+ /** Combined frecency score */
77
+ totalFrecencyScore: number;
78
+ /** Git status: 'clean', 'modified', 'untracked', 'staged_new', etc. */
79
+ gitStatus: string;
80
+ }
81
+ /**
82
+ * Score breakdown for a search result
83
+ */
84
+ export interface Score {
85
+ /** Total combined score */
86
+ total: number;
87
+ /** Base fuzzy match score */
88
+ baseScore: number;
89
+ /** Bonus for filename match */
90
+ filenameBonus: number;
91
+ /** Bonus for special filenames (index.ts, main.rs, etc.) */
92
+ specialFilenameBonus: number;
93
+ /** Boost from frecency */
94
+ frecencyBoost: number;
95
+ /** Penalty for distance in path */
96
+ distancePenalty: number;
97
+ /** Penalty if this is the current file */
98
+ currentFilePenalty: number;
99
+ /** Boost from query history combo matching */
100
+ comboMatchBoost: number;
101
+ /** Whether this was an exact match */
102
+ exactMatch: boolean;
103
+ /** Type of match: 'fuzzy', 'exact', 'prefix', etc. */
104
+ matchType: string;
105
+ }
106
+ /**
107
+ * Location in file (from query like "file.ts:42")
108
+ */
109
+ export type Location = {
110
+ type: "line";
111
+ line: number;
112
+ } | {
113
+ type: "position";
114
+ line: number;
115
+ col: number;
116
+ } | {
117
+ type: "range";
118
+ start: {
119
+ line: number;
120
+ col: number;
121
+ };
122
+ end: {
123
+ line: number;
124
+ col: number;
125
+ };
126
+ };
127
+ /**
128
+ * Search result from fuzzy file search
129
+ */
130
+ export interface SearchResult {
131
+ /** Matched file items */
132
+ items: FileItem[];
133
+ /** Corresponding scores for each item */
134
+ scores: Score[];
135
+ /** Total number of files that matched */
136
+ totalMatched: number;
137
+ /** Total number of indexed files */
138
+ totalFiles: number;
139
+ /** Location parsed from query (e.g., "file.ts:42:10") */
140
+ location?: Location;
141
+ }
142
+ /**
143
+ * Scan progress information
144
+ */
145
+ export interface ScanProgress {
146
+ /** Number of files scanned so far */
147
+ scannedFilesCount: number;
148
+ /** Whether a scan is currently in progress */
149
+ isScanning: boolean;
150
+ }
151
+ /**
152
+ * Database health information
153
+ */
154
+ export interface DbHealth {
155
+ /** Path to the database */
156
+ path: string;
157
+ /** Size of the database on disk in bytes */
158
+ diskSize: number;
159
+ }
160
+ /**
161
+ * Health check result
162
+ */
163
+ export interface HealthCheck {
164
+ /** Library version */
165
+ version: string;
166
+ /** Git integration status */
167
+ git: {
168
+ /** Whether git2 library is available */
169
+ available: boolean;
170
+ /** Whether a git repository was found */
171
+ repositoryFound: boolean;
172
+ /** Git working directory path */
173
+ workdir?: string;
174
+ /** libgit2 version string */
175
+ libgit2Version: string;
176
+ /** Error message if git detection failed */
177
+ error?: string;
178
+ };
179
+ /** File picker status */
180
+ filePicker: {
181
+ /** Whether the file picker is initialized */
182
+ initialized: boolean;
183
+ /** Base path being indexed */
184
+ basePath?: string;
185
+ /** Whether a scan is in progress */
186
+ isScanning?: boolean;
187
+ /** Number of indexed files */
188
+ indexedFiles?: number;
189
+ /** Error message if there's an issue */
190
+ error?: string;
191
+ };
192
+ /** Frecency database status */
193
+ frecency: {
194
+ /** Whether frecency tracking is initialized */
195
+ initialized: boolean;
196
+ /** Database health information */
197
+ dbHealthcheck?: DbHealth;
198
+ /** Error message if there's an issue */
199
+ error?: string;
200
+ };
201
+ /** Query tracker status */
202
+ queryTracker: {
203
+ /** Whether query tracking is initialized */
204
+ initialized: boolean;
205
+ /** Database health information */
206
+ dbHealthcheck?: DbHealth;
207
+ /** Error message if there's an issue */
208
+ error?: string;
209
+ };
210
+ }
211
+ /**
212
+ * Internal: Options format sent to Rust FFI
213
+ * @internal
214
+ */
215
+ export interface InitOptionsInternal {
216
+ base_path: string;
217
+ frecency_db_path?: string;
218
+ history_db_path?: string;
219
+ use_unsafe_no_lock: boolean;
220
+ warmup_mmap_cache: boolean;
221
+ ai_mode: boolean;
222
+ }
223
+ /**
224
+ * Internal: Search options format sent to Rust FFI
225
+ * @internal
226
+ */
227
+ export interface SearchOptionsInternal {
228
+ max_threads?: number;
229
+ current_file?: string;
230
+ combo_boost_multiplier?: number;
231
+ min_combo_count?: number;
232
+ page_index?: number;
233
+ page_size?: number;
234
+ }
235
+ /**
236
+ * Convert public InitOptions to internal format
237
+ * @internal
238
+ */
239
+ export declare function toInternalInitOptions(opts: InitOptions): InitOptionsInternal;
240
+ /**
241
+ * Convert public SearchOptions to internal format
242
+ * @internal
243
+ */
244
+ export declare function toInternalSearchOptions(opts?: SearchOptions): SearchOptionsInternal;
245
+ /**
246
+ * Grep search mode
247
+ */
248
+ export type GrepMode = "plain" | "regex" | "fuzzy";
249
+ /**
250
+ * Opaque pagination cursor for grep results.
251
+ * Pass this to `GrepOptions.cursor` to fetch the next page.
252
+ * Do not construct or modify this — use the `nextCursor` from a previous `GrepResult`.
253
+ */
254
+ export interface GrepCursor {
255
+ /** @internal */
256
+ readonly __brand: "GrepCursor";
257
+ /** @internal */
258
+ readonly _offset: number;
259
+ }
260
+ /**
261
+ * @internal Create a GrepCursor from a raw file offset.
262
+ */
263
+ export declare function createGrepCursor(offset: number): GrepCursor;
264
+ /**
265
+ * Options for live grep (content search)
266
+ *
267
+ * Files are searched sequentially in frecency order (most recently/frequently
268
+ * accessed first). The engine returns a `nextCursor` for fetching the next page.
269
+ */
270
+ export interface GrepOptions {
271
+ /** Maximum file size to search in bytes. Files larger than this are skipped. (default: 10MB) */
272
+ maxFileSize?: number;
273
+ /** Maximum matching lines to collect from a single file (default: 200) */
274
+ maxMatchesPerFile?: number;
275
+ /** Smart case: case-insensitive when the query is all lowercase, case-sensitive otherwise (default: true) */
276
+ smartCase?: boolean;
277
+ /**
278
+ * Pagination cursor from a previous `GrepResult.nextCursor`.
279
+ * Omit (or pass `null`) for the first page.
280
+ */
281
+ cursor?: GrepCursor | null;
282
+ /** Search mode (default: "plain") */
283
+ mode?: GrepMode;
284
+ /**
285
+ * Maximum wall-clock time in milliseconds to spend searching before returning
286
+ * partial results. 0 = unlimited. (default: 0)
287
+ */
288
+ timeBudgetMs?: number;
289
+ /** Number of context lines to include before each match (default: 0) */
290
+ beforeContext?: number;
291
+ /** Number of context lines to include after each match (default: 0) */
292
+ afterContext?: number;
293
+ }
294
+ /**
295
+ * A single grep match with file and line information
296
+ */
297
+ export interface GrepMatch {
298
+ /** Absolute path to the file */
299
+ path: string;
300
+ /** Path relative to the indexed directory */
301
+ relativePath: string;
302
+ /** File name only */
303
+ fileName: string;
304
+ /** Git status */
305
+ gitStatus: string;
306
+ /** File size in bytes */
307
+ size: number;
308
+ /** Last modified timestamp (Unix seconds) */
309
+ modified: number;
310
+ /** Whether the file is binary */
311
+ isBinary: boolean;
312
+ /** Combined frecency score */
313
+ totalFrecencyScore: number;
314
+ /** Access-based frecency score */
315
+ accessFrecencyScore: number;
316
+ /** Modification-based frecency score */
317
+ modificationFrecencyScore: number;
318
+ /** 1-based line number of the match */
319
+ lineNumber: number;
320
+ /** 0-based byte column of first match start */
321
+ col: number;
322
+ /** Absolute byte offset of the matched line from file start */
323
+ byteOffset: number;
324
+ /** The matched line text (may be truncated) */
325
+ lineContent: string;
326
+ /** Byte offset pairs [start, end] within lineContent for highlighting */
327
+ matchRanges: [number, number][];
328
+ /** Fuzzy match score (only in fuzzy mode) */
329
+ fuzzyScore?: number;
330
+ /** Lines before the match (context). Empty array when context is 0. */
331
+ contextBefore?: string[];
332
+ /** Lines after the match (context). Empty array when context is 0. */
333
+ contextAfter?: string[];
334
+ }
335
+ /**
336
+ * Result from a grep search
337
+ */
338
+ export interface GrepResult {
339
+ /** Matched items with file and line information. At most `max_matches_per_file`. */
340
+ items: GrepMatch[];
341
+ /** Total number of matches collected (always equal to items.length). */
342
+ totalMatched: number;
343
+ /** Number of files actually opened and searched in this call */
344
+ totalFilesSearched: number;
345
+ /** Total number of indexed files (before any filtering) */
346
+ totalFiles: number;
347
+ /** Number of files eligible for search after filtering out binary files, oversized files, and constraint mismatches */
348
+ filteredFileCount: number;
349
+ /**
350
+ * Cursor for the next page, or `null` if all eligible files have been searched.
351
+ * Pass this as `GrepOptions.cursor` to continue from where this call left off.
352
+ */
353
+ nextCursor: GrepCursor | null;
354
+ /** When regex mode fails to compile the pattern, the engine falls back to literal matching and this field contains the compilation error */
355
+ regexFallbackError?: string;
356
+ }
357
+ /**
358
+ * Options for multi-pattern grep (Aho-Corasick multi-needle search)
359
+ *
360
+ * Searches for lines matching ANY of the provided patterns using
361
+ * SIMD-accelerated Aho-Corasick multi-pattern matching.
362
+ */
363
+ export interface MultiGrepOptions {
364
+ /** Patterns to search for (OR logic — matches lines containing any pattern) */
365
+ patterns: string[];
366
+ /** File constraints like "*.rs" or "/src/" */
367
+ constraints?: string;
368
+ /** Maximum file size to search in bytes (default: 10MB) */
369
+ maxFileSize?: number;
370
+ /** Maximum matching lines to collect from a single file (default: 0 = unlimited) */
371
+ maxMatchesPerFile?: number;
372
+ /** Smart case: case-insensitive when all patterns are lowercase (default: true) */
373
+ smartCase?: boolean;
374
+ /**
375
+ * Pagination cursor from a previous `GrepResult.nextCursor`.
376
+ * Omit (or pass `null`) for the first page.
377
+ */
378
+ cursor?: GrepCursor | null;
379
+ /**
380
+ * Maximum wall-clock time in milliseconds to spend searching before returning
381
+ * partial results. 0 = unlimited. (default: 0)
382
+ */
383
+ timeBudgetMs?: number;
384
+ /** Number of context lines to include before each match (default: 0) */
385
+ beforeContext?: number;
386
+ /** Number of context lines to include after each match (default: 0) */
387
+ afterContext?: number;
388
+ }
389
+ /**
390
+ * Internal: Multi-grep options format sent to Rust FFI
391
+ * @internal
392
+ */
393
+ export interface MultiGrepOptionsInternal {
394
+ patterns: string[];
395
+ constraints?: string;
396
+ max_file_size?: number;
397
+ max_matches_per_file?: number;
398
+ smart_case?: boolean;
399
+ file_offset?: number;
400
+ page_limit?: number;
401
+ time_budget_ms?: number;
402
+ before_context?: number;
403
+ after_context?: number;
404
+ }
405
+ /**
406
+ * Convert public MultiGrepOptions to internal format
407
+ * @internal
408
+ */
409
+ export declare function toInternalMultiGrepOptions(opts: MultiGrepOptions, pageLimit?: number): MultiGrepOptionsInternal;
410
+ /**
411
+ * Internal: Grep options format sent to Rust FFI
412
+ * @internal
413
+ */
414
+ export interface GrepOptionsInternal {
415
+ max_file_size?: number;
416
+ max_matches_per_file?: number;
417
+ smart_case?: boolean;
418
+ file_offset?: number;
419
+ page_limit?: number;
420
+ mode?: string;
421
+ time_budget_ms?: number;
422
+ before_context?: number;
423
+ after_context?: number;
424
+ }
425
+ /**
426
+ * Convert public GrepOptions to internal format
427
+ * @internal
428
+ */
429
+ export declare function toInternalGrepOptions(opts?: GrepOptions, pageLimit?: number): GrepOptionsInternal;
430
+ //# sourceMappingURL=types.d.ts.map