rufio 1.5.1 → 1.6.0

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.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +37 -0
  3. data/README.md +8 -3
  4. data/README_ja.md +7 -3
  5. data/Rakefile +5 -0
  6. data/SECURITY.md +2 -2
  7. data/docs/guide.md +41 -8
  8. data/docs/guide_ja.md +41 -8
  9. data/docs/native_fuzzy_search_design_ja.md +684 -0
  10. data/info/help.md +13 -4
  11. data/info/keybindings.md +5 -3
  12. data/info/welcome.md +2 -2
  13. data/lib/rufio/config.rb +0 -2
  14. data/lib/rufio/config_loader.rb +24 -4
  15. data/lib/rufio/fuzzy_candidate_block.rb +131 -0
  16. data/lib/rufio/fuzzy_candidate_cache.rb +258 -0
  17. data/lib/rufio/fuzzy_file_source.rb +180 -0
  18. data/lib/rufio/fuzzy_finder.rb +313 -0
  19. data/lib/rufio/fuzzy_preview_loader.rb +107 -0
  20. data/lib/rufio/fuzzy_search.rb +327 -0
  21. data/lib/rufio/fuzzy_search_session.rb +426 -0
  22. data/lib/rufio/global_search.rb +292 -51
  23. data/lib/rufio/health_checker.rb +0 -22
  24. data/lib/rufio/help_menu.rb +5 -4
  25. data/lib/rufio/keybind_handler.rb +6 -5
  26. data/lib/rufio/native/aarch64-linux-gnu/librufio_zig.so +0 -0
  27. data/lib/rufio/native/aarch64-linux-musl/librufio_zig.so +0 -0
  28. data/lib/rufio/native/aarch64-macos/librufio_zig.dylib +0 -0
  29. data/lib/rufio/native/aarch64-windows/rufio_zig.dll +0 -0
  30. data/lib/rufio/native/x86_64-linux-gnu/librufio_zig.so +0 -0
  31. data/lib/rufio/native/x86_64-linux-musl/librufio_zig.so +0 -0
  32. data/lib/rufio/native/x86_64-macos/librufio_zig.dylib +0 -0
  33. data/lib/rufio/native/x86_64-windows/rufio_zig.dll +0 -0
  34. data/lib/rufio/native_content_search.rb +43 -7
  35. data/lib/rufio/native_scanner_zig.rb +17 -0
  36. data/lib/rufio/rga_result_source.rb +89 -0
  37. data/lib/rufio/screen.rb +5 -1
  38. data/lib/rufio/search_controller.rb +56 -54
  39. data/lib/rufio/terminal_ui.rb +70 -8
  40. data/lib/rufio/ui_renderer.rb +1 -1
  41. data/lib/rufio/version.rb +1 -1
  42. data/lib/rufio.rb +6 -0
  43. data/lib_zig/rufio_native/Makefile +16 -2
  44. data/lib_zig/rufio_native/build.zig +8 -0
  45. data/lib_zig/rufio_native/src/fuzzy.zig +520 -0
  46. data/lib_zig/rufio_native/src/fuzzy_test.zig +212 -0
  47. data/lib_zig/rufio_native/src/main.zig +27 -0
  48. data/lib_zig/rufio_native/src/search.zig +221 -44
  49. metadata +13 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ff603a8e5d0c14a9bb18bfe116f0ccef4a5eee527ea0a24bd78bc358cd274f74
4
- data.tar.gz: e4d85a17e12f8601d7e45ae1d338328db7a9febaf96a8aae3f115b10e438d56f
3
+ metadata.gz: 259020c67c64924be286409faf8308368b2971500689a280ff4d272c9c73f9ae
4
+ data.tar.gz: 6b7fbffbbc9509f69be7c94927b5bca8bb6e5e9472a1cf43d2e1904bdb1f0f1b
5
5
  SHA512:
6
- metadata.gz: 33abb4a41ddfc5801b8afa1692bb020ba39ca003440349c8475b02436202bc0b3e90f996a68ffe1a1123ebd23c5f0bf75d3192c22a8bf6476123821e132e5347
7
- data.tar.gz: 1af1b2a50d37c6975697f87621df384d77b1863579b1e62e6396fdc0c7216a32575fec1cafccf964fdb474c87c3899340a94ff47983d43c672331119682f0af4
6
+ metadata.gz: f6027004bbd37d5f747a673e974803ea766ae1677f24f3b489fd2a5320fa6ee497a072206d1caec15bb5b546fd31e1be98190ef03c2adc66a0479de020817497
7
+ data.tar.gz: 701591ad5de5abfeba0a0b2cde643870fc39006afa4cede6912aaff68d3d997ccb19a47578f218ce1cecdb2ed394742a34eb89e1ef6964225cf12ea7f78e941e
data/CHANGELOG.md CHANGED
@@ -7,6 +7,43 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [1.6.0] - 2026-11-22
11
+
12
+ ### Added
13
+ - Phase 1 of the internal fuzzy search engine: a persistent Zig candidate index, bounded top-K ranking, UTF-8 match byte offsets, and an equivalent Ruby fallback. Missing or older native libraries and `RUFIO_NATIVE_FUZZY=0` use Ruby. The engine is available through `Rufio::FuzzySearch`
14
+ - Native/Ruby parity tests, allocation-failure checks, a reproducible synthetic benchmark, and the staged implementation plan in `docs/native_fuzzy_search_design_ja.md`. The bundled native binaries for all eight platforms are rebuilt with the fuzzy API
15
+ - Phase 2 adds `Rufio::FuzzySearchSession`: background file listing and index ownership, bounded producer queues, latest-query coalescing, generation-checked immutable results, and nonblocking close with worker-owned cleanup. Candidate-only refreshes are grouped at 50ms intervals; query changes and scan completion bypass the interval
16
+ - `Rufio::FuzzyFileSource` lists hidden files and regular-file symlinks using the existing Zig listing API or a Ruby fallback, skips directory symlinks, and keeps original paths separate from scrubbed UTF-8 labels. A cooperative cancellation callback on `NativeContentSearch#each_batch` stops idle polling as well. Session lifecycle tests and a streaming benchmark cover the new APIs
17
+ - Built-in fuzzy search screen (`Rufio::FuzzyFinder`) for `s` / `/`: lists every file under the current directory while scanning, filters as you type with in-order fuzzy matching, highlights matched characters, and opens the selection with `Enter`. `Up` / `Down`, `Ctrl+J` / `Ctrl+K`, `Ctrl+N` / `Ctrl+P` select, `Ctrl+U` clears and `ESC` returns. The selection stays on the same file while new candidates arrive
18
+ - `F` asks for the text in an input dialog, then streams rga's `file:line:text` results into the same screen (`Rufio::RgaResultSource`); `Enter` opens the file at that line. rga is stopped when the screen closes
19
+ - The fuzzy search screen previews the selected file on the right when the screen is at least 80 columns wide (`Rufio::FuzzyPreviewLoader`). Previews load in the background, only the latest selection is read, and reads are limited to the first 64 KiB. `F` results scroll to the matching line and highlight it. `UI_OPTIONS` `preview_enabled: false` hides the preview
20
+ - Reopening `s` in a directory scanned in the last 5 minutes shows the cached file list immediately (`Rufio::FuzzyCandidateCache`, up to 4 directories and 200,000 files, kept as packed label strings). The title shows `Cached ... ago`, `Ctrl+R` rescans while keeping the query, and choosing a file deleted since then keeps the screen open with `File no longer exists`
21
+
22
+ - `FUZZY_SEARCH_CACHE` in `config.rb` changes the file list cache limits (`max_entries` up to 1,000,000, `max_roots` up to 16, `ttl` up to 86,400 seconds; `0` disables). Omitted or invalid values keep the defaults (200,000 / 4 / 300)
23
+
24
+ ### Changed
25
+ - `s`, `/` and `F` no longer use fzf, and `rufio -c` no longer checks for it. The keybind actions are renamed to `file_search` / `file_search_alt`; the former `fzf_search` / `fzf_search_alt` names in `KEYBINDS` are still accepted as aliases (the new names win when both are set)
26
+ - G mode file name search uses the same fuzzy matching as `s`: results are ranked, matched characters are highlighted and filtering runs in the background instead of on each keystroke in the UI thread. Content search stays literal. Exclusions, skipped counts and bookmark labels are unchanged
27
+ - Fuzzy ranking no longer penalizes the distance from the start of the path, and the first character of the file name gets +8, so file names that start with the query rank first (e.g. `Rakefile` for `rakefile`, `gemspec.rb` for `gemspec`). Ruby and native scoring stay identical
28
+ - `rake native:sync_nvim` (`make -C lib_zig/rufio_native sync-nvim`) copies the shared Zig core (`search.zig`, `os.zig`, `fuzzy.zig` and their tests) to the usurai.nvim Zig tree and rebuilds it there, so both projects stay on one search and fuzzy implementation
29
+
30
+ ### Performance
31
+ - The fuzzy index narrows from the previous query: when the previous query is a subsequence of the new one (typing more characters), only the previous matches and candidates added since are scored. `Rufio::FuzzySearch#scanned` reports how many candidates the last query scored; the Ruby fallback narrows the same way
32
+ - Native fuzzy scoring runs on all CPU cores for 2,048 or more candidates, with work split into chunks claimed atomically and per-thread top-K merged deterministically (results are identical to a single thread)
33
+ - The native index stores each candidate once as UTF-8 plus a start offset and a character count, and decodes characters only for candidates that pass the subsequence check. For 168,785 paths the memory increase dropped from about 222 MiB to about 48 MiB, and registration from about 390 ms to about 43 ms
34
+ - Sessions keep frozen candidates without copying them, and the file, rga and G mode sources emit frozen rows. Reopening `s` from the cache for 168,785 files takes about 0.22–0.32 s instead of 0.76–1.05 s
35
+ - File candidates travel as packed blocks (`Rufio::FuzzyCandidateBlock`: NUL-terminated labels in one string) instead of one Hash per file. Sessions register a block with `Rufio::FuzzySearch#add_packed` and build rows only for candidates that reach the results; the file list cache keeps the scanned blocks and hands the same objects to the next session. `s` / `/` and G mode file names use blocks; rga results keep rows. Sources may yield either rows or blocks. No native library change
36
+ - Measured on Linux x86_64 (4 cores) with 168,000 synthetic files: reopening `s` from the cache completes in 25–40 ms instead of 686–860 ms, a fresh scan in 434–659 ms instead of about 1,570 ms, G mode file names in 541–596 ms instead of about 1,760 ms, and Ruby objects held by an open session drop from 87–136 MiB to 17 MiB
37
+ - `NativeContentSearch#each_batch(max_events:)` splits large drains so parsing does not hold the interpreter lock for long, and a search that ran before any candidate arrived no longer delays the first results by the 50 ms refresh interval
38
+ - On the same data, a query takes 1.7–12.9 ms instead of 20.7–47.6 ms, and typing `s` → `sctrl` takes 9–14 ms per key instead of 22–55 ms. The bundled native libraries for all eight platforms are rebuilt
39
+ - The native file listing can return root-relative labels packed per root (`core_files_labels_create`, `NativeContentSearch.new(labels: true)`), and `s` / `/` and G mode file names turn them into candidate blocks without per-file Ruby strings. Opening `s` on 168,000 files completes in about 93 ms instead of 513 ms, and G mode file names in about 124 ms instead of 722 ms (Linux x86_64, 4 cores); `rg --files | fzf` takes about 176 ms on the same files
40
+ - The multi-thread threshold was lowered from 16,384 to 2,048 candidates after measuring, so narrowed queries no longer fall back to one thread (`unicod` / `unicode` on 50,934 paths: 3.0 / 2.3 ms instead of 7.0 / 5.2 ms). `FuzzySearch#query(positions:)` and `FuzzySearchSession.new(position_limit:)` recover match positions only for the best results; G mode computes positions for rows below the top 100 when they are drawn (`FuzzySearch.positions`)
41
+ - G mode content search no longer fills its in-memory cache during the first search: files are searched as usual and cached by a background thread afterwards, so the first search takes about 88–118 ms instead of 156–199 ms (rg: 87–107 ms). Searches made while the cache is being filled do not use it. `NativeContentSearch::Cache#wait_for_fill` waits for the fill
42
+ - The bundled native libraries for all eight platforms are rebuilt with these APIs; older libraries keep working with the previous code paths
43
+
44
+ ### Fixed
45
+ - G mode and the fuzzy search screen erase rows left over from the previous frame when the result list gets shorter
46
+
10
47
  ## [1.5.1] - 2026-11-15
11
48
 
12
49
  ### Fixed
data/README.md CHANGED
@@ -8,6 +8,11 @@ Add your own actions in Ruby.
8
8
 
9
9
  [日本語](./README_ja.md) | **English**
10
10
 
11
+ Development for 1.6.0 replaces fzf with a built-in fuzzy search screen for `s` / `/` and `F`
12
+ (with a file preview and a cached file list for quick reopening),
13
+ backed by a Zig fuzzy search core, a Ruby fallback, and an asynchronous search session.
14
+ See the [implementation plan and benchmarks](./docs/native_fuzzy_search_design_ja.md).
15
+
11
16
  ## What Makes rufio Different
12
17
 
13
18
  rufio brings finding files, running scripts, and checking results together in one interface.
@@ -15,7 +20,7 @@ rufio brings finding files, running scripts, and checking results together in on
15
20
  - **Run scripts where your files are**: Register your script directories, then press `:`, type `@` + part of a script name, press `Tab`, and hit `Enter`. Run Ruby, Python, or PowerShell scripts in the directory you are browsing
16
21
  - **Follow jobs and execution logs**: Keep browsing while scripts run in the background. Press `J` to check jobs and `L` to view execution logs
17
22
  - **Add your own actions in Ruby**: Define custom commands with a small Ruby DSL in `~/.config/rufio/commands.rb`. `~/.rufio/commands.rb` is also supported
18
- - **Use installed tools without extra configuration**: Search file names with fzf, search contents with rga, highlight previews with bat, and navigate directory history with zoxide
23
+ - **Use installed tools without extra configuration**: Search contents with rga, highlight previews with bat, and navigate directory history with zoxide
19
24
  - **Windows support**: Run PowerShell scripts with keyboard input handling adapted to Windows terminals
20
25
  - **Trace behavior in the source**: The implementation is primarily Ruby, so you can inspect and change the parts you need. Security design is documented in [SECURITY.md](./SECURITY.md)
21
26
 
@@ -33,7 +38,7 @@ rufio brings finding files, running scripts, and checking results together in on
33
38
 
34
39
  - **Vim-like Key Bindings**: Intuitive navigation
35
40
  - **Real-time Preview**: Instantly display file contents with syntax highlighting (via `bat`), including `.zip` entry lists
36
- - **Fast Search**: Integration with fzf/rga, plus built-in search across all bookmarks that also reads PDF, Excel and PowerPoint
41
+ - **Fast Search**: Built-in fuzzy file name search, rga content search, plus built-in search across all bookmarks that also reads PDF, Excel and PowerPoint
37
42
  - **ZIP Archives**: Extract or compress selected items as a background job
38
43
  - **Jump to a Path**: Paste any path into `:cd`
39
44
  - **Bookmarks**: Quick access to frequently used directories
@@ -93,7 +98,7 @@ The most used keys. See the **[User Guide](./docs/guide.md)** for every key and
93
98
  | `m/c/x` | Move / copy / delete selected items |
94
99
  | `z` | Extract or compress selected items (`.zip`); zoxide history when nothing is selected |
95
100
  | `a/A`, `r`, `d` | Create file / directory, rename, delete |
96
- | `f`, `s`, `F` | Filter, fzf file name search, rga content search |
101
+ | `f`, `s`, `F` | Filter, fuzzy file name search, rga content search |
97
102
  | `G` | Search names or contents (PDF, Excel, PowerPoint too) across all bookmarks |
98
103
  | `b`, `B`, `1-9`, `Tab` | Add bookmark, bookmark menu, jump, next bookmark |
99
104
  | `:` | Command mode (`@script`, `rake:task`, `!shell`, `cd <path>`) |
data/README_ja.md CHANGED
@@ -8,6 +8,10 @@
8
8
 
9
9
  **日本語** | [English](./README.md)
10
10
 
11
+ 1.6.0 の開発では、`s` / `/` と `F` を fzf から内蔵のあいまい検索画面に置き換えました(ファイルのプレビューと、開き直しを速くする一覧キャッシュつき)。
12
+ Zig の曖昧検索コア・Ruby フォールバック・非同期検索セッションで動作します。
13
+ 詳細は[実装計画と計測結果](./docs/native_fuzzy_search_design_ja.md)を参照してください。
14
+
11
15
  ## rufioならではの点
12
16
 
13
17
  rufio は、ファイルを探すところからスクリプトの実行、結果の確認までを一つの画面にまとめます。
@@ -15,7 +19,7 @@ rufio は、ファイルを探すところからスクリプトの実行、結
15
19
  - **ファイルのある場所からスクリプトを実行**: スクリプトのディレクトリを登録し、`:` → `@` + スクリプト名の一部 → `Tab` → `Enter` で呼び出せます。Ruby・Python・PowerShell を、いま開いているディレクトリで実行できます
16
20
  - **ジョブとログで実行結果を追える**: バックグラウンドで実行しながらファイル操作を続け、`J` でジョブ、`L` で実行ログを確認できます
17
21
  - **自分用の操作を Ruby で追加**: `~/.config/rufio/commands.rb` に小さな Ruby DSL で独自コマンドを定義できます。`~/.rufio/commands.rb` にも対応しています
18
- - **インストール済みのツールと追加設定なしで連携**: fzf でファイル名検索、rga で内容検索、bat でプレビューのシンタックスハイライト、zoxide でディレクトリ履歴から移動できます
22
+ - **インストール済みのツールと追加設定なしで連携**: rga で内容検索、bat でプレビューのシンタックスハイライト、zoxide でディレクトリ履歴から移動できます
19
23
  - **Windows にも対応**: PowerShell スクリプトの実行に対応し、Windows のターミナルに合わせたキー入力処理を備えています
20
24
  - **挙動をソースで追いやすい**: Ruby を中心とした実装で、必要な処理を自分で確認・修正できます。セキュリティに関する設計は [SECURITY.md](./SECURITY.md) にまとめています
21
25
 
@@ -33,7 +37,7 @@ rufio は、ファイルを探すところからスクリプトの実行、結
33
37
 
34
38
  - **Vimライクなキーバインド**: 直感的なナビゲーション
35
39
  - **リアルタイムプレビュー**: ファイル内容を即座に表示(`bat` によるシンタックスハイライト対応、`.zip` はエントリ一覧)
36
- - **高速検索**: fzf/rgaとの連携に加え、PDF・Excel・PowerPointも読める全ブックマーク横断検索を内蔵
40
+ - **高速検索**: 内蔵のあいまいファイル名検索とrgaによる内容検索に加え、PDF・Excel・PowerPointも読める全ブックマーク横断検索を内蔵
37
41
  - **ZIPの展開・圧縮**: 選択したアイテムをバックグラウンドで展開・圧縮
38
42
  - **パスへ移動**: コピーしたパスを `:cd` に貼り付けて移動
39
43
  - **ブックマーク**: よく使うディレクトリに素早くアクセス
@@ -93,7 +97,7 @@ rufio /path/to # 指定したディレクトリで起動
93
97
  | `m/c/x` | 選択したアイテムの移動 / コピー / 削除 |
94
98
  | `z` | 選択したアイテムの展開・圧縮(`.zip`)。未選択時は zoxide 履歴 |
95
99
  | `a/A`、`r`、`d` | ファイル / ディレクトリ作成、リネーム、削除 |
96
- | `f`、`s`、`F` | フィルター、fzf でファイル名検索、rga で内容検索 |
100
+ | `f`、`s`、`F` | フィルター、あいまいファイル名検索、rga で内容検索 |
97
101
  | `G` | 全ブックマーク配下のファイル名・内容(PDF・Excel・PowerPoint も)を横断検索 |
98
102
  | `b`、`B`、`1-9`、`Tab` | ブックマーク追加、メニュー、ジャンプ、次のブックマーク |
99
103
  | `:` | コマンドモード(`@スクリプト`、`rake:タスク`、`!シェル`、`cd <パス>`) |
data/Rakefile CHANGED
@@ -25,6 +25,11 @@ namespace :native do
25
25
  task :check do
26
26
  ruby '-I test -I lib test/test_native_platform_binaries.rb'
27
27
  end
28
+
29
+ desc 'Sync shared Zig core (search/os/fuzzy and tests) to usurai.nvim and rebuild'
30
+ task :sync_nvim do
31
+ sh 'make -C lib_zig/rufio_native sync-nvim'
32
+ end
28
33
  end
29
34
 
30
35
  # Gem build and push tasks
data/SECURITY.md CHANGED
@@ -31,7 +31,7 @@ rufio is a local TUI tool run by you, on files you can already access.
31
31
  - Commands you type yourself in command mode (`:`, `!`) — they are executed as shell commands
32
32
  - Code in your own configuration: `~/.rufio/commands.rb` and `~/.config/rufio/commands.rb` are **evaluated as Ruby**. Keep them writable only by you
33
33
  - Scripts you register under script paths — they run with your privileges
34
- - Vulnerabilities in external tools (fzf, rga, bat, zoxide, editors)
34
+ - Vulnerabilities in external tools (rga, bat, zoxide, editors)
35
35
 
36
36
  ### Design practices
37
37
 
@@ -78,7 +78,7 @@ rufioは、あなた自身がアクセスできるファイルに対して、ロ
78
78
  - コマンドモード(`:`、`!`)で自分で入力したコマンド — シェルコマンドとして実行されます
79
79
  - 自分の設定ファイル内のコード — `~/.rufio/commands.rb` と `~/.config/rufio/commands.rb` は**Rubyとして評価**されます。書き込み権限は自分だけにしてください
80
80
  - スクリプトパスに登録したスクリプト — あなたの権限で実行されます
81
- - 外部ツール(fzf、rga、bat、zoxide、エディタ)自体の脆弱性
81
+ - 外部ツール(rga、bat、zoxide、エディタ)自体の脆弱性
82
82
 
83
83
  ### 設計上の方針
84
84
 
data/docs/guide.md CHANGED
@@ -107,17 +107,36 @@ With nothing selected, `z` opens zoxide history instead.
107
107
  | Key | Action |
108
108
  |-----|--------|
109
109
  | `f` | Filter the current list as you type (`Enter` keeps the filter, `ESC` clears it) |
110
- | `s` or `/` | Search file names with fzf |
111
- | `F` | Search file contents with rga |
110
+ | `s` or `/` | Fuzzy search file names under the current directory (no external tools needed) |
111
+ | `F` | Search file contents with rga, then pick a result in the same screen |
112
112
  | `G` | Global search across all bookmarks (no external tools needed) |
113
113
 
114
+ ### Fuzzy Search Screen (`s`, `/`, `F`)
115
+
116
+ `s` and `/` list every file under the current directory, including hidden files and links to regular files, while the list is still being scanned. Typing narrows it with fuzzy matching: the query characters must appear in order but need not be adjacent (`sctrl` finds `search_controller.rb`). ASCII letters ignore case and Japanese text is matched as is. Matches after the last `/`, at word boundaries and in consecutive runs rank higher, and matched characters are highlighted.
117
+
118
+ | Key | Action |
119
+ |-----|--------|
120
+ | Type | Filter the list |
121
+ | `Up` / `Down`, `Ctrl+J` / `Ctrl+K`, `Ctrl+N` / `Ctrl+P` | Select a result |
122
+ | `Enter` | Open the file (`F`: at the matching line) |
123
+ | `Ctrl+U` | Clear the query |
124
+ | `Ctrl+R` | Rescan the directory (keeps the query) |
125
+ | `ESC` | Return to the file list |
126
+
127
+ `F` asks for the text to search, runs rga in the background and streams its `file:line:text` results into this screen; typing then filters those lines. The matching itself uses the bundled Zig library when available and falls back to Ruby otherwise (`RUFIO_NATIVE_FUZZY=0` forces Ruby).
128
+
129
+ On screens at least 80 columns wide, the right half shows a preview of the selected file, loaded in the background and limited to the first 64 KiB. `F` results scroll the preview to the matching line and highlight it. `preview_enabled: false` in `UI_OPTIONS` hides it.
130
+
131
+ Reopening `s` in a directory scanned in the last 5 minutes shows the cached list immediately; the title reads `Cached 2m ago | Ctrl+R: Rescan`. By default the cache keeps up to 4 directories and 200,000 files in total (see `FUZZY_SEARCH_CACHE` below), so new, deleted or changed files may be missing until you press `Ctrl+R`. Selecting a file that no longer exists keeps the screen open and shows `File no longer exists`.
132
+
114
133
  ## Global Search (G mode)
115
134
 
116
- `G` searches recursively under every bookmarked directory. Add bookmarks with `b` first.
135
+ `G` searches recursively under every bookmarked directory. Add bookmarks with `b` first. File names use the same fuzzy matching as `s` (best matches first, matched characters highlighted, filtered in the background); content search stays literal.
117
136
 
118
137
  | Key | Action |
119
138
  |-----|--------|
120
- | Type | Literal, case-insensitive search |
139
+ | Type | File names: fuzzy search. Content: Literal, case-insensitive search |
121
140
  | `Tab` | Switch between **File names** and **Content** |
122
141
  | `Up` / `Down`, `Ctrl+J` / `Ctrl+K`, `Ctrl+N` / `Ctrl+P` | Select a result |
123
142
  | `Enter` | Go to the file in Files mode |
@@ -325,18 +344,33 @@ APPLICATIONS = {
325
344
 
326
345
  # Extensions (and /names of directories or files) excluded from G mode search
327
346
  GLOBAL_SEARCH_EXCLUDED_EXTENSIONS = %w[.log /node_modules].freeze
347
+
348
+ # File list cache for reopening s / / (omitted keys keep their defaults)
349
+ FUZZY_SEARCH_CACHE = { max_entries: 500_000, max_roots: 8, ttl: 900 }.freeze
328
350
  ```
329
351
 
352
+ `FUZZY_SEARCH_CACHE` keys:
353
+
354
+ | Key | Default | Maximum | Meaning |
355
+ |-----|---------|---------|---------|
356
+ | `max_entries` | 200,000 | 1,000,000 | Files kept across all cached directories |
357
+ | `max_roots` | 4 | 16 | Directories kept (least recently used is dropped first) |
358
+ | `ttl` | 300 | 86,400 | Seconds before a cached list is scanned again |
359
+
360
+ Values above the maximum are capped, invalid values fall back to the default, and `0` disables caching (`max_entries` / `max_roots`) or expires lists immediately (`ttl`). About 90 bytes are used per cached file.
361
+
330
362
  Action names for `KEYBINDS`:
331
363
 
332
364
  | Group | Actions (default key) |
333
365
  |-------|-----------------------|
334
366
  | Navigation | `move_up` (k), `move_down` (j), `navigate_parent` (h), `navigate_enter` (l), `top` (g), `bottom` (}), `refresh` (R) |
335
367
  | Files | `open_file` (o), `preview` (P), `rename` (r), `delete` (d), `create_file` (a), `create_dir` (A), `move_selected` (m), `copy_selected` (c), `delete_selected` (x), `open_explorer` (e) |
336
- | Selection and search | `select` (Space), `filter` (f), `fzf_search` (s), `fzf_search_alt` (/), `rga_search` (F) |
368
+ | Selection and search | `select` (Space), `filter` (f), `file_search` (s), `file_search_alt` (/), `rga_search` (F) |
337
369
  | Bookmarks | `add_bookmark` (b), `bookmark_menu` (B), `zoxide` (z), `start_dir` (0) |
338
370
  | Modes | `job_mode` (J), `global_search` (G), `config_mode` (C), `help` (?), `log_viewer` (L), `command_mode` (:), `quit` (q), `quit_cd` (T) |
339
371
 
372
+ The former names `fzf_search` / `fzf_search_alt` are still accepted as aliases of `file_search` / `file_search_alt`.
373
+
340
374
  ### script_paths.yml and bookmarks.yml
341
375
 
342
376
  ```yaml
@@ -370,17 +404,16 @@ All tools are optional. Without them, rufio disables the feature or falls back t
370
404
 
371
405
  | Tool | Used for | Key |
372
406
  |------|----------|-----|
373
- | fzf | File name search | `s`, `/` |
374
407
  | rga | File content search | `F` |
375
408
  | zoxide | Directory history | `z` |
376
409
  | bat | Syntax highlighting in the preview | — |
377
410
 
378
411
  ```bash
379
412
  # macOS
380
- brew install fzf bat rga zoxide
413
+ brew install bat rga zoxide
381
414
 
382
415
  # Ubuntu/Debian
383
- apt install fzf bat zoxide
416
+ apt install bat zoxide
384
417
  # rga: https://github.com/phiresky/ripgrep-all
385
418
  ```
386
419
 
data/docs/guide_ja.md CHANGED
@@ -107,17 +107,36 @@ Files モードでは、最上段に現在のパス、その下にブックマ
107
107
  | キー | 操作 |
108
108
  |------|------|
109
109
  | `f` | 入力に合わせて一覧を絞り込む(`Enter` で確定、`ESC` で解除) |
110
- | `s` または `/` | fzf でファイル名検索 |
111
- | `F` | rga でファイル内容検索 |
110
+ | `s` または `/` | 現在のディレクトリ配下のファイル名をあいまい検索(外部ツール不要) |
111
+ | `F` | rga でファイル内容を検索し、同じ画面で結果を選択 |
112
112
  | `G` | 全ブックマークを横断検索(外部ツール不要) |
113
113
 
114
+ ### あいまい検索画面(`s`、`/`、`F`)
115
+
116
+ `s` と `/` は、現在のディレクトリ配下のファイル(隠しファイルと通常ファイルへのリンクを含む)を走査しながら一覧表示します。入力すると、文字が順番どおりに現れれば離れていても一致するあいまい検索で絞り込みます(`sctrl` で `search_controller.rb` が見つかります)。ASCII の英字は大文字小文字を区別せず、日本語はそのまま照合します。最後の `/` 以降・単語の先頭・連続した一致ほど上位に並び、一致した文字はハイライトされます。
117
+
118
+ | キー | 操作 |
119
+ |------|------|
120
+ | 入力 | 一覧を絞り込む |
121
+ | `↑` / `↓`、`Ctrl+J` / `Ctrl+K`、`Ctrl+N` / `Ctrl+P` | 結果を選択 |
122
+ | `Enter` | ファイルを開く(`F` は一致した行で開く) |
123
+ | `Ctrl+U` | 検索語をクリア |
124
+ | `Ctrl+R` | ディレクトリを走査し直す(検索語は保持) |
125
+ | `ESC` | ファイル一覧に戻る |
126
+
127
+ `F` は検索する文字列を尋ね、rga をバックグラウンドで実行して `ファイル:行:本文` の結果をこの画面へ流し込みます。入力するとその結果の行を絞り込めます。照合には同梱の Zig ライブラリを使い、利用できない場合は Ruby 実装に切り替えます(`RUFIO_NATIVE_FUZZY=0` で Ruby を強制)。
128
+
129
+ 幅 80 桁以上の画面では、右半分に選択中のファイルのプレビューを表示します。読み込みはバックグラウンドで行い、先頭 64 KiB までに制限します。`F` の結果では一致した行までスクロールして強調します。`UI_OPTIONS` の `preview_enabled: false` で非表示にできます。
130
+
131
+ 直近 5 分以内に走査したディレクトリで `s` を開き直すと、キャッシュした一覧をすぐに表示し、タイトルに `Cached 2m ago | Ctrl+R: Rescan` と出します。キャッシュは既定で最大 4 ディレクトリ・合計 20 万ファイルまでです(下記 `FUZZY_SEARCH_CACHE` で変更可)。その後に追加・削除・変更されたファイルは `Ctrl+R` で走査し直すまで反映されません。削除済みのファイルを選んだ場合は画面を閉じずに `File no longer exists` と表示します。
132
+
114
133
  ## 横断検索(G モード)
115
134
 
116
- `G` で、ブックマークした全ディレクトリの配下を再帰的に検索します。先に `b` でブックマークを登録してください。
135
+ `G` で、ブックマークした全ディレクトリの配下を再帰的に検索します。先に `b` でブックマークを登録してください。ファイル名は `s` と同じあいまい検索(よく一致したものから並び、一致文字をハイライト、絞り込みはバックグラウンド)で、内容検索はリテラルのままです。
117
136
 
118
137
  | キー | 操作 |
119
138
  |------|------|
120
- | 文字入力 | 大文字・小文字を区別しない部分一致検索 |
139
+ | 文字入力 | ファイル名: あいまい検索。内容: 大文字・小文字を区別しないリテラル(部分一致)検索 |
121
140
  | `Tab` | **File names(ファイル名)** と **Content(内容)** を切り替え |
122
141
  | `↑` / `↓`、`Ctrl+J` / `Ctrl+K`、`Ctrl+N` / `Ctrl+P` | 結果を選択 |
123
142
  | `Enter` | Files モードでそのファイルの場所へ移動 |
@@ -325,18 +344,33 @@ APPLICATIONS = {
325
344
 
326
345
  # G モードの検索から除外する拡張子(/ 始まりはディレクトリ・ファイル名)
327
346
  GLOBAL_SEARCH_EXCLUDED_EXTENSIONS = %w[.log /node_modules].freeze
347
+
348
+ # s / / を開き直すときの一覧キャッシュ(省略したキーは既定値)
349
+ FUZZY_SEARCH_CACHE = { max_entries: 500_000, max_roots: 8, ttl: 900 }.freeze
328
350
  ```
329
351
 
352
+ `FUZZY_SEARCH_CACHE` のキー:
353
+
354
+ | キー | 既定値 | 上限 | 意味 |
355
+ |------|--------|------|------|
356
+ | `max_entries` | 200,000 | 1,000,000 | 全ディレクトリ合計で保持するファイル数 |
357
+ | `max_roots` | 4 | 16 | 保持するディレクトリ数(最近使っていないものから捨てる) |
358
+ | `ttl` | 300 | 86,400 | 一覧を走査し直すまでの秒数 |
359
+
360
+ 上限を超える値は上限に丸め、不正な値は既定値を使います。`0` はキャッシュの無効化(`max_entries` / `max_roots`)または即時期限切れ(`ttl`)です。キャッシュは 1 ファイルあたり約 90 バイトを使います。
361
+
330
362
  `KEYBINDS` で使えるアクション名:
331
363
 
332
364
  | 分類 | アクション(デフォルトキー) |
333
365
  |------|------------------------------|
334
366
  | 移動 | `move_up` (k), `move_down` (j), `navigate_parent` (h), `navigate_enter` (l), `top` (g), `bottom` (}), `refresh` (R) |
335
367
  | ファイル | `open_file` (o), `preview` (P), `rename` (r), `delete` (d), `create_file` (a), `create_dir` (A), `move_selected` (m), `copy_selected` (c), `delete_selected` (x), `open_explorer` (e) |
336
- | 選択・検索 | `select` (Space), `filter` (f), `fzf_search` (s), `fzf_search_alt` (/), `rga_search` (F) |
368
+ | 選択・検索 | `select` (Space), `filter` (f), `file_search` (s), `file_search_alt` (/), `rga_search` (F) |
337
369
  | ブックマーク | `add_bookmark` (b), `bookmark_menu` (B), `zoxide` (z), `start_dir` (0) |
338
370
  | モード | `job_mode` (J), `global_search` (G), `config_mode` (C), `help` (?), `log_viewer` (L), `command_mode` (:), `quit` (q), `quit_cd` (T) |
339
371
 
372
+ 以前のアクション名 `fzf_search` / `fzf_search_alt` も `file_search` / `file_search_alt` の別名として引き続き使えます。
373
+
340
374
  ### script_paths.yml と bookmarks.yml
341
375
 
342
376
  ```yaml
@@ -370,17 +404,16 @@ script_paths:
370
404
 
371
405
  | ツール | 用途 | キー |
372
406
  |--------|------|------|
373
- | fzf | ファイル名検索 | `s`、`/` |
374
407
  | rga | ファイル内容検索 | `F` |
375
408
  | zoxide | ディレクトリ履歴 | `z` |
376
409
  | bat | プレビューのシンタックスハイライト | — |
377
410
 
378
411
  ```bash
379
412
  # macOS
380
- brew install fzf bat rga zoxide
413
+ brew install bat rga zoxide
381
414
 
382
415
  # Ubuntu/Debian
383
- apt install fzf bat zoxide
416
+ apt install bat zoxide
384
417
  # rga: https://github.com/phiresky/ripgrep-all
385
418
  ```
386
419