swarm_cli 2.0.0 → 2.0.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c76f2194c98896ffdd5f1c16a08e0ce0460d3430efc9c4f21adc4999c1af73f7
4
- data.tar.gz: c004295295b56474ba2eafad610fb2804ae9e8d171d1103b08faa5d7e93881a0
3
+ metadata.gz: f57ce5f511e43f8c520bf787d993cdcff34f3152870d496f72b5bbdee962c1a5
4
+ data.tar.gz: e21157d97dfce0fc71806683b6cb755c0e5ce9901c43c71764aab2b398d23fb1
5
5
  SHA512:
6
- metadata.gz: 8203e59b81a125b4d1ae7188e3a90e9158c228882e15237be1475e64a9ace7489ad0879f8a6507cdd1d0fba7f09ed448e574cbe5df424727f0ddafd06e4d4bd3
7
- data.tar.gz: f433f4105c2adeec9e37b8d0539a81180ba5d66d0b979529acd604906fecb1c575f80c352c6620ce89faff6300d0e4ab40b76714c8af71b11e87f25f494da81e
6
+ metadata.gz: e8702078d6573711ebe3c08c74571c0ce3d6b1de19810fa324cf6a38122573c7268c906b35e9f3446eb812dbad7d06ce4b61a01e24ff4c2ba5d56244f2b659d0
7
+ data.tar.gz: 252d1ee2ad3acb39f4302a558ec8633a5eba854522b6924362ecbee4db9f0dfdfe92020a531333d615f1402879b3d2ea8ed9ee4ee140ec668c59a6ad5254f20e
data/lib/swarm_cli/cli.rb CHANGED
@@ -4,7 +4,6 @@ module SwarmCLI
4
4
  class CLI
5
5
  class << self
6
6
  def start(args)
7
- SwarmSDK.refresh_models_silently
8
7
  new(args).run
9
8
  end
10
9
  end
@@ -496,6 +496,23 @@ module SwarmCLI
496
496
  # Capture COMMANDS for use in lambda
497
497
  commands = COMMANDS
498
498
 
499
+ # Capture file completion logic for use in lambda (since lambda runs in different context)
500
+ file_completions = lambda do |target|
501
+ has_at_prefix = target.start_with?("@")
502
+ query = has_at_prefix ? target[1..] : target
503
+
504
+ next Dir.glob("*").sort.first(20) if query.empty?
505
+
506
+ # Find files matching query anywhere in path
507
+ pattern = "**/*#{query}*"
508
+ found = Dir.glob(pattern, File::FNM_CASEFOLD).reject do |path|
509
+ path.split("/").any? { |part| part.start_with?(".") }
510
+ end.sort.first(20)
511
+
512
+ # Add @ prefix if needed
513
+ has_at_prefix ? found.map { |p| "@#{p}" } : found
514
+ end
515
+
499
516
  # Custom dialog proc for fuzzy file/command completion
500
517
  fuzzy_proc = lambda do
501
518
  # State: [pre, target, post, matches, pointer, navigating]
@@ -503,6 +520,20 @@ module SwarmCLI
503
520
  # Check if this is a navigation key press
504
521
  is_nav_key = key&.match?(dialog.name)
505
522
 
523
+ # If we were in navigation mode and user typed a regular key (not Tab), exit nav mode
524
+ if !context.empty? && context.size >= 6 && context[5] && !is_nav_key
525
+ context[5] = false # Exit navigation mode
526
+ end
527
+
528
+ # Early check: if user typed and current target has spaces, close dialog
529
+ unless is_nav_key || context.empty?
530
+ _, target_check, = retrieve_completion_block
531
+ if target_check.include?(" ")
532
+ context.clear
533
+ return
534
+ end
535
+ end
536
+
506
537
  # Detect if we should recalculate matches
507
538
  should_recalculate = if context.empty?
508
539
  true # First time - initialize
@@ -529,8 +560,8 @@ module SwarmCLI
529
560
  query.empty? || cmd.downcase.include?(query.downcase)
530
561
  end.sort
531
562
  elsif target.start_with?("@") || target.include?("/")
532
- # File path completions - extract to reduce nesting
533
- get_file_completions(target)
563
+ # File path completions - use captured lambda
564
+ file_completions.call(target)
534
565
  end
535
566
 
536
567
  return if matches.nil? || matches.empty?
@@ -605,23 +636,5 @@ module SwarmCLI
605
636
  # Register the custom fuzzy dialog
606
637
  Reline.add_dialog_proc(:fuzzy_complete, fuzzy_proc, [])
607
638
  end
608
-
609
- # Get file path completions with fuzzy matching
610
- # Extracted to reduce block nesting in the dialog lambda
611
- def get_file_completions(target)
612
- has_at_prefix = target.start_with?("@")
613
- query = has_at_prefix ? target[1..] : target
614
-
615
- return Dir.glob("*").sort.first(20) if query.empty?
616
-
617
- # Find files matching query anywhere in path
618
- pattern = "**/*#{query}*"
619
- found = Dir.glob(pattern, File::FNM_CASEFOLD).reject do |path|
620
- path.split("/").any? { |part| part.start_with?(".") }
621
- end.sort.first(20)
622
-
623
- # Add @ prefix if needed
624
- has_at_prefix ? found.map { |p| "@#{p}" } : found
625
- end
626
639
  end
627
640
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SwarmCLI
4
- VERSION = "2.0.0"
4
+ VERSION = "2.0.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: swarm_cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paulo Arruda