@ff-labs/pi-fff 0.9.4 → 0.9.5-nightly.5f7661a

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
@@ -134,6 +134,7 @@ Mode precedence:
134
134
  - `--fff-mode <mode>` — set mode (see above)
135
135
  - `--fff-frecency-db <path>` — path to frecency database (also: `FFF_FRECENCY_DB` env)
136
136
  - `--fff-history-db <path>` — path to query history database (also: `FFF_HISTORY_DB` env)
137
+ - `--fff-enable-root-scan` — allow indexing when launched from `/` (also: `FFF_ENABLE_ROOT_SCAN=1` env). FFF refuses to init at the filesystem root by default. Home directory scanning is always enabled for pi.
137
138
 
138
139
  ## Data
139
140
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ff-labs/pi-fff",
3
3
  "public": true,
4
- "version": "0.9.4",
4
+ "version": "0.9.5-nightly.5f7661a",
5
5
  "description": "pi extension: FFF-powered fuzzy file and content search",
6
6
  "type": "module",
7
7
  "license": "MIT",
package/src/index.ts CHANGED
@@ -304,6 +304,21 @@ export default function fffExtension(pi: ExtensionAPI) {
304
304
  process.env.FFF_HISTORY_DB ??
305
305
  undefined;
306
306
 
307
+ // Root scanning opt-in: flag (boolean) > env ("1"/"true") > false.
308
+ // FFF refuses to init at / unless this is set. Home dir scanning is on by
309
+ // default for pi — launching pi from $HOME is a normal flow.
310
+ function resolveBoolOpt(flagName: string, envName: string): boolean {
311
+ const flag = pi.getFlag(flagName);
312
+ if (typeof flag === "boolean") return flag;
313
+ if (typeof flag === "string") return flag === "true" || flag === "1";
314
+ const env = process.env[envName];
315
+ return env === "1" || env === "true";
316
+ }
317
+ const enableFsRootScanning = resolveBoolOpt(
318
+ "fff-enable-root-scan",
319
+ "FFF_ENABLE_ROOT_SCAN",
320
+ );
321
+
307
322
  function getMode(): FffMode {
308
323
  return currentMode;
309
324
  }
@@ -333,6 +348,8 @@ export default function fffExtension(pi: ExtensionAPI) {
333
348
  frecencyDbPath,
334
349
  historyDbPath,
335
350
  aiMode: true,
351
+ enableHomeDirScanning: true,
352
+ enableFsRootScanning,
336
353
  });
337
354
 
338
355
  if (!result.ok)
@@ -441,9 +458,39 @@ export default function fffExtension(pi: ExtensionAPI) {
441
458
  type: "string",
442
459
  });
443
460
 
461
+ pi.registerFlag("fff-enable-root-scan", {
462
+ description:
463
+ "Allow indexing when launched from the filesystem root (also: FFF_ENABLE_ROOT_SCAN env)",
464
+ type: "boolean",
465
+ });
466
+
444
467
  pi.on("session_start", async (_event, ctx) => {
445
468
  try {
446
469
  activeCwd = ctx.cwd;
470
+
471
+ // Restore persisted mode from session entries. This handles session
472
+ // resume after process restart where env vars are lost, and ensures
473
+ // the env var is set for the next /reload in the same session.
474
+ const entries = ctx.sessionManager?.getEntries();
475
+ if (entries) {
476
+ const modeEntry = [...entries]
477
+ .reverse()
478
+ .find(
479
+ (e: { type: string; customType?: string }) =>
480
+ e.type === "custom" && e.customType === "fff-mode",
481
+ );
482
+ if (
483
+ modeEntry &&
484
+ typeof (modeEntry as any).data?.mode === "string" &&
485
+ VALID_MODES.includes((modeEntry as any).data.mode as FffMode)
486
+ ) {
487
+ const restored = (modeEntry as any).data.mode as FffMode;
488
+ if (restored !== currentMode) {
489
+ currentMode = restored;
490
+ }
491
+ }
492
+ }
493
+
447
494
  registerAutocompleteProvider(ctx);
448
495
  await ensureFinder(activeCwd);
449
496
  } catch (e: unknown) {
@@ -897,8 +944,10 @@ export default function fffExtension(pi: ExtensionAPI) {
897
944
  if (!arg) {
898
945
  const mode = getMode();
899
946
  const flag = pi.getFlag("fff-mode") ?? "unset";
900
- const env = process.env.PI_FFF_MODE ?? "unset";
901
- ctx.ui.notify(`Current mode: '${mode}'\nFlag: ${flag}, Env: ${env}`, "info");
947
+ ctx.ui.notify(
948
+ `Current mode: '${mode}' (flag: ${flag})`,
949
+ "info",
950
+ );
902
951
  return;
903
952
  }
904
953
 
@@ -912,9 +961,11 @@ export default function fffExtension(pi: ExtensionAPI) {
912
961
  const oldMode = getMode();
913
962
  setMode(newMode);
914
963
 
964
+ pi.appendEntry("fff-mode", { mode: newMode });
965
+
915
966
  const note =
916
967
  (oldMode === "override") !== (newMode === "override")
917
- ? " (tool name change requires restart)"
968
+ ? " (tool name change requires /reload)"
918
969
  : "";
919
970
  ctx.ui.notify(`Mode changed: '${oldMode}' → '${newMode}'${note}`, "info");
920
971
  },