Skip to content
Open
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
51 changes: 51 additions & 0 deletions .github/workflows/validation-template.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Validation template

on:
workflow_call:
workflow_dispatch:

permissions:
contents: read

concurrency:
group: validation-template-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
node-quality:
name: Node quality
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5
with:
persist-credentials: false
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
node-version: 22
cache: npm
- name: Install dependencies
run: npm ci --ignore-scripts
- name: Check package formatting and linting
run: npm run check:ci

rust-quality:
name: Rust quality
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5
with:
persist-credentials: false
- name: Install Zig
uses: goto-bus-stop/setup-zig@abea47f85e598557f500fa1fd2ab7464fcb39406 # v2.2.1
with:
version: 0.16.0
- name: Install Rust
uses: actions-rust-lang/setup-rust-toolchain@150fca883cd4034361b621bd4e6a9d34e5143606 # v1.15.4
with:
components: rustfmt, clippy
- name: Check Rust formatting
run: cargo fmt --all -- --check
- name: Run Clippy
run: cargo clippy --no-default-features --features zlob -- -D warnings
2 changes: 1 addition & 1 deletion crates/fff-core/src/index/bigram_filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ impl BigramIndexBuilder {
fn flush_seen(&self, seen: &[u64; SEEN_WORDS], word_idx: usize, bit_mask: u64) {
let col_base = self.col_data_ptr();
let words = self.words;
for (blk, block) in seen.chunks_exact(8).enumerate() {
for (blk, block) in seen.as_chunks::<8>().0.iter().enumerate() {
// OR-test whole blocks so the mostly-empty bitmap scans fast.
if block.iter().fold(0u64, |a, &w| a | w) == 0 {
continue;
Expand Down
15 changes: 14 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions packages/fff-bun/examples/glob-bench.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env bun

/**
* Glob benchmark: fff.glob vs Bun.Glob vs npm `glob`.
*
Expand All @@ -18,8 +19,8 @@
* bun add glob
*/

import { performance } from "node:perf_hooks";
import { resolve } from "node:path";
import { performance } from "node:perf_hooks";
import { Glob as BunGlob } from "bun";
import { FileFinder } from "../src/index";

Expand All @@ -30,7 +31,7 @@ try {
const mod: {
glob: (pattern: string, opts: { cwd: string }) => Promise<string[]>;
} =
// @ts-ignore - optional peer; resolved at runtime, may be absent
// @ts-expect-error - optional peer; resolved at runtime, may be absent
await import("glob");
npmGlob = mod.glob;
} catch {
Expand Down
3 changes: 2 additions & 1 deletion packages/fff-bun/examples/grep.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env bun

/**
* Interactive live grep demo
*
Expand All @@ -9,9 +10,9 @@
* content search prompt with match highlighting.
*/

import * as readline from "node:readline";
import { FileFinder } from "../src/index";
import type { GrepMode } from "../src/types";
import * as readline from "node:readline";

const RESET = "\x1b[0m";
const BOLD = "\x1b[1m";
Expand Down
9 changes: 5 additions & 4 deletions packages/fff-bun/examples/search.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env bun

/**
* Interactive file finder demo
*
Expand All @@ -15,11 +16,11 @@
* :mixed - mixed file + directory search
*/

import { FileFinder } from "../src/index";
import type { DirItem, FileItem, MixedItem, Score } from "../src/index";
import * as readline from "node:readline";
import { join } from "node:path";
import { homedir } from "node:os";
import { join } from "node:path";
import * as readline from "node:readline";
import type { DirItem, FileItem, MixedItem, Score } from "../src/index";
import { FileFinder } from "../src/index";

const RESET = "\x1b[0m";
const BOLD = "\x1b[1m";
Expand Down
2 changes: 1 addition & 1 deletion packages/fff-bun/examples/watch.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bun
import { FileFinder } from "../src/index";
import type { WatchEvent } from "../src/index";
import { FileFinder } from "../src/index";

const KIND = {
created: "+ created ",
Expand Down
15 changes: 3 additions & 12 deletions packages/fff-bun/src/fff-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -573,16 +573,10 @@ export interface FileFinderApi {
glob(pattern: string, options?: GlobOptions): Result<SearchResult>;

/** Fuzzy directory search. */
directorySearch(
query: string,
options?: DirSearchOptions,
): Result<DirSearchResult>;
directorySearch(query: string, options?: DirSearchOptions): Result<DirSearchResult>;

/** Fuzzy search over files and directories interleaved by score. */
mixedSearch(
query: string,
options?: SearchOptions,
): Result<MixedSearchResult>;
mixedSearch(query: string, options?: SearchOptions): Result<MixedSearchResult>;

/** Content search (live grep). */
grep(query: string, options?: GrepOptions): Result<GrepResult>;
Expand Down Expand Up @@ -647,10 +641,7 @@ export interface FileFinderApi {
* Events are debounced and submitted in batches per 100-ms window at most 128 events.
* Gitignored and other ignored files are never triggering watcher.
*/
watch(
callback: WatchBatchCallback,
options?: WatchOptions,
): Result<WatchUnsubscribe>;
watch(callback: WatchBatchCallback, options?: WatchOptions): Result<WatchUnsubscribe>;
watch(
pattern: string,
callback: WatchBatchCallback,
Expand Down
43 changes: 20 additions & 23 deletions packages/fff-bun/src/finder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,26 @@
*/

import { FFIType, JSCallback, type Pointer } from "bun:ffi";

import type {
DirSearchOptions,
DirSearchResult,
InitOptions as FFFInitOptions,
FileFinderApi,
GlobOptions,
GrepOptions,
GrepResult,
HealthCheck,
MixedSearchResult,
MultiGrepOptions,
Result,
ScanProgress,
SearchOptions,
SearchResult,
WatchBatchCallback,
WatchOptions,
WatchUnsubscribe,
} from "./fff-api";
import { err } from "./fff-api";
import {
ensureLoaded,
ffiCreate,
Expand Down Expand Up @@ -38,28 +57,6 @@ import {
readWatchEventBatch,
} from "./ffi";

import type {
DirSearchOptions,
DirSearchResult,
InitOptions as FFFInitOptions,
FileFinderApi,
GlobOptions,
GrepOptions,
GrepResult,
HealthCheck,
MixedSearchResult,
MultiGrepOptions,
Result,
ScanProgress,
SearchOptions,
SearchResult,
WatchBatchCallback,
WatchOptions,
WatchUnsubscribe,
} from "./fff-api";

import { err } from "./fff-api";

/**
* FileFinder - Fast file finder with fuzzy search
*
Expand Down
2 changes: 1 addition & 1 deletion packages/fff-bun/test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { dirname, resolve } from "node:path";
import { FileFinder } from "./src/index";
import { resolve, dirname } from "node:path";

async function main() {
console.log("=== fff Test Script ===\n");
Expand Down
15 changes: 3 additions & 12 deletions packages/fff-node/src/fff-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -573,16 +573,10 @@ export interface FileFinderApi {
glob(pattern: string, options?: GlobOptions): Result<SearchResult>;

/** Fuzzy directory search. */
directorySearch(
query: string,
options?: DirSearchOptions,
): Result<DirSearchResult>;
directorySearch(query: string, options?: DirSearchOptions): Result<DirSearchResult>;

/** Fuzzy search over files and directories interleaved by score. */
mixedSearch(
query: string,
options?: SearchOptions,
): Result<MixedSearchResult>;
mixedSearch(query: string, options?: SearchOptions): Result<MixedSearchResult>;

/** Content search (live grep). */
grep(query: string, options?: GrepOptions): Result<GrepResult>;
Expand Down Expand Up @@ -647,10 +641,7 @@ export interface FileFinderApi {
* Events are debounced and submitted in batches per 100-ms window at most 128 events.
* Gitignored and other ignored files are never triggering watcher.
*/
watch(
callback: WatchBatchCallback,
options?: WatchOptions,
): Result<WatchUnsubscribe>;
watch(callback: WatchBatchCallback, options?: WatchOptions): Result<WatchUnsubscribe>;
watch(
pattern: string,
callback: WatchBatchCallback,
Expand Down
Loading
Loading