fix: improve file mention suggestions without ripgrep

This commit is contained in:
Federico Jaramillo Martinez
2026-05-31 20:04:59 +02:00
parent 1ae28d8f59
commit fdd2cf2390
12 changed files with 247 additions and 41 deletions
+35 -6
View File
@@ -931,16 +931,44 @@ function runChecks(checks: Check[]): boolean {
const ok = result.status === 0;
failed ||= !ok;
console.log(`${ok ? "✓" : "✗"} ${label}`);
const output = (result.stdout || result.stderr).trim();
if (output !== "") {
const lines = output.split("\n");
for (const line of lines.slice(0, 3)) console.log(` ${line}`);
if (lines.length > 3) console.log(" ...");
}
printCheckOutput(result.stdout || result.stderr);
}
return !failed;
}
function printCheckOutput(output: string): void {
const trimmed = output.trim();
if (trimmed === "") return;
const lines = trimmed.split("\n");
for (const line of lines.slice(0, 3)) console.log(` ${line}`);
if (lines.length > 3) console.log(" ...");
}
function optionalDoctorChecks(): Check[] {
const shell = serviceShellLabel();
const backend = currentServiceBackend();
const checks: Check[] = [[`${shell} can find optional ripgrep (rg)`, serviceShellCommand(commandCheck("rg"))]];
if (backend?.kind === "systemd") checks.push([`systemd user ${shell} can find optional ripgrep (rg)`, systemdUserServiceShellCommand(commandCheck("rg"))]);
return checks;
}
function printOptionalDoctorChecks(): void {
let missingOptionalTool = false;
for (const [label, command] of optionalDoctorChecks()) {
const [bin, ...args] = command;
if (bin === undefined) continue;
const result = capture(bin, args);
const ok = result.status === 0;
missingOptionalTool ||= !ok;
console.log(`${ok ? "✓" : "!"} ${label}`);
printCheckOutput(result.stdout || result.stderr);
}
if (missingOptionalTool) {
console.log(" Install ripgrep, or make rg visible to the service shell, for faster all-file @ suggestions.");
console.log(" PI WEB falls back to a bounded filesystem scan when rg is unavailable.");
}
}
function printPathSetupAdvice(): void {
const shell = detectServiceShell();
console.log("\nPATH setup advice:");
@@ -969,6 +997,7 @@ async function doctor(): Promise<void> {
await printPiWebVersionReport();
console.log("\nDoctor checks:");
const ok = runChecks(doctorChecks());
printOptionalDoctorChecks();
const nodePtySpawnHelperOk = printNodePtyDarwinSpawnHelperCheck();
if (supportsSystemdUserServices()) {