beniya 0.6.3 → 0.8.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.
data/README.md CHANGED
@@ -12,6 +12,8 @@ beniyaは、Yaziにインスパイアされたターミナル上で動作する
12
12
 
13
13
  - **軽量でシンプル**: Rubyで書かれた軽量なファイルマネージャー
14
14
  - **直感的な操作**: Vimライクなキーバインド
15
+ - **プラグインシステム**: 拡張可能なプラグインアーキテクチャ
16
+ - **コマンドモード**: Tab補完とフローティングウィンドウを備えた強力なコマンドシステム
15
17
  - **ファイルプレビュー**: テキストファイルの内容をその場で確認
16
18
  - **ファイル選択・操作**: 複数ファイルの選択、移動、コピー、削除が可能
17
19
  - **ベースディレクトリ操作**: 起動ディレクトリへの一括ファイル移動・コピー
@@ -117,6 +119,15 @@ beniya --help # ヘルプメッセージを表示
117
119
  | ---- | ---------------------------------- |
118
120
  | `z` | zoxide履歴からディレクトリを選択移動 |
119
121
 
122
+ #### コマンドモード
123
+
124
+ | キー | 機能 |
125
+ | ------ | ---------------------------------------- |
126
+ | `:` | コマンドモードを起動 |
127
+ | `Tab` | コマンド補完(コマンドモード中) |
128
+ | `Enter`| コマンドを実行(コマンドモード中) |
129
+ | `ESC` | コマンドモードをキャンセル(コマンドモード中) |
130
+
120
131
  #### システム操作
121
132
 
122
133
  | キー | 機能 |
@@ -271,6 +282,46 @@ apt install zoxide
271
282
  - zoxideが無効な場合は適切なメッセージが表示されます
272
283
  - 履歴が空の場合も適切にハンドリングされます
273
284
 
285
+ ### コマンドモードの詳細
286
+
287
+ #### コマンドモードの起動 (`:`)
288
+
289
+ - `:`キーを押してコマンドモードを起動
290
+ - 画面最下部にコマンド入力欄が表示される
291
+ - プラグインが提供するコマンドを実行できる
292
+
293
+ #### Tab補完機能
294
+
295
+ - **インテリジェントな補完**: コマンド名の一部を入力して`Tab`キーを押すと自動補完
296
+ - **複数候補の処理**: 複数のコマンドが一致する場合は共通プレフィックスまで補完
297
+ - **単一候補の自動完成**: 一つだけマッチする場合は完全に補完される
298
+ - **リアルタイム更新**: 入力内容に応じて候補が動的に変化
299
+
300
+ #### フローティングウィンドウでの結果表示
301
+
302
+ - **視覚的フィードバック**: コマンド実行結果をモダンなフローティングウィンドウで表示
303
+ - **色分けされた結果**:
304
+ - **緑色のボーダー**: コマンドが正常に実行された場合
305
+ - **赤色のボーダー**: エラーまたは警告が発生した場合
306
+ - **中央配置**: 画面中央に自動的に配置され視認性が高い
307
+ - **自動サイズ調整**: 結果の内容に応じてウィンドウサイズが自動調整
308
+ - **簡単に閉じる**: 任意のキーを押すとウィンドウを閉じて通常操作に戻る
309
+
310
+ #### 使用例
311
+
312
+ ```
313
+ 1. : → コマンドモードを起動
314
+ 2. "he" → コマンド名の一部を入力
315
+ 3. Tab → 補完("hello", "help", "health"などが候補)
316
+ 4. Enter → コマンドを実行
317
+ 5. フローティングウィンドウで結果を確認
318
+ 6. 任意のキーを押してウィンドウを閉じる
319
+ ```
320
+
321
+ #### 利用可能なコマンド
322
+
323
+ コマンドはプラグインによって提供されます。プラグインシステムの詳細については後述の「プラグインシステム」セクションを参照してください。
324
+
274
325
  ### 必要な外部ツール
275
326
 
276
327
  検索機能・履歴機能を使用するには、以下のツールが必要です:
@@ -351,6 +402,189 @@ COLORS = {
351
402
  - `selected`: 選択中の項目の色
352
403
  - `preview`: プレビューパネルの色
353
404
 
405
+ ## プラグインシステム
406
+
407
+ beniyaは拡張可能なプラグインシステムを備えており、独自の機能を簡単に追加できます。
408
+
409
+ ### プラグインの配置場所
410
+
411
+ #### 1. 本体同梱プラグイン
412
+ ```
413
+ lib/beniya/plugins/*.rb
414
+ ```
415
+ beniyaに標準で含まれるプラグイン。外部gem依存なしの基本機能を提供。
416
+
417
+ #### 2. ユーザープラグイン
418
+ ```
419
+ ~/.beniya/plugins/*.rb
420
+ ```
421
+ ユーザーが自由に追加できるプラグイン。GitHub GistやrawURLから取得可能。
422
+
423
+ ### プラグインの作成方法
424
+
425
+ #### シンプルなプラグイン例
426
+
427
+ ```ruby
428
+ # ~/.beniya/plugins/hello.rb
429
+ module Beniya
430
+ module Plugins
431
+ class Hello < Plugin
432
+ def name
433
+ 'Hello'
434
+ end
435
+
436
+ def description
437
+ 'シンプルな挨拶プラグイン'
438
+ end
439
+
440
+ def commands
441
+ {
442
+ hello: method(:say_hello)
443
+ }
444
+ end
445
+
446
+ private
447
+
448
+ def say_hello
449
+ "Hello from beniya!"
450
+ end
451
+ end
452
+ end
453
+ end
454
+ ```
455
+
456
+ **プラグインの使い方:**
457
+
458
+ 1. beniyaを起動
459
+ 2. `:`キーでコマンドモードを起動
460
+ 3. `hello`と入力(または`he`と入力してTabキーで補完)
461
+ 4. Enterキーで実行
462
+ 5. フローティングウィンドウに"Hello from beniya!"が表示される
463
+
464
+ #### 外部gemに依存するプラグイン例
465
+
466
+ ```ruby
467
+ # ~/.beniya/plugins/ai_helper.rb
468
+ module Beniya
469
+ module Plugins
470
+ class AiHelper < Plugin
471
+ requires 'anthropic' # 依存gem宣言
472
+
473
+ def name
474
+ 'AiHelper'
475
+ end
476
+
477
+ def description
478
+ 'Claude APIを使ったAIアシスタント'
479
+ end
480
+
481
+ def commands
482
+ {
483
+ ai: method(:ask_ai)
484
+ }
485
+ end
486
+
487
+ def initialize
488
+ super # 依存チェック実行
489
+ @client = Anthropic::Client.new(
490
+ api_key: ENV['ANTHROPIC_API_KEY']
491
+ )
492
+ end
493
+
494
+ private
495
+
496
+ def ask_ai
497
+ response = @client.messages.create(
498
+ model: "claude-3-5-sonnet-20241022",
499
+ max_tokens: 1024,
500
+ messages: [{role: "user", content: "Hello, Claude!"}]
501
+ )
502
+ response.content.first.text
503
+ end
504
+ end
505
+ end
506
+ end
507
+ ```
508
+
509
+ **プラグインの使い方:**
510
+
511
+ 1. 依存gemをインストール: `gem install anthropic`
512
+ 2. 環境変数を設定: `export ANTHROPIC_API_KEY=your_api_key`
513
+ 3. beniyaを起動
514
+ 4. `:`キーでコマンドモードを起動
515
+ 5. `ai`と入力してEnterキーで実行
516
+ 6. フローティングウィンドウにClaude APIからの応答が表示される
517
+
518
+ ### プラグインの管理
519
+
520
+ #### プラグインの有効/無効設定
521
+
522
+ `~/.beniya/config.yml`でプラグインの有効/無効を制御できます:
523
+
524
+ ```yaml
525
+ plugins:
526
+ fileoperations:
527
+ enabled: true
528
+ ai_helper:
529
+ enabled: true
530
+ my_custom:
531
+ enabled: false
532
+ ```
533
+
534
+ #### デフォルト動作
535
+
536
+ - `config.yml`が存在しない → 全プラグイン有効
537
+ - プラグインの設定がない → 有効とみなす
538
+ - `enabled: false`が明示的に設定されている → 無効
539
+
540
+ ### プラグインの配布方法
541
+
542
+ #### GitHub Gistで共有
543
+
544
+ ```bash
545
+ # プラグイン作者
546
+ 1. GitHub Gistに.rbファイルをアップロード
547
+ 2. Raw URLをユーザーに共有
548
+
549
+ # ユーザー
550
+ $ mkdir -p ~/.beniya/plugins
551
+ $ curl -o ~/.beniya/plugins/my_plugin.rb [RAW_URL]
552
+ $ beniya
553
+ ✓ my_plugin 読み込み完了
554
+ ```
555
+
556
+ #### GitHubリポジトリで共有
557
+
558
+ ```bash
559
+ # プラグイン作者
560
+ beniya-plugins/
561
+ ├── plugin1.rb
562
+ └── plugin2.rb
563
+
564
+ # ユーザー
565
+ $ curl -o ~/.beniya/plugins/plugin1.rb https://raw.githubusercontent.com/user/beniya-plugins/main/plugin1.rb
566
+ ```
567
+
568
+ ### プラグインの主要機能
569
+
570
+ #### 必須メソッド
571
+
572
+ - `name`: プラグイン名(必須)
573
+ - `description`: プラグインの説明(オプション、デフォルト: "")
574
+ - `version`: プラグインのバージョン(オプション、デフォルト: "1.0.0")
575
+ - `commands`: コマンド定義(オプション、デフォルト: {})
576
+
577
+ #### 依存gem管理
578
+
579
+ - `requires 'gem_name'`: 依存gemを宣言
580
+ - 依存gemが不足している場合、警告を表示してプラグインを無効化
581
+ - beniya本体は正常に起動継続
582
+
583
+ #### 自動登録機能
584
+
585
+ - `Plugin`クラスを継承すると自動的に`PluginManager`に登録
586
+ - 複雑な登録処理は不要
587
+
354
588
  ## 開発
355
589
 
356
590
  ### 必要な環境
data/README_EN.md CHANGED
@@ -12,6 +12,7 @@ beniya is a terminal-based file manager inspired by Yazi. It's implemented in Ru
12
12
 
13
13
  - **Lightweight & Simple**: A lightweight file manager written in Ruby
14
14
  - **Intuitive Operation**: Vim-like key bindings
15
+ - **Plugin System**: Extensible plugin architecture
15
16
  - **File Preview**: View text file contents on the fly
16
17
  - **File Selection & Operations**: Select multiple files, move, copy, and delete
17
18
  - **Base Directory Operations**: Batch file operations to startup directory
@@ -352,6 +353,167 @@ COLORS = {
352
353
  - `selected`: Selected item color
353
354
  - `preview`: Preview panel color
354
355
 
356
+ ## Plugin System
357
+
358
+ beniya features an extensible plugin system that allows you to easily add custom functionality.
359
+
360
+ ### Plugin Locations
361
+
362
+ #### 1. Built-in Plugins
363
+ ```
364
+ lib/beniya/plugins/*.rb
365
+ ```
366
+ Plugins included with beniya by default. Provides basic functionality without external gem dependencies.
367
+
368
+ #### 2. User Plugins
369
+ ```
370
+ ~/.beniya/plugins/*.rb
371
+ ```
372
+ Plugins you can freely add. Can be obtained from GitHub Gist or raw URLs.
373
+
374
+ ### Creating Plugins
375
+
376
+ #### Simple Plugin Example
377
+
378
+ ```ruby
379
+ # ~/.beniya/plugins/hello.rb
380
+ module Beniya
381
+ module Plugins
382
+ class Hello < Plugin
383
+ def name
384
+ 'Hello'
385
+ end
386
+
387
+ def description
388
+ 'Simple greeting plugin'
389
+ end
390
+
391
+ def commands
392
+ {
393
+ hello: method(:say_hello)
394
+ }
395
+ end
396
+
397
+ private
398
+
399
+ def say_hello
400
+ puts "Hello from beniya!"
401
+ end
402
+ end
403
+ end
404
+ end
405
+ ```
406
+
407
+ #### Plugin with External Gem Dependencies
408
+
409
+ ```ruby
410
+ # ~/.beniya/plugins/ai_helper.rb
411
+ module Beniya
412
+ module Plugins
413
+ class AiHelper < Plugin
414
+ requires 'anthropic' # Declare gem dependency
415
+
416
+ def name
417
+ 'AiHelper'
418
+ end
419
+
420
+ def description
421
+ 'AI assistant using Claude API'
422
+ end
423
+
424
+ def commands
425
+ {
426
+ ai: method(:ask_ai)
427
+ }
428
+ end
429
+
430
+ def initialize
431
+ super # Run dependency check
432
+ @client = Anthropic::Client.new(
433
+ api_key: ENV['ANTHROPIC_API_KEY']
434
+ )
435
+ end
436
+
437
+ private
438
+
439
+ def ask_ai(question)
440
+ # AI processing
441
+ end
442
+ end
443
+ end
444
+ end
445
+ ```
446
+
447
+ ### Plugin Management
448
+
449
+ #### Enable/Disable Plugins
450
+
451
+ You can control plugin activation in `~/.beniya/config.yml`:
452
+
453
+ ```yaml
454
+ plugins:
455
+ fileoperations:
456
+ enabled: true
457
+ ai_helper:
458
+ enabled: true
459
+ my_custom:
460
+ enabled: false
461
+ ```
462
+
463
+ #### Default Behavior
464
+
465
+ - No `config.yml` → All plugins enabled
466
+ - Plugin not in config → Enabled by default
467
+ - `enabled: false` explicitly set → Disabled
468
+
469
+ ### Plugin Distribution
470
+
471
+ #### Share via GitHub Gist
472
+
473
+ ```bash
474
+ # Plugin author
475
+ 1. Upload .rb file to GitHub Gist
476
+ 2. Share Raw URL with users
477
+
478
+ # User
479
+ $ mkdir -p ~/.beniya/plugins
480
+ $ curl -o ~/.beniya/plugins/my_plugin.rb [RAW_URL]
481
+ $ beniya
482
+ ✓ my_plugin loaded successfully
483
+ ```
484
+
485
+ #### Share via GitHub Repository
486
+
487
+ ```bash
488
+ # Plugin author
489
+ beniya-plugins/
490
+ ├── plugin1.rb
491
+ └── plugin2.rb
492
+
493
+ # User
494
+ $ curl -o ~/.beniya/plugins/plugin1.rb https://raw.githubusercontent.com/user/beniya-plugins/main/plugin1.rb
495
+ ```
496
+
497
+ ### Plugin Key Features
498
+
499
+ #### Required Methods
500
+
501
+ - `name`: Plugin name (required)
502
+ - `description`: Plugin description (optional, default: "")
503
+ - `version`: Plugin version (optional, default: "1.0.0")
504
+ - `commands`: Command definitions (optional, default: {})
505
+
506
+ #### Dependency Management
507
+
508
+ - `requires 'gem_name'`: Declare gem dependencies
509
+ - If dependencies are missing, displays warning and disables plugin
510
+ - beniya continues to start normally
511
+
512
+ #### Auto-registration
513
+
514
+ - Inheriting from `Plugin` class automatically registers with `PluginManager`
515
+ - No complex registration process needed
516
+
355
517
  ## Development
356
518
 
357
519
  ### Requirements
data/bin/beniya CHANGED
@@ -3,6 +3,9 @@
3
3
 
4
4
  require_relative '../lib/beniya'
5
5
 
6
+ # プラグインを読み込む
7
+ Beniya::PluginManager.load_all
8
+
6
9
  # コマンドライン引数の処理
7
10
  if ARGV.include?('--check-health') || ARGV.include?('-c')
8
11
  # ヘルスチェック実行