feat(tui): enable @path fuzzy file picker with fd detection

The TUI's CombinedAutocompleteProvider supports @path fuzzy file search
via the fd binary, but it was never enabled because fdPath wasn't passed.

This adds:
- detectFd() function to locate fd/fdfind binary
- Pass fdPath to CombinedAutocompleteProvider

Users with fd installed (brew install fd / apt install fd-find) now get
fuzzy file autocomplete when typing @ in the TUI input.

Inspired by opencode's file picker UX (MIT License).
This commit is contained in:
Sirnii 2026-01-29 14:06:43 +01:00
parent 5f4715acfc
commit 32c49196c3

View File

@ -6,6 +6,33 @@ import {
Text,
TUI,
} from "@mariozechner/pi-tui";
import { spawnSync } from "node:child_process";
/**
* Detect the fd binary for @path fuzzy file picker.
* fd is a fast alternative to `find` that respects .gitignore.
* On some systems (e.g., Ubuntu) it's called 'fdfind'.
*
* @returns Path to fd binary, or undefined if not found
*/
function detectFd(): string | undefined {
for (const name of ["fd", "fdfind"]) {
try {
const result = spawnSync("which", [name], {
encoding: "utf-8",
timeout: 1000,
});
if (result.status === 0 && result.stdout?.trim()) {
return result.stdout.trim();
}
} catch {
// Continue to next candidate
}
}
return undefined;
}
const fdPath = detectFd();
import { resolveDefaultAgentId } from "../agents/agent-scope.js";
import { loadConfig } from "../config/config.js";
import {
@ -251,6 +278,7 @@ export async function runTui(opts: TuiOptions) {
model: sessionInfo.model,
}),
process.cwd(),
fdPath,
),
);
};