@cmmd-center/forge 0.13.6 → 0.13.7

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.
Files changed (78) hide show
  1. package/dist/{BunHttpServer-DKvSpNd1.cjs → BunHttpServer-C7-1JJ7b.cjs} +4 -4
  2. package/dist/{BunHttpServer-CDh4Vioe.mjs → BunHttpServer-CVPGkizx.mjs} +4 -4
  3. package/dist/{BunServices-D6PAheqS.mjs → BunServices-CPrZSIfE.mjs} +2 -2
  4. package/dist/{BunServices-DDh7Whyx.cjs → BunServices-Dl-3897e.cjs} +2 -2
  5. package/dist/{Cache-BVilO50s.mjs → Cache-C9cwdCDt.mjs} +2 -2
  6. package/dist/{Cache-DCF22Dfk.cjs → Cache-Cf3ARNaS.cjs} +2 -2
  7. package/dist/{HttpServer-ClsGgAq1.mjs → HttpServer-COaBeM7-.mjs} +2 -2
  8. package/dist/{HttpServer-D1gSU7NX.cjs → HttpServer-CggZzScj.cjs} +3 -3
  9. package/dist/{NodeHttpServer-Dfc7nSMq.cjs → NodeHttpServer-Bi339XFk.cjs} +5 -5
  10. package/dist/{NodeHttpServer-DT0TF8s4.mjs → NodeHttpServer-UQnvZnmu.mjs} +5 -5
  11. package/dist/{NodePTY-loxi8Vku.mjs → NodePTY-B1u6RHXk.mjs} +2 -2
  12. package/dist/{NodePTY-S4tPEwZc.cjs → NodePTY-UOaRyQsj.cjs} +2 -2
  13. package/dist/{NodeServices-Cb0rXFb2.cjs → NodeServices-CKFIZVu5.cjs} +2 -2
  14. package/dist/{NodeServices-DE8jhdcU.cjs → NodeServices-R0BZsZ72.cjs} +1 -1
  15. package/dist/{NodeServices-BahzLhbo.mjs → NodeServices-z1Ac4lEO.mjs} +2 -2
  16. package/dist/{NodeSqliteClient-DqFjB3u_.mjs → NodeSqliteClient-BrzqdOsF.mjs} +4 -4
  17. package/dist/{NodeSqliteClient-qjBWAOGq.cjs → NodeSqliteClient-CyJvo9y9.cjs} +4 -4
  18. package/dist/{NodeTerminal-rYbifme7.cjs → NodeTerminal-B89MobLp.cjs} +2 -2
  19. package/dist/{NodeTerminal-BPw7bktz.mjs → NodeTerminal-pYVVRTiD.mjs} +2 -2
  20. package/dist/{Path-CGCc_dDx.cjs → Path-BunGrE8F.cjs} +72 -1
  21. package/dist/{Path-C851t6sC.mjs → Path-evOm-H0Q.mjs} +61 -2
  22. package/dist/{SqlError-CzB6p9lL.cjs → SqlError-1wIMjXAf.cjs} +2 -2
  23. package/dist/{SqlError-3aqibZrj.mjs → SqlError-CezTFGvr.mjs} +2 -2
  24. package/dist/{SqliteClient-DTWCGkrj.mjs → SqliteClient-D3Yd3ZHn.mjs} +3 -3
  25. package/dist/{SqliteClient-Cq1peWN1.cjs → SqliteClient-bo7iui1t.cjs} +3 -3
  26. package/dist/bin.cjs +4818 -3951
  27. package/dist/bin.mjs +4356 -3495
  28. package/dist/client/assets/{CanvasPanel-BwSV27Ct.js → CanvasPanel-C21OO2qi.js} +2 -2
  29. package/dist/client/assets/{CompositeItem-CZk3X-ud.js → CompositeItem-naFGUtSL.js} +2 -2
  30. package/dist/client/assets/{DiffPanel-ixzJ8GwW.js → DiffPanel-D_YC838v.js} +3 -3
  31. package/dist/client/assets/{DiffPanel.logic-D-SDgBF9.js → DiffPanel.logic-Bqk_6nE1.js} +2 -2
  32. package/dist/client/assets/DiffPanelShell-D1KMJc9z.js +2532 -0
  33. package/dist/client/assets/{DiffWorkerPoolProvider-BO_xUE3R.js → DiffWorkerPoolProvider-B5tF5UEc.js} +10 -10
  34. package/dist/client/assets/PullRequestCodePanel-ClD3ZXbi.js +5 -0
  35. package/dist/client/assets/Virtualizer-cvcMb_IQ.js +2 -0
  36. package/dist/client/assets/{canvasStateStore-5DH2Z-PG.js → canvasStateStore-CpNOSHBt.js} +2 -2
  37. package/dist/client/assets/cmmdAuthRedirect-DdH7K490.js +2 -0
  38. package/dist/client/assets/index-BE83u7Db.css +1 -0
  39. package/dist/client/assets/index-yLc4LtMp.js +153 -0
  40. package/dist/client/assets/{popover-Dxp_1Sz0.js → popover-BajtiGgk.js} +2 -2
  41. package/dist/client/assets/src-D6fBWY6U.js +3 -0
  42. package/dist/client/assets/{toggle-B-GE6jq_.js → toggle-BRNCUuRT.js} +2 -2
  43. package/dist/client/index.html +11 -11
  44. package/dist/forge-build.json +1 -1
  45. package/dist/node_modules/@ff-labs/fff-bin-linux-x64-gnu/libfff_c.so +0 -0
  46. package/dist/node_modules/@ff-labs/fff-bin-linux-x64-gnu/package.json +27 -0
  47. package/dist/node_modules/@ff-labs/fff-node/.bun-tag-689ffe3747e13d19 +0 -0
  48. package/dist/node_modules/@ff-labs/fff-node/README.md +126 -0
  49. package/dist/node_modules/@ff-labs/fff-node/dist/src/binary.d.ts +22 -0
  50. package/dist/node_modules/@ff-labs/fff-node/dist/src/binary.js +144 -0
  51. package/dist/node_modules/@ff-labs/fff-node/dist/src/fff-api.d.ts +581 -0
  52. package/dist/node_modules/@ff-labs/fff-node/dist/src/fff-api.js +24 -0
  53. package/dist/node_modules/@ff-labs/fff-node/dist/src/ffi.d.ts +137 -0
  54. package/dist/node_modules/@ff-labs/fff-node/dist/src/ffi.js +1191 -0
  55. package/dist/node_modules/@ff-labs/fff-node/dist/src/finder.d.ts +353 -0
  56. package/dist/node_modules/@ff-labs/fff-node/dist/src/finder.js +488 -0
  57. package/dist/node_modules/@ff-labs/fff-node/dist/src/index.d.ts +47 -0
  58. package/dist/node_modules/@ff-labs/fff-node/dist/src/index.js +47 -0
  59. package/dist/node_modules/@ff-labs/fff-node/dist/src/platform.d.ts +27 -0
  60. package/dist/node_modules/@ff-labs/fff-node/dist/src/platform.js +120 -0
  61. package/dist/node_modules/@ff-labs/fff-node/package.json +76 -0
  62. package/dist/node_modules/@yuuang/ffi-rs-linux-x64-gnu/README.md +794 -0
  63. package/dist/node_modules/@yuuang/ffi-rs-linux-x64-gnu/ffi-rs.linux-x64-gnu.node +0 -0
  64. package/dist/node_modules/@yuuang/ffi-rs-linux-x64-gnu/package.json +21 -0
  65. package/dist/node_modules/ffi-rs/LICENSE +21 -0
  66. package/dist/node_modules/ffi-rs/README.md +794 -0
  67. package/dist/node_modules/ffi-rs/index.d.ts +222 -0
  68. package/dist/node_modules/ffi-rs/index.js +380 -0
  69. package/dist/node_modules/ffi-rs/package.json +76 -0
  70. package/dist/{open-FIgTDosf.mjs → open-D8mGyWmt.mjs} +3 -3
  71. package/package.json +2 -1
  72. package/dist/client/assets/DiffPanelShell-Dz5Wvcvi.js +0 -2532
  73. package/dist/client/assets/PullRequestCodePanel-CW4RK1Oa.js +0 -5
  74. package/dist/client/assets/cmmdAuthRedirect-D68LO-sw.js +0 -2
  75. package/dist/client/assets/diffTargetResolution-WqxwJEax.js +0 -2
  76. package/dist/client/assets/index-DivaIsZ4.css +0 -1
  77. package/dist/client/assets/index-UXWCtM6c.js +0 -153
  78. package/dist/client/assets/src-n5cTLVWV.js +0 -3
@@ -0,0 +1,488 @@
1
+ /**
2
+ * FileFinder - High-level API for the fff file finder
3
+ *
4
+ * This class provides a type-safe, ergonomic API for file finding operations.
5
+ * Each instance owns an independent native file picker that can be created
6
+ * and destroyed independently. Multiple instances can coexist.
7
+ *
8
+ * All methods return Result types for explicit error handling.
9
+ */
10
+ import { ensureLoaded, ffiCreate, ffiDestroy, ffiGetBasePath, ffiGetHistoricalQuery, ffiGetScanProgress, ffiGlob, ffiHealthCheck, ffiIsScanning, ffiLiveGrep, ffiMultiGrep, ffiRefreshGitStatus, ffiRestartIndex, ffiScanFiles, ffiSearch, ffiSearchDirectories, ffiSearchMixed, ffiTrackQuery, ffiWaitForScan, isAvailable, } from "./ffi.js";
11
+ import { err } from "./fff-api.js";
12
+ /**
13
+ * FileFinder - Fast file finder with fuzzy search
14
+ *
15
+ * Each instance is backed by an independent native file picker. Create as many
16
+ * as you need and destroy them when done.
17
+ *
18
+ * @example
19
+ *
20
+ * ```ts
21
+ * import { FileFinder } from "@ff-labs/fff-node";
22
+ *
23
+ * // Create an instance
24
+ * const finder = FileFinder.create({ basePath: "/path/to/project" });
25
+ * if (!finder.ok) {
26
+ * console.error(finder.error);
27
+ * process.exit(1);
28
+ * }
29
+ *
30
+ * // Wait for initial scan
31
+ * await finder.value.waitForScan(5000);
32
+ *
33
+ * // Search for files
34
+ * const search = finder.value.search("main.ts");
35
+ * if (search.ok) {
36
+ * for (const item of search.value.items) {
37
+ * console.log(item.relativePath);
38
+ * }
39
+ * }
40
+ *
41
+ * // Cleanup
42
+ * finder.value.destroy();
43
+ * ```
44
+ */
45
+ export class FileFinder {
46
+ handle;
47
+ constructor(handle) {
48
+ this.handle = handle;
49
+ }
50
+ /**
51
+ * Create a new file finder instance.
52
+ *
53
+ * @param options - Initialization options
54
+ * @returns Result containing the new FileFinder instance or an error
55
+ *
56
+ * @example
57
+ * ```typescript
58
+ * // Basic initialization
59
+ * const finder = FileFinder.create({ basePath: "/path/to/project" });
60
+ *
61
+ * // With custom database paths
62
+ * const finder = FileFinder.create({
63
+ * basePath: "/path/to/project",
64
+ * frecencyDbPath: "/custom/frecency.mdb",
65
+ * historyDbPath: "/custom/history.mdb",
66
+ * });
67
+ * ```
68
+ */
69
+ static create(options) {
70
+ const result = ffiCreate(options.basePath, options.frecencyDbPath ?? "", options.historyDbPath ?? "", options.useUnsafeNoLock ?? false, !(options.disableMmapCache ?? false), !(options.disableContentIndexing ?? options.disableMmapCache ?? false), !(options.disableWatch ?? false), options.aiMode ?? false, options.logFilePath ?? "", options.logLevel ?? "", options.cacheBudgetMaxFiles ?? 0, options.cacheBudgetMaxBytes ?? 0, options.cacheBudgetMaxFileSize ?? 0, options.enableFsRootScanning ?? false, options.enableHomeDirScanning ?? false);
71
+ if (!result.ok) {
72
+ return result;
73
+ }
74
+ return { ok: true, value: new FileFinder(result.value) };
75
+ }
76
+ /**
77
+ * Destroy and clean up all resources.
78
+ *
79
+ * Call this when you're done using the file finder to free memory
80
+ * and stop background file watching. After calling this, the instance
81
+ * must not be used again.
82
+ */
83
+ destroy() {
84
+ if (this.handle !== null) {
85
+ ffiDestroy(this.handle);
86
+ this.handle = null;
87
+ }
88
+ }
89
+ /**
90
+ * Check if this instance has been destroyed.
91
+ */
92
+ get isDestroyed() {
93
+ return this.handle === null;
94
+ }
95
+ /**
96
+ * Guard that returns an error if the instance has been destroyed.
97
+ */
98
+ ensureAlive() {
99
+ if (this.handle === null) {
100
+ return err("FileFinder instance has been destroyed.");
101
+ }
102
+ return { ok: true, value: this.handle };
103
+ }
104
+ /**
105
+ * Search for files matching the query.
106
+ *
107
+ * The query supports fuzzy matching and special syntax:
108
+ * - `foo bar` - Match files containing "foo" and "bar"
109
+ * - `src/` - Match files in src directory
110
+ * - `file.ts:42` - Match file.ts with line 42
111
+ * - `file.ts:42:10` - Match file.ts with line 42, column 10
112
+ *
113
+ * @param query - Search query string
114
+ * @param options - Search options
115
+ * @returns Search results with matched files and scores
116
+ *
117
+ * @example
118
+ * ```typescript
119
+ * const result = finder.search("main.ts", { pageSize: 10 });
120
+ * if (result.ok) {
121
+ * console.log(`Found ${result.value.totalMatched} files`);
122
+ * for (const item of result.value.items) {
123
+ * console.log(item.relativePath);
124
+ * }
125
+ * }
126
+ * ```
127
+ */
128
+ fileSearch(query, options) {
129
+ const guard = this.ensureAlive();
130
+ if (!guard.ok)
131
+ return guard;
132
+ return ffiSearch(guard.value, query, options?.currentFile ?? "", options?.maxThreads ?? 0, options?.pageIndex ?? 0, options?.pageSize ?? 0, options?.comboBoostMultiplier ?? 0, options?.minComboCount ?? 0);
133
+ }
134
+ /**
135
+ * Filters files using glob wildcard expression.
136
+ *
137
+ * The pattern is applied as a single pass SIMD optimized prefiltering
138
+ * without any fuzzy matching involved. Faster and 100% compatible to npm `glob`.
139
+ *
140
+ * @param pattern - Glob pattern (required, non-empty)
141
+ * @param options - Glob search options (pagination, max threads, current file)
142
+ * @returns Search results with files matching the glob
143
+ *
144
+ * @example
145
+ * ```typescript
146
+ * const result = finder.glob("**\/*.rs", { pageSize: 100 });
147
+ * if (result.ok) {
148
+ * for (const item of result.value.items) {
149
+ * console.log(item.relativePath);
150
+ * }
151
+ * }
152
+ * ```
153
+ */
154
+ glob(pattern, options) {
155
+ const guard = this.ensureAlive();
156
+ if (!guard.ok)
157
+ return guard;
158
+ return ffiGlob(guard.value, pattern, options?.currentFile ?? "", options?.maxThreads ?? 0, options?.pageIndex ?? 0, options?.pageSize ?? 0);
159
+ }
160
+ /**
161
+ * Search for directories matching the query.
162
+ *
163
+ * @param query - Search query string
164
+ * @param options - Directory search options
165
+ * @returns Search results with matched directories and scores
166
+ *
167
+ * @example
168
+ * ```typescript
169
+ * const result = finder.directorySearch("src/comp", { pageSize: 10 });
170
+ * if (result.ok) {
171
+ * console.log(`Found ${result.value.totalMatched} directories`);
172
+ * for (const item of result.value.items) {
173
+ * console.log(item.relativePath);
174
+ * }
175
+ * }
176
+ * ```
177
+ */
178
+ directorySearch(query, options) {
179
+ const guard = this.ensureAlive();
180
+ if (!guard.ok)
181
+ return guard;
182
+ return ffiSearchDirectories(guard.value, query, options?.currentFile ?? null, options?.maxThreads ?? 0, options?.pageIndex ?? 0, options?.pageSize ?? 0);
183
+ }
184
+ /**
185
+ * Search for files and directories matching the query (mixed results).
186
+ *
187
+ * Results are interleaved by total score in descending order, mixing
188
+ * both file and directory items.
189
+ *
190
+ * @param query - Search query string
191
+ * @param options - Search options
192
+ * @returns Mixed search results with files and directories interleaved by score
193
+ *
194
+ * @example
195
+ * ```typescript
196
+ * const result = finder.mixedSearch("main", { pageSize: 20 });
197
+ * if (result.ok) {
198
+ * for (const entry of result.value.items) {
199
+ * if (entry.type === "file") {
200
+ * console.log(`File: ${entry.item.relativePath}`);
201
+ * } else {
202
+ * console.log(`Dir: ${entry.item.relativePath}`);
203
+ * }
204
+ * }
205
+ * }
206
+ * ```
207
+ */
208
+ mixedSearch(query, options) {
209
+ const guard = this.ensureAlive();
210
+ if (!guard.ok)
211
+ return guard;
212
+ return ffiSearchMixed(guard.value, query, options?.currentFile ?? "", options?.maxThreads ?? 0, options?.pageIndex ?? 0, options?.pageSize ?? 0, options?.comboBoostMultiplier ?? 0, options?.minComboCount ?? 0);
213
+ }
214
+ /**
215
+ * Search file contents (live grep).
216
+ *
217
+ * Searches through the contents of indexed files using the specified mode:
218
+ * - `"plain"` (default): SIMD-accelerated literal text matching
219
+ * - `"regex"`: Regular expression matching
220
+ * - `"fuzzy"`: Smith-Waterman fuzzy matching per line
221
+ *
222
+ * Supports pagination for large result sets. The result includes a `nextCursor`
223
+ * that can be passed back to fetch the next page.
224
+ *
225
+ * The query also supports constraint syntax:
226
+ * - `*.ts pattern` - Only search in TypeScript files
227
+ * - `src/ pattern` - Only search in the src directory
228
+ *
229
+ * @param query - Search query string
230
+ * @param options - Grep options (mode, pagination, limits)
231
+ * @returns Grep results with matched lines and file metadata
232
+ *
233
+ * @example
234
+ * ```typescript
235
+ * // First page
236
+ * const result = finder.grep("TODO", { mode: "plain" });
237
+ * if (result.ok) {
238
+ * for (const match of result.value.items) {
239
+ * console.log(`${match.relativePath}:${match.lineNumber}: ${match.lineContent}`);
240
+ * }
241
+ * // Fetch next page
242
+ * if (result.value.nextCursor) {
243
+ * const page2 = finder.grep("TODO", {
244
+ * cursor: result.value.nextCursor,
245
+ * });
246
+ * }
247
+ * }
248
+ * ```
249
+ */
250
+ grep(query, options) {
251
+ const guard = this.ensureAlive();
252
+ if (!guard.ok)
253
+ return guard;
254
+ return ffiLiveGrep(guard.value, query, options?.mode ?? "plain", options?.maxFileSize ?? 0, options?.maxMatchesPerFile ?? 0, options?.smartCase ?? true, options?.cursor?._offset ?? 0, options?.pageSize ?? 0, options?.timeBudgetMs ?? 0, options?.beforeContext ?? 0, options?.afterContext ?? 0, options?.classifyDefinitions ?? false);
255
+ }
256
+ /**
257
+ * Multi-pattern OR search using Aho-Corasick.
258
+ *
259
+ * Searches for lines matching ANY of the provided patterns using
260
+ * SIMD-accelerated multi-needle matching. Faster than regex alternation
261
+ * for literal text searches.
262
+ *
263
+ * Supports pagination. The result includes a `nextCursor` that can be
264
+ * passed back to fetch the next page.
265
+ *
266
+ * @param options - Multi-grep options including patterns and optional constraints
267
+ * @returns Grep results with matched lines and file metadata
268
+ *
269
+ * @example
270
+ * ```typescript
271
+ * const result = finder.multiGrep({
272
+ * patterns: ["VideoFrame", "video_frame", "PreloadedImage"],
273
+ * });
274
+ * if (result.ok) {
275
+ * for (const match of result.value.items) {
276
+ * console.log(`${match.relativePath}:${match.lineNumber}: ${match.lineContent}`);
277
+ * }
278
+ * }
279
+ * ```
280
+ */
281
+ multiGrep(options) {
282
+ const guard = this.ensureAlive();
283
+ if (!guard.ok)
284
+ return guard;
285
+ if (!options.patterns || options.patterns.length === 0) {
286
+ return err("patterns array must have at least 1 element");
287
+ }
288
+ return ffiMultiGrep(guard.value, options.patterns.join("\n"), options.constraints ?? "", options.maxFileSize ?? 0, options.maxMatchesPerFile ?? 0, options.smartCase ?? true, options.cursor?._offset ?? 0, options.pageSize ?? 0, options.timeBudgetMs ?? 0, options.beforeContext ?? 0, options.afterContext ?? 0, options.classifyDefinitions ?? false);
289
+ }
290
+ /**
291
+ * Trigger a rescan of the indexed directory.
292
+ *
293
+ * This is useful after major file system changes that the
294
+ * background watcher might have missed.
295
+ */
296
+ scanFiles() {
297
+ const guard = this.ensureAlive();
298
+ if (!guard.ok)
299
+ return guard;
300
+ return ffiScanFiles(guard.value);
301
+ }
302
+ /**
303
+ * Check if a scan is currently in progress.
304
+ */
305
+ isScanning() {
306
+ if (this.handle === null)
307
+ return false;
308
+ return ffiIsScanning(this.handle);
309
+ }
310
+ /**
311
+ * Get the base path of the file picker (the root directory being indexed).
312
+ */
313
+ getBasePath() {
314
+ const guard = this.ensureAlive();
315
+ if (!guard.ok)
316
+ return guard;
317
+ return ffiGetBasePath(guard.value);
318
+ }
319
+ /**
320
+ * Get the current scan progress.
321
+ */
322
+ getScanProgress() {
323
+ const guard = this.ensureAlive();
324
+ if (!guard.ok)
325
+ return guard;
326
+ return ffiGetScanProgress(guard.value);
327
+ }
328
+ /**
329
+ * Wait for the initial file scan to complete.
330
+ * Non-blocking: polls `isScanning` and yields to the event loop between checks.
331
+ *
332
+ * @param timeoutMs - Maximum time to wait in milliseconds (default: 5000)
333
+ * @returns true if scan completed, false if timed out
334
+ *
335
+ * @example
336
+ * ```typescript
337
+ * const finder = FileFinder.create({ basePath: "/path/to/project" });
338
+ * if (finder.ok) {
339
+ * const completed = await finder.value.waitForScan(10000);
340
+ * if (!completed.ok || !completed.value) {
341
+ * console.warn("Scan did not complete in time");
342
+ * }
343
+ * }
344
+ * ```
345
+ */
346
+ async waitForScan(timeoutMs = 5000) {
347
+ const guard = this.ensureAlive();
348
+ if (!guard.ok)
349
+ return guard;
350
+ const deadline = Date.now() + timeoutMs;
351
+ while (this.isScanning()) {
352
+ if (Date.now() >= deadline) {
353
+ return { ok: true, value: false };
354
+ }
355
+ await new Promise((resolve) => setTimeout(resolve, 50));
356
+ }
357
+ return { ok: true, value: true };
358
+ }
359
+ /**
360
+ * Wait for the initial file scan to complete, blocking the calling thread.
361
+ *
362
+ * Backed by the native `fff_wait_for_scan` call. Prefer {@link waitForScan}
363
+ * unless you specifically need synchronous blocking behaviour.
364
+ *
365
+ * @param timeoutMs - Maximum time to wait in milliseconds (default: 5000)
366
+ * @returns true if scan completed, false if timed out
367
+ */
368
+ waitForScanBlocking(timeoutMs = 5000) {
369
+ const guard = this.ensureAlive();
370
+ if (!guard.ok)
371
+ return guard;
372
+ return ffiWaitForScan(guard.value, timeoutMs);
373
+ }
374
+ /**
375
+ * Wait until the index is fully ready: the scan has finished and the warmup
376
+ * (content indexing / bigram) phase has completed.
377
+ *
378
+ * Non-blocking: polls `getScanProgress` and yields to the event loop.
379
+ *
380
+ * @param timeoutMs - Maximum time to wait in milliseconds (default: 5000)
381
+ * @returns true if the index became ready, false if timed out
382
+ */
383
+ async waitForIndexReady(timeoutMs = 5000) {
384
+ const guard = this.ensureAlive();
385
+ if (!guard.ok)
386
+ return guard;
387
+ const deadline = Date.now() + timeoutMs;
388
+ while (true) {
389
+ const progress = this.getScanProgress();
390
+ if (!progress.ok)
391
+ return progress;
392
+ if (!progress.value.isScanning && progress.value.isWarmupComplete) {
393
+ return { ok: true, value: true };
394
+ }
395
+ if (Date.now() >= deadline) {
396
+ return { ok: true, value: false };
397
+ }
398
+ await new Promise((resolve) => setTimeout(resolve, 50));
399
+ }
400
+ }
401
+ /**
402
+ * Change the indexed directory to a new path.
403
+ *
404
+ * This stops the current file watcher and starts indexing the new directory.
405
+ *
406
+ * @param newPath - New directory path to index
407
+ */
408
+ reindex(newPath) {
409
+ const guard = this.ensureAlive();
410
+ if (!guard.ok)
411
+ return guard;
412
+ return ffiRestartIndex(guard.value, newPath);
413
+ }
414
+ /**
415
+ * Refresh the git status cache.
416
+ *
417
+ * @returns Number of files with updated git status
418
+ */
419
+ refreshGitStatus() {
420
+ const guard = this.ensureAlive();
421
+ if (!guard.ok)
422
+ return guard;
423
+ return ffiRefreshGitStatus(guard.value);
424
+ }
425
+ /**
426
+ * Track query completion for smart suggestions.
427
+ *
428
+ * Call this when a user selects a file from search results.
429
+ * This helps improve future search rankings for similar queries.
430
+ *
431
+ * @param query - The search query that was used
432
+ * @param selectedFilePath - The file path that was selected
433
+ */
434
+ trackQuery(query, selectedFilePath) {
435
+ const guard = this.ensureAlive();
436
+ if (!guard.ok)
437
+ return guard;
438
+ return ffiTrackQuery(guard.value, query, selectedFilePath);
439
+ }
440
+ /**
441
+ * Get a historical query by offset.
442
+ *
443
+ * @param offset - Offset from most recent (0 = most recent)
444
+ * @returns The historical query string, or null if not found
445
+ */
446
+ getHistoricalQuery(offset) {
447
+ const guard = this.ensureAlive();
448
+ if (!guard.ok)
449
+ return guard;
450
+ return ffiGetHistoricalQuery(guard.value, offset);
451
+ }
452
+ /**
453
+ * Get health check information.
454
+ *
455
+ * Useful for debugging and verifying the file finder is working correctly.
456
+ *
457
+ * @param testPath - Optional path to test git repository detection
458
+ */
459
+ healthCheck(testPath) {
460
+ return ffiHealthCheck(this.handle, testPath || "");
461
+ }
462
+ /**
463
+ * Check if the native library is available.
464
+ */
465
+ static isAvailable() {
466
+ return isAvailable();
467
+ }
468
+ /**
469
+ * Ensure the native library is loaded.
470
+ *
471
+ * Loads the native library from the platform-specific npm package
472
+ * or a local dev build. Throws if the binary is not found.
473
+ */
474
+ static ensureLoaded() {
475
+ ensureLoaded();
476
+ }
477
+ /**
478
+ * Get a health check without requiring an instance.
479
+ *
480
+ * Returns limited info (version + git only, no picker/frecency/query data).
481
+ *
482
+ * @param testPath - Optional path to test git repository detection
483
+ */
484
+ static healthCheckStatic(testPath) {
485
+ return ffiHealthCheck(null, testPath || "");
486
+ }
487
+ }
488
+ //# sourceMappingURL=finder.js.map
@@ -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
+ * await 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 type { DbHealth, DirItem, DirSearchOptions, DirSearchResult, FileFinderApi, FileItem, GrepCursor, GrepMatch, GrepMode, GrepOptions, GrepResult, HealthCheck, InitOptions, Location, MixedItem, MixedSearchResult, MultiGrepOptions, Result, ScanProgress, Score, SearchOptions, SearchResult, } from "./fff-api.js";
44
+ export { err, ok } from "./fff-api.js";
45
+ export { FileFinder } from "./finder.js";
46
+ export { getLibExtension, getLibFilename, getNpmPackageName, getTriple, } from "./platform.js";
47
+ //# sourceMappingURL=index.d.ts.map
@@ -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
+ * await 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
+ // Result helpers
44
+ export { err, ok } from "./fff-api.js";
45
+ export { FileFinder } from "./finder.js";
46
+ export { getLibExtension, getLibFilename, getNpmPackageName, getTriple, } from "./platform.js";
47
+ //# sourceMappingURL=index.js.map
@@ -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