@ff-labs/fff-bun 0.1.0-nightly.fcdf4a9 → 0.2.4-nightly.124ead8

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.
package/README.md CHANGED
@@ -16,20 +16,20 @@ High-performance fuzzy file finder for Bun, powered by Rust. Perfect for LLM age
16
16
  bun add @ff-labs/bun
17
17
  ```
18
18
 
19
- The correct native binary for your platform is installed automatically via platform-specific packages (e.g. `@ff-labs/fff-bun-darwin-arm64`, `@ff-labs/fff-bun-linux-x64-gnu`). No GitHub downloads are needed.
19
+ The correct native binary for your platform is installed automatically via platform-specific packages (e.g. `@ff-labs/fff-bin-darwin-arm64`, `@ff-labs/fff-bin-linux-x64-gnu`). No GitHub downloads are needed.
20
20
 
21
21
  ### Supported Platforms
22
22
 
23
23
  | Platform | Architecture | Package |
24
24
  |----------|-------------|---------|
25
- | macOS | ARM64 (Apple Silicon) | `@ff-labs/fff-bun-darwin-arm64` |
26
- | macOS | x64 (Intel) | `@ff-labs/fff-bun-darwin-x64` |
27
- | Linux | x64 (glibc) | `@ff-labs/fff-bun-linux-x64-gnu` |
28
- | Linux | ARM64 (glibc) | `@ff-labs/fff-bun-linux-arm64-gnu` |
29
- | Linux | x64 (musl) | `@ff-labs/fff-bun-linux-x64-musl` |
30
- | Linux | ARM64 (musl) | `@ff-labs/fff-bun-linux-arm64-musl` |
31
- | Windows | x64 | `@ff-labs/fff-bun-win32-x64` |
32
- | Windows | ARM64 | `@ff-labs/fff-bun-win32-arm64` |
25
+ | macOS | ARM64 (Apple Silicon) | `@ff-labs/fff-bin-darwin-arm64` |
26
+ | macOS | x64 (Intel) | `@ff-labs/fff-bin-darwin-x64` |
27
+ | Linux | x64 (glibc) | `@ff-labs/fff-bin-linux-x64-gnu` |
28
+ | Linux | ARM64 (glibc) | `@ff-labs/fff-bin-linux-arm64-gnu` |
29
+ | Linux | x64 (musl) | `@ff-labs/fff-bin-linux-x64-musl` |
30
+ | Linux | ARM64 (musl) | `@ff-labs/fff-bin-linux-arm64-musl` |
31
+ | Windows | x64 | `@ff-labs/fff-bin-win32-x64` |
32
+ | Windows | ARM64 | `@ff-labs/fff-bin-win32-arm64` |
33
33
 
34
34
  If the platform package isn't available, the postinstall script will attempt to download from GitHub releases as a fallback.
35
35
 
@@ -113,7 +113,7 @@ Track file access for frecency scoring.
113
113
  FileFinder.trackAccess("/path/to/file.ts");
114
114
  ```
115
115
 
116
- ### `FileFinder.liveGrep(query, options?)`
116
+ ### `FileFinder.grep(query, options?)`
117
117
 
118
118
  Search file contents with SIMD-accelerated matching.
119
119
 
@@ -129,7 +129,7 @@ interface GrepOptions {
129
129
  }
130
130
 
131
131
  // Plain text search
132
- const result = FileFinder.liveGrep("TODO", { pageLimit: 20 });
132
+ const result = FileFinder.grep("TODO", { pageLimit: 20 });
133
133
  if (result.ok) {
134
134
  for (const match of result.value.items) {
135
135
  console.log(`${match.relativePath}:${match.lineNumber}: ${match.lineContent}`);
@@ -137,22 +137,22 @@ if (result.ok) {
137
137
  }
138
138
 
139
139
  // Regex search
140
- const regexResult = FileFinder.liveGrep("fn\\s+\\w+", { mode: "regex" });
140
+ const regexResult = FileFinder.grep("fn\\s+\\w+", { mode: "regex" });
141
141
 
142
142
  // Fuzzy search
143
- const fuzzyResult = FileFinder.liveGrep("imprt recat", { mode: "fuzzy" });
143
+ const fuzzyResult = FileFinder.grep("imprt recat", { mode: "fuzzy" });
144
144
 
145
145
  // Pagination
146
- const page1 = FileFinder.liveGrep("error");
146
+ const page1 = FileFinder.grep("error");
147
147
  if (page1.ok && page1.value.nextCursor) {
148
- const page2 = FileFinder.liveGrep("error", {
148
+ const page2 = FileFinder.grep("error", {
149
149
  cursor: page1.value.nextCursor,
150
150
  });
151
151
  }
152
152
 
153
153
  // With file constraints
154
- const tsOnly = FileFinder.liveGrep("*.ts useState");
155
- const srcOnly = FileFinder.liveGrep("src/ handleClick");
154
+ const tsOnly = FileFinder.grep("*.ts useState");
155
+ const srcOnly = FileFinder.grep("src/ handleClick");
156
156
  ```
157
157
 
158
158
  ### `FileFinder.trackQuery(query, selectedFile)`
@@ -178,7 +178,7 @@ if (health.ok) {
178
178
 
179
179
  ### Other Methods
180
180
 
181
- - `FileFinder.liveGrep(query, options?)` - Search file contents
181
+ - `FileFinder.grep(query, options?)` - Search file contents
182
182
  - `FileFinder.scanFiles()` - Trigger rescan
183
183
  - `FileFinder.isScanning()` - Check scan status
184
184
  - `FileFinder.getScanProgress()` - Get scan progress
package/examples/grep.ts CHANGED
@@ -190,7 +190,7 @@ async function main() {
190
190
  }
191
191
 
192
192
  const searchStart = Date.now();
193
- const result = finder.liveGrep(query, {
193
+ const result = finder.grep(query, {
194
194
  mode: currentMode,
195
195
  pageLimit: 30,
196
196
  timeBudgetMs: 5000,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ff-labs/fff-bun",
3
- "version": "0.1.0-nightly.fcdf4a9",
3
+ "version": "0.2.4-nightly.124ead8",
4
4
  "private": false,
5
5
  "description": "High-performance fuzzy file finder for Bun - perfect for LLM agent tools",
6
6
  "type": "module",
@@ -13,19 +13,14 @@
13
13
  }
14
14
  },
15
15
  "bin": {
16
- "fff": "./scripts/cli.ts",
17
16
  "fff-demo": "./examples/search.ts",
18
17
  "fff-grep": "./examples/grep.ts"
19
18
  },
20
19
  "files": [
21
20
  "src",
22
- "bin",
23
- "scripts",
24
21
  "examples"
25
22
  ],
26
23
  "scripts": {
27
- "postinstall": "bun ./scripts/postinstall.ts",
28
- "download": "bun ./scripts/cli.ts download",
29
24
  "test": "bun test src/",
30
25
  "typecheck": "tsc --noEmit",
31
26
  "demo": "bun ./examples/search.ts"
@@ -67,14 +62,14 @@
67
62
  },
68
63
  "homepage": "https://github.com/dmtrKovalenko/fff.nvim#readme",
69
64
  "optionalDependencies": {
70
- "@ff-labs/fff-bun-darwin-arm64": "0.1.0-nightly.fcdf4a9",
71
- "@ff-labs/fff-bun-darwin-x64": "0.1.0-nightly.fcdf4a9",
72
- "@ff-labs/fff-bun-linux-x64-gnu": "0.1.0-nightly.fcdf4a9",
73
- "@ff-labs/fff-bun-linux-arm64-gnu": "0.1.0-nightly.fcdf4a9",
74
- "@ff-labs/fff-bun-linux-x64-musl": "0.1.0-nightly.fcdf4a9",
75
- "@ff-labs/fff-bun-linux-arm64-musl": "0.1.0-nightly.fcdf4a9",
76
- "@ff-labs/fff-bun-win32-x64": "0.1.0-nightly.fcdf4a9",
77
- "@ff-labs/fff-bun-win32-arm64": "0.1.0-nightly.fcdf4a9"
65
+ "@ff-labs/fff-bin-darwin-arm64": "0.2.4-nightly.124ead8",
66
+ "@ff-labs/fff-bin-darwin-x64": "0.2.4-nightly.124ead8",
67
+ "@ff-labs/fff-bin-linux-x64-gnu": "0.2.4-nightly.124ead8",
68
+ "@ff-labs/fff-bin-linux-arm64-gnu": "0.2.4-nightly.124ead8",
69
+ "@ff-labs/fff-bin-linux-x64-musl": "0.2.4-nightly.124ead8",
70
+ "@ff-labs/fff-bin-linux-arm64-musl": "0.2.4-nightly.124ead8",
71
+ "@ff-labs/fff-bin-win32-x64": "0.2.4-nightly.124ead8",
72
+ "@ff-labs/fff-bin-win32-arm64": "0.2.4-nightly.124ead8"
78
73
  },
79
74
  "devDependencies": {
80
75
  "@types/bun": "^1.3.8",
package/src/download.ts CHANGED
@@ -1,25 +1,16 @@
1
1
  /**
2
2
  * Binary resolution utilities for fff
3
3
  *
4
- * Resolves the native binary from:
5
- * 1. Platform-specific npm package (e.g. @ff-labs/fff-bun-darwin-arm64) - primary
6
- * 2. Local bin/ directory (legacy or manual download)
7
- * 3. Local dev build (target/release or target/debug)
8
- * 4. GitHub releases (fallback, requires network)
4
+ * Resolves the native library from:
5
+ * 1. Platform-specific npm package (e.g. @ff-labs/fff-bin-darwin-arm64)
6
+ * 2. Local dev build (target/release or target/debug)
9
7
  */
10
8
 
11
- import { chmodSync, existsSync, mkdirSync, writeFileSync } from "node:fs";
9
+ import { existsSync } from "node:fs";
12
10
  import { createRequire } from "node:module";
13
11
  import { dirname, join } from "node:path";
14
12
  import { fileURLToPath } from "node:url";
15
- import {
16
- getLibExtension,
17
- getLibFilename,
18
- getNpmPackageName,
19
- getTriple,
20
- } from "./platform";
21
-
22
- const GITHUB_REPO = "dmtrKovalenko/fff.nvim";
13
+ import { getLibFilename, getNpmPackageName } from "./platform";
23
14
 
24
15
  /**
25
16
  * Get the current file's directory
@@ -47,21 +38,6 @@ function getPackageDir(): string {
47
38
  return dirname(currentDir);
48
39
  }
49
40
 
50
- /**
51
- * Get the directory where binaries are stored (legacy/fallback)
52
- */
53
- export function getBinDir(): string {
54
- return join(getPackageDir(), "bin");
55
- }
56
-
57
- /**
58
- * Get the full path to the native library in bin/ (legacy/fallback)
59
- */
60
- export function getBinaryPath(): string {
61
- const binDir = getBinDir();
62
- return join(binDir, getLibFilename());
63
- }
64
-
65
41
  /**
66
42
  * Check if the binary exists in any known location
67
43
  */
@@ -72,8 +48,8 @@ export function binaryExists(): boolean {
72
48
  /**
73
49
  * Try to resolve the binary from the platform-specific npm package.
74
50
  *
75
- * When users install @ff-labs/bun, npm/bun automatically installs the matching
76
- * optionalDependency (e.g. @ff-labs/fff-bun-darwin-arm64). We resolve the binary
51
+ * When users install @ff-labs/fff-bun, npm/bun automatically installs the matching
52
+ * optionalDependency (e.g. @ff-labs/fff-bin-darwin-arm64). We resolve the binary
77
53
  * path by requiring that package's package.json and looking for the binary
78
54
  * in the same directory.
79
55
  */
@@ -101,7 +77,7 @@ function resolveFromNpmPackage(): string | null {
101
77
  /**
102
78
  * Get the development binary path (for local development)
103
79
  */
104
- export function getDevBinaryPath(): string | null {
80
+ function getDevBinaryPath(): string | null {
105
81
  const packageDir = getPackageDir();
106
82
  const workspaceRoot = join(packageDir, "..", "..");
107
83
 
@@ -125,11 +101,20 @@ function isDevWorkspace(): boolean {
125
101
  return existsSync(join(workspaceRoot, "Cargo.toml"));
126
102
  }
127
103
 
104
+ /**
105
+ * Find the native library binary.
106
+ *
107
+ * Resolution order:
108
+ * - Dev workspace: local dev build first, then npm package
109
+ * - Production: npm package first, then dev build
110
+ *
111
+ * @returns Absolute path to the library, or null if not found
112
+ */
128
113
  export function findBinary(): string | null {
129
114
  if (isDevWorkspace()) {
130
115
  // 1. Local bin/ directory (populated by `make prepare-bun`)
131
- const installedPath = getBinaryPath();
132
- if (existsSync(installedPath)) return installedPath;
116
+ const binPath = join(getPackageDir(), "bin", getLibFilename());
117
+ if (existsSync(binPath)) return binPath;
133
118
 
134
119
  // 2. Local dev build (target/release or target/debug)
135
120
  const devPath = getDevBinaryPath();
@@ -143,117 +128,9 @@ export function findBinary(): string | null {
143
128
  }
144
129
 
145
130
  // Production: npm package first
146
- // 1. Try platform-specific npm package first
147
131
  const npmPath = resolveFromNpmPackage();
148
132
  if (npmPath) return npmPath;
149
133
 
150
- // 2. Try local bin/ directory (legacy or manual download)
151
- const installedPath = getBinaryPath();
152
- if (existsSync(installedPath)) return installedPath;
153
-
154
- // 3. Try local dev build
134
+ // Fallback: local dev build (e.g. user built from source)
155
135
  return getDevBinaryPath();
156
136
  }
157
-
158
- /**
159
- * Download the binary from GitHub releases as a fallback.
160
- * This is only used when the platform npm package is not available.
161
- *
162
- * @param tag - The release tag to download (e.g. commit hash), or "latest"
163
- */
164
- export async function downloadBinary(tag?: string): Promise<string> {
165
- const resolvedTag = tag || "latest";
166
- const triple = getTriple();
167
- const ext = getLibExtension();
168
-
169
- // Resolve "latest" tag via GitHub API
170
- let releaseTag = resolvedTag;
171
- if (releaseTag === "latest") {
172
- console.log("fff: Fetching latest release tag from GitHub...");
173
- releaseTag = await fetchLatestReleaseTag();
174
- }
175
-
176
- const binaryName = `c-lib-${triple}.${ext}`;
177
- const baseUrl = `https://github.com/${GITHUB_REPO}/releases/download/${releaseTag}`;
178
- const binaryUrl = `${baseUrl}/${binaryName}`;
179
-
180
- console.log(`fff: Downloading native library for ${triple}...`);
181
- console.log(`fff: Release: ${releaseTag}`);
182
-
183
- const binaryResponse = await fetch(binaryUrl);
184
- if (!binaryResponse.ok) {
185
- throw new Error(
186
- `Failed to download binary: ${binaryResponse.status} ${binaryResponse.statusText}\nURL: ${binaryUrl}`,
187
- );
188
- }
189
-
190
- const binaryBuffer = Buffer.from(await binaryResponse.arrayBuffer());
191
-
192
- const binDir = getBinDir();
193
- if (!existsSync(binDir)) {
194
- mkdirSync(binDir, { recursive: true });
195
- }
196
-
197
- const binaryPath = getBinaryPath();
198
- writeFileSync(binaryPath, binaryBuffer);
199
-
200
- // Make executable on Unix
201
- if (process.platform !== "win32") {
202
- chmodSync(binaryPath, 0o755);
203
- }
204
-
205
- console.log(`fff: Binary downloaded to ${binaryPath}`);
206
- return releaseTag;
207
- }
208
-
209
- /**
210
- * Fetch the latest release tag from GitHub
211
- */
212
- async function fetchLatestReleaseTag(): Promise<string> {
213
- const url = `https://api.github.com/repos/${GITHUB_REPO}/releases/latest`;
214
-
215
- const response = await fetch(url, {
216
- headers: {
217
- Accept: "application/vnd.github.v3+json",
218
- "User-Agent": "fff-bun-client",
219
- },
220
- });
221
-
222
- if (!response.ok) {
223
- const allReleasesUrl = `https://api.github.com/repos/${GITHUB_REPO}/releases`;
224
- const allResponse = await fetch(allReleasesUrl, {
225
- headers: {
226
- Accept: "application/vnd.github.v3+json",
227
- "User-Agent": "fff-bun-client",
228
- },
229
- });
230
-
231
- if (!allResponse.ok) {
232
- throw new Error(`Failed to fetch releases: ${allResponse.status}`);
233
- }
234
-
235
- const releases = (await allResponse.json()) as Array<{ tag_name: string }>;
236
- if (releases.length === 0) {
237
- throw new Error("No releases found");
238
- }
239
-
240
- return releases[0].tag_name;
241
- }
242
-
243
- const release = (await response.json()) as { tag_name: string };
244
- return release.tag_name;
245
- }
246
-
247
- /**
248
- * Ensure the binary exists, downloading from GitHub if necessary.
249
- */
250
- export async function ensureBinary(): Promise<string> {
251
- const existingPath = findBinary();
252
- if (existingPath) {
253
- return existingPath;
254
- }
255
-
256
- // Fallback: download from GitHub
257
- await downloadBinary();
258
- return getBinaryPath();
259
- }
package/src/ffi.ts CHANGED
@@ -9,7 +9,7 @@
9
9
  */
10
10
 
11
11
  import { CString, dlopen, FFIType, type Pointer, ptr, read } from "bun:ffi";
12
- import { ensureBinary, findBinary } from "./download";
12
+ import { findBinary } from "./download";
13
13
  import type { Result } from "./types";
14
14
  import { err } from "./types";
15
15
 
@@ -112,7 +112,7 @@ function loadLibrary(): FFFLibrary {
112
112
  const binaryPath = findBinary();
113
113
  if (!binaryPath) {
114
114
  throw new Error(
115
- "fff native library not found. Run `bunx fff download` or build from source with `cargo build --release -p fff-c`",
115
+ "fff native library not found. Build from source with `cargo build --release -p fff-c` or install the platform package.",
116
116
  );
117
117
  }
118
118
 
@@ -417,10 +417,12 @@ export function ffiMultiGrep(handle: NativeHandle, optsJson: string): Result<unk
417
417
  }
418
418
 
419
419
  /**
420
- * Ensure the library is loaded (for preloading).
420
+ * Ensure the library is loaded.
421
+ *
422
+ * Loads the native library from the platform-specific npm package
423
+ * or a local dev build. Throws if the binary is not found.
421
424
  */
422
- export async function ensureLoaded(): Promise<void> {
423
- await ensureBinary();
425
+ export function ensureLoaded(): void {
424
426
  loadLibrary();
425
427
  }
426
428
 
package/src/finder.ts CHANGED
@@ -49,25 +49,6 @@ import {
49
49
  toInternalSearchOptions,
50
50
  } from "./types";
51
51
 
52
- /** Transform raw FFI grep result into typed GrepResult with opaque cursor. */
53
- function transformGrepResult(result: Result<unknown>): Result<GrepResult> {
54
- if (!result.ok) {
55
- return result;
56
- }
57
- const raw = result.value as Record<string, unknown>;
58
- const nextFileOffset = raw.nextFileOffset as number;
59
- const grepResult: GrepResult = {
60
- items: raw.items as GrepResult["items"],
61
- totalMatched: raw.totalMatched as number,
62
- totalFilesSearched: raw.totalFilesSearched as number,
63
- totalFiles: raw.totalFiles as number,
64
- filteredFileCount: raw.filteredFileCount as number,
65
- nextCursor: nextFileOffset > 0 ? createGrepCursor(nextFileOffset) : null,
66
- regexFallbackError: raw.regexFallbackError as string | undefined,
67
- };
68
- return { ok: true, value: grepResult };
69
- }
70
-
71
52
  /**
72
53
  * FileFinder - Fast file finder with fuzzy search
73
54
  *
@@ -192,7 +173,7 @@ export class FileFinder {
192
173
  * }
193
174
  * ```
194
175
  */
195
- search(query: string, options?: SearchOptions): Result<SearchResult> {
176
+ fileSearch(query: string, options?: SearchOptions): Result<SearchResult> {
196
177
  const guard = this.ensureAlive();
197
178
  if (!guard.ok) return guard;
198
179
 
@@ -228,21 +209,21 @@ export class FileFinder {
228
209
  * @example
229
210
  * ```typescript
230
211
  * // First page
231
- * const result = finder.liveGrep("TODO", { mode: "plain" });
212
+ * const result = finder.grep("TODO", { mode: "plain" });
232
213
  * if (result.ok) {
233
214
  * for (const match of result.value.items) {
234
215
  * console.log(`${match.relativePath}:${match.lineNumber}: ${match.lineContent}`);
235
216
  * }
236
217
  * // Fetch next page
237
218
  * if (result.value.nextCursor) {
238
- * const page2 = finder.liveGrep("TODO", {
219
+ * const page2 = finder.grep("TODO", {
239
220
  * cursor: result.value.nextCursor,
240
221
  * });
241
222
  * }
242
223
  * }
243
224
  * ```
244
225
  */
245
- liveGrep(query: string, options?: GrepOptions): Result<GrepResult> {
226
+ grep(query: string, options?: GrepOptions): Result<GrepResult> {
246
227
  const guard = this.ensureAlive();
247
228
  if (!guard.ok) return guard;
248
229
 
@@ -412,14 +393,9 @@ export class FileFinder {
412
393
  return isAvailable();
413
394
  }
414
395
 
415
- /**
416
- * Ensure the native library is loaded.
417
- *
418
- * This will download the binary if needed and load it.
419
- * Useful for preloading before first use.
420
- */
421
- static async ensureLoaded(): Promise<void> {
422
- return ensureLoaded();
396
+ /** Ensure the native library is loaded. */
397
+ static ensureLoaded(): void {
398
+ ensureLoaded();
423
399
  }
424
400
 
425
401
  /**
@@ -433,3 +409,21 @@ export class FileFinder {
433
409
  return ffiHealthCheck(null, testPath || "") as Result<HealthCheck>;
434
410
  }
435
411
  }
412
+
413
+ function transformGrepResult(result: Result<unknown>): Result<GrepResult> {
414
+ if (!result.ok) {
415
+ return result;
416
+ }
417
+ const raw = result.value as Record<string, unknown>;
418
+ const nextFileOffset = raw.nextFileOffset as number;
419
+ const grepResult: GrepResult = {
420
+ items: raw.items as GrepResult["items"],
421
+ totalMatched: raw.totalMatched as number,
422
+ totalFilesSearched: raw.totalFilesSearched as number,
423
+ totalFiles: raw.totalFiles as number,
424
+ filteredFileCount: raw.filteredFileCount as number,
425
+ nextCursor: nextFileOffset > 0 ? createGrepCursor(nextFileOffset) : null,
426
+ regexFallbackError: raw.regexFallbackError as string | undefined,
427
+ };
428
+ return { ok: true, value: grepResult };
429
+ }
@@ -51,7 +51,7 @@ function sleep(ms: number) {
51
51
  }
52
52
 
53
53
  function findFile(finder: FileFinder, name: string): FileItem | undefined {
54
- const result = finder.search(name, { pageSize: 200 });
54
+ const result = finder.fileSearch(name, { pageSize: 200 });
55
55
  if (!result.ok) throw new Error(`search failed: ${result.error}`);
56
56
  return result.value.items.find((item) => item.fileName === name);
57
57
  }
@@ -99,15 +99,15 @@ async function waitForFileGone(finder: FileFinder, name: string): Promise<boolea
99
99
  async function waitForFileCount(finder: FileFinder, count: number): Promise<number> {
100
100
  const start = Date.now();
101
101
  while (Date.now() - start < WATCHER_TIMEOUT_MS) {
102
- const result = finder.search("", { pageSize: 200 });
102
+ const result = finder.fileSearch("", { pageSize: 200 });
103
103
  if (result.ok && result.value.totalFiles === count) return count;
104
104
  await sleep(POLL_INTERVAL_MS);
105
105
  }
106
- const result = finder.search("", { pageSize: 200 });
106
+ const result = finder.fileSearch("", { pageSize: 200 });
107
107
  return result.ok ? result.value.totalFiles : -1;
108
108
  }
109
109
 
110
- /** Poll liveGrep until predicate on totalMatched is satisfied, or the timeout is exceeded. */
110
+ /** Poll grep until predicate on totalMatched is satisfied, or the timeout is exceeded. */
111
111
  async function waitForGrep(
112
112
  finder: FileFinder,
113
113
  pattern: string,
@@ -116,11 +116,11 @@ async function waitForGrep(
116
116
  ) {
117
117
  const start = Date.now();
118
118
  while (Date.now() - start < WATCHER_TIMEOUT_MS) {
119
- const result = finder.liveGrep(pattern, options);
119
+ const result = finder.grep(pattern, options);
120
120
  if (result.ok && predicate(result.value.totalMatched)) return result;
121
121
  await sleep(POLL_INTERVAL_MS);
122
122
  }
123
- return finder.liveGrep(pattern, options);
123
+ return finder.grep(pattern, options);
124
124
  }
125
125
 
126
126
  describe.skipIf(process.platform === "win32")("Git lifecycle integration", () => {
@@ -161,7 +161,7 @@ describe.skipIf(process.platform === "win32")("Git lifecycle integration", () =>
161
161
  });
162
162
 
163
163
  test("initial scan indexes all committed files", () => {
164
- const result = finder.search("", { pageSize: 200 });
164
+ const result = finder.fileSearch("", { pageSize: 200 });
165
165
  expect(result.ok).toBe(true);
166
166
  if (!result.ok) return;
167
167
 
package/src/index.test.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { afterAll, beforeAll, describe, expect, test } from "bun:test";
2
- import { findBinary, getDevBinaryPath } from "./download";
2
+ import { findBinary } from "./download";
3
3
  import { FileFinder } from "./index";
4
4
  import { getLibExtension, getLibFilename, getTriple } from "./platform";
5
5
 
@@ -46,14 +46,6 @@ describe("Platform Detection", () => {
46
46
  });
47
47
 
48
48
  describe("Binary Detection", () => {
49
- test("getDevBinaryPath finds local build", () => {
50
- const devPath = getDevBinaryPath();
51
- expect(devPath).not.toBeNull();
52
- // Normalize path for cross-platform comparison (Windows uses backslashes)
53
- const normalizedPath = normalizePath(devPath);
54
- expect(normalizedPath).toContain("target/release");
55
- });
56
-
57
49
  test("findBinary returns a path", () => {
58
50
  const path = findBinary();
59
51
  expect(path).not.toBeNull();
@@ -120,7 +112,7 @@ describe("FileFinder - Full Lifecycle", () => {
120
112
  if (progress.ok) {
121
113
  }
122
114
 
123
- const result = finder.search("");
115
+ const result = finder.fileSearch("");
124
116
  expect(result.ok).toBe(true);
125
117
 
126
118
  if (result.ok) {
@@ -140,7 +132,7 @@ describe("FileFinder - Full Lifecycle", () => {
140
132
  });
141
133
 
142
134
  test("search returns a valid result structure", () => {
143
- const result = finder.search("Cargo.toml");
135
+ const result = finder.fileSearch("Cargo.toml");
144
136
  expect(result.ok).toBe(true);
145
137
 
146
138
  if (result.ok) {
@@ -152,7 +144,7 @@ describe("FileFinder - Full Lifecycle", () => {
152
144
  });
153
145
 
154
146
  test("search returns empty for non-matching query", () => {
155
- const result = finder.search("xyznonexistentfilenamexyz123456");
147
+ const result = finder.fileSearch("xyznonexistentfilenamexyz123456");
156
148
  expect(result.ok).toBe(true);
157
149
 
158
150
  if (result.ok) {
@@ -162,7 +154,7 @@ describe("FileFinder - Full Lifecycle", () => {
162
154
  });
163
155
 
164
156
  test("search respects pageSize option", () => {
165
- const result = finder.search("ts", { pageSize: 3 });
157
+ const result = finder.fileSearch("ts", { pageSize: 3 });
166
158
  expect(result.ok).toBe(true);
167
159
 
168
160
  if (result.ok) {
@@ -170,8 +162,8 @@ describe("FileFinder - Full Lifecycle", () => {
170
162
  }
171
163
  });
172
164
 
173
- test("liveGrep plain text returns matching lines", () => {
174
- const result = finder.liveGrep("fff-core", {
165
+ test("grep plain text returns matching lines", () => {
166
+ const result = finder.grep("fff-core", {
175
167
  mode: "plain",
176
168
  });
177
169
  expect(result.ok).toBe(true);
@@ -205,9 +197,9 @@ describe("FileFinder - Full Lifecycle", () => {
205
197
  }
206
198
  });
207
199
 
208
- test("liveGrep fuzzy mode returns results with scores", () => {
200
+ test("grep fuzzy mode returns results with scores", () => {
209
201
  // Intentional typo: "depdnency" instead of "dependency" to exercise fuzzy matching
210
- const result = finder.liveGrep("depdnency", {
202
+ const result = finder.grep("depdnency", {
211
203
  mode: "fuzzy",
212
204
  });
213
205
  expect(result.ok).toBe(true);
@@ -273,8 +265,8 @@ describe("FileFinder - Full Lifecycle", () => {
273
265
  const finder2 = result2.value;
274
266
 
275
267
  // Both should work independently
276
- const search1 = finder.search("Cargo");
277
- const search2 = finder2.search("Cargo");
268
+ const search1 = finder.fileSearch("Cargo");
269
+ const search2 = finder2.fileSearch("Cargo");
278
270
 
279
271
  expect(search1.ok).toBe(true);
280
272
  expect(search2.ok).toBe(true);
@@ -282,7 +274,7 @@ describe("FileFinder - Full Lifecycle", () => {
282
274
  // Destroying one should not affect the other
283
275
  finder2.destroy();
284
276
 
285
- const search3 = finder.search("Cargo");
277
+ const search3 = finder.fileSearch("Cargo");
286
278
  expect(search3.ok).toBe(true);
287
279
  }
288
280
  });
@@ -297,7 +289,7 @@ describe("FileFinder - Error Handling", () => {
297
289
  const f = createResult.value;
298
290
  f.destroy();
299
291
 
300
- const result = f.search("test");
292
+ const result = f.fileSearch("test");
301
293
  expect(result.ok).toBe(false);
302
294
  if (!result.ok) {
303
295
  expect(result.error).toContain("destroyed");
package/src/index.ts CHANGED
@@ -23,7 +23,7 @@
23
23
  * finder.waitForScan(5000);
24
24
  *
25
25
  * // Search for files
26
- * const search = finder.search("main.ts");
26
+ * const search = finder.fileSearch("main.ts");
27
27
  * if (search.ok) {
28
28
  * for (const item of search.value.items) {
29
29
  * console.log(item.relativePath);
@@ -37,15 +37,11 @@
37
37
  * @packageDocumentation
38
38
  */
39
39
 
40
- export { FileFinder } from "./finder";
41
-
42
40
  export {
43
41
  binaryExists,
44
- downloadBinary,
45
- ensureBinary,
46
42
  findBinary,
47
- getBinaryPath,
48
43
  } from "./download";
44
+ export { FileFinder } from "./finder";
49
45
 
50
46
  export {
51
47
  getLibExtension,
package/src/platform.ts CHANGED
@@ -95,20 +95,20 @@ export function getLibFilename(): string {
95
95
  * Map from Rust target triple to npm platform package name
96
96
  */
97
97
  const TRIPLE_TO_NPM_PACKAGE: Record<string, string> = {
98
- "aarch64-apple-darwin": "@ff-labs/fff-bun-darwin-arm64",
99
- "x86_64-apple-darwin": "@ff-labs/fff-bun-darwin-x64",
100
- "x86_64-unknown-linux-gnu": "@ff-labs/fff-bun-linux-x64-gnu",
101
- "aarch64-unknown-linux-gnu": "@ff-labs/fff-bun-linux-arm64-gnu",
102
- "x86_64-unknown-linux-musl": "@ff-labs/fff-bun-linux-x64-musl",
103
- "aarch64-unknown-linux-musl": "@ff-labs/fff-bun-linux-arm64-musl",
104
- "x86_64-pc-windows-msvc": "@ff-labs/fff-bun-win32-x64",
105
- "aarch64-pc-windows-msvc": "@ff-labs/fff-bun-win32-arm64",
98
+ "aarch64-apple-darwin": "@ff-labs/fff-bin-darwin-arm64",
99
+ "x86_64-apple-darwin": "@ff-labs/fff-bin-darwin-x64",
100
+ "x86_64-unknown-linux-gnu": "@ff-labs/fff-bin-linux-x64-gnu",
101
+ "aarch64-unknown-linux-gnu": "@ff-labs/fff-bin-linux-arm64-gnu",
102
+ "x86_64-unknown-linux-musl": "@ff-labs/fff-bin-linux-x64-musl",
103
+ "aarch64-unknown-linux-musl": "@ff-labs/fff-bin-linux-arm64-musl",
104
+ "x86_64-pc-windows-msvc": "@ff-labs/fff-bin-win32-x64",
105
+ "aarch64-pc-windows-msvc": "@ff-labs/fff-bin-win32-arm64",
106
106
  };
107
107
 
108
108
  /**
109
109
  * Get the npm package name for the current platform's native binary.
110
110
  *
111
- * @returns Package name like "@ff-labs/fff-bun-darwin-arm64"
111
+ * @returns Package name like "@ff-labs/fff-bin-darwin-arm64"
112
112
  * @throws If the current platform is not supported
113
113
  */
114
114
  export function getNpmPackageName(): string {
Binary file
package/scripts/cli.ts DELETED
@@ -1,116 +0,0 @@
1
- #!/usr/bin/env bun
2
- /**
3
- * CLI tool for fff package management
4
- *
5
- * Usage:
6
- * bunx fff download [tag] - Download native binary from GitHub
7
- * bunx fff info - Show platform and binary info
8
- */
9
-
10
- import { downloadBinary, getBinaryPath, findBinary } from "../src/download";
11
- import {
12
- getTriple,
13
- getLibExtension,
14
- getLibFilename,
15
- getNpmPackageName,
16
- } from "../src/platform";
17
- import { dirname, join } from "node:path";
18
- import { fileURLToPath } from "node:url";
19
-
20
- const args = process.argv.slice(2);
21
- const command = args[0];
22
-
23
- interface PackageJson {
24
- version: string;
25
- }
26
-
27
- async function getPackageInfo(): Promise<PackageJson> {
28
- const currentDir = dirname(fileURLToPath(import.meta.url));
29
- const packageJsonPath = join(currentDir, "..", "package.json");
30
-
31
- try {
32
- return await Bun.file(packageJsonPath).json();
33
- } catch {
34
- return { version: "unknown" };
35
- }
36
- }
37
-
38
- async function main() {
39
- switch (command) {
40
- case "download": {
41
- const tag = args[1];
42
- console.log("fff: Downloading native library from GitHub...");
43
- try {
44
- const resolvedTag = await downloadBinary(tag);
45
- console.log(`fff: Download complete! (${resolvedTag})`);
46
- } catch (error) {
47
- console.error("fff: Download failed:", error);
48
- process.exit(1);
49
- }
50
- break;
51
- }
52
-
53
- case "info": {
54
- const pkg = await getPackageInfo();
55
- let npmPackage: string;
56
- try {
57
- npmPackage = getNpmPackageName();
58
- } catch {
59
- npmPackage = "unsupported";
60
- }
61
-
62
- console.log("fff - Fast File Finder");
63
- console.log(`Package version: ${pkg.version}`);
64
- console.log("");
65
- console.log("Platform Information:");
66
- console.log(` Triple: ${getTriple()}`);
67
- console.log(` Extension: ${getLibExtension()}`);
68
- console.log(` Library name: ${getLibFilename()}`);
69
- console.log(` npm package: ${npmPackage}`);
70
- console.log("");
71
- console.log("Binary Status:");
72
- const existing = findBinary();
73
- if (existing) {
74
- console.log(` Found: ${existing}`);
75
- } else {
76
- console.log(` Not found`);
77
- console.log(` Expected path: ${getBinaryPath()}`);
78
- console.log(` Try: bun add ${npmPackage}`);
79
- }
80
- break;
81
- }
82
-
83
- case "version":
84
- case "--version":
85
- case "-v": {
86
- const pkg = await getPackageInfo();
87
- console.log(pkg.version);
88
- break;
89
- }
90
-
91
- default: {
92
- const pkg = await getPackageInfo();
93
- console.log(`fff - Fast File Finder CLI v${pkg.version}`);
94
- console.log("");
95
- console.log("Usage:");
96
- console.log(
97
- " bunx fff download [tag] Download native binary from GitHub (fallback)",
98
- );
99
- console.log(" bunx fff info Show platform and binary info");
100
- console.log(" bunx fff version Show version");
101
- console.log(" bunx fff help Show this help message");
102
- console.log("");
103
- console.log("Examples:");
104
- console.log(" bunx fff download Download latest binary from GitHub");
105
- console.log(" bunx fff download abc1234 Download specific release tag");
106
- console.log("");
107
- console.log(
108
- "Note: Binaries are normally provided via platform-specific npm packages.",
109
- );
110
- console.log("The download command is a fallback for when those aren't available.");
111
- break;
112
- }
113
- }
114
- }
115
-
116
- main();
@@ -1,49 +0,0 @@
1
- #!/usr/bin/env bun
2
- /**
3
- * Postinstall script - ensures the native binary is available
4
- *
5
- * Resolution order:
6
- * 1. Platform-specific npm package (installed via optionalDependencies)
7
- * 2. Local dev build (target/release or target/debug)
8
- * 3. Fallback: download from GitHub releases
9
- */
10
-
11
- import { findBinary, downloadBinary } from "../src/download";
12
- import { getNpmPackageName } from "../src/platform";
13
-
14
- async function main() {
15
- // Check if binary is already available (npm package or dev build)
16
- const existing = findBinary();
17
- if (existing) {
18
- console.log(`fff: Native library found at ${existing}`);
19
- return;
20
- }
21
-
22
- // Binary not found via npm package - try downloading from GitHub as fallback
23
- let packageName: string;
24
- try {
25
- packageName = getNpmPackageName();
26
- } catch {
27
- packageName = "unknown";
28
- }
29
-
30
- console.log(
31
- `fff: Platform package ${packageName} not found, falling back to GitHub download...`,
32
- );
33
-
34
- try {
35
- const tag = await downloadBinary();
36
- console.log(`fff: Native library installed successfully! (${tag})`);
37
- } catch (error) {
38
- console.error("fff: Failed to download native library:", error);
39
- console.error("");
40
- console.error("fff: You can build from source instead:");
41
- console.error(" cargo build --release -p fff-c");
42
- console.error("");
43
- console.error("fff: Or run `bunx fff download` after fixing network issues.");
44
- // Don't exit with error - allow install to complete
45
- // The error will surface when the user tries to use the library
46
- }
47
- }
48
-
49
- main();