swarm_cli 3.0.0.alpha3 → 3.0.0.alpha4

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 (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/swarm_cli/v3/cli.rb +30 -3
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 733ba737a80d7fd602ef6e4482547167cf36e8b1ed8fdc80a78594aee0174df2
4
- data.tar.gz: ea4acde5fddc3f37907df76ed3730a3ec4c6ed38a75340d31386802405b205d7
3
+ metadata.gz: a4a46dc28301d9944d4780989720a455736cdd45f5f770c7ac1b3d0d44e4740e
4
+ data.tar.gz: daf3e6f7887eef22b502e74da0c527f19c10c99e4a99da7441367cc131ad62bc
5
5
  SHA512:
6
- metadata.gz: e329d281f641dc43edb4dc94a6aef054b72b01595030f6f52ec86e281c6bcb77331ffa806c3a8b57d958b2919ece3a06eb2a5c46628a7f06cce80eef17a3cc85
7
- data.tar.gz: 67aa0df4a2772992df89ee3f50aa8135ee895262995603ba60553b1fa0ac1eea4dddecbc75979d305d79c7b0759892c9ba3c2b1f2479e56b8d531f6e23a52546
6
+ metadata.gz: 2a9f88d5825f7c5d2ac65d5c891d5f44c35902fb54ba1caf691c8a79a22ecccce5957a6c8e03144ab51077f34b02c440afd6f79ff596f27cdddef5a1c30aad10
7
+ data.tar.gz: c77b804edb2b3c2f348630424ad803d4d1da6d047f0717ba74d593f3989f0a0fe854407163feab417bf7816a96b37fafc852e23133bfc3789becd5e0653e9d17
@@ -55,18 +55,45 @@ module SwarmCLI
55
55
 
56
56
  # Expand @file mentions to include file contents.
57
57
  # This is a public utility method that can be used for testing.
58
+ # Uses Read tool for consistent file handling including documents.
58
59
  #
59
60
  # @param prompt [String] the prompt text with @file mentions
60
61
  # @param display [Display, nil] optional display to show read status
61
62
  # @return [String] the expanded prompt with file contents
62
63
  def expand_file_mentions(prompt, display: nil)
64
+ # Create Read tool for consistent file handling (including documents)
65
+ read_tracker = SwarmSDK::V3::Tools::ReadTracker.new
66
+ read_tool = SwarmSDK::V3::Tools::Read.new(
67
+ agent_name: :cli,
68
+ directory: Dir.pwd,
69
+ read_tracker: read_tracker,
70
+ )
71
+
63
72
  prompt.gsub(%r{@([\w/.~-]+)}) do |match|
64
73
  path = Regexp.last_match(1)
65
74
 
66
75
  if File.file?(path)
67
- content = File.read(path, encoding: "UTF-8")
68
- display&.agent_print(ANSIColors.dim(" \u{1F4C4} Read @#{path}"))
69
- "\n\n<file path=\"#{path}\">\n#{content}\n</file>\n"
76
+ result = read_tool.execute(file_path: path)
77
+
78
+ # Handle result types
79
+ case result
80
+ when RubyLLM::Content
81
+ # Document with images
82
+ display&.agent_print(ANSIColors.dim(" \u{1F4C4} Read @#{path} (with images)"))
83
+ "\n\n<file path=\"#{path}\">\n#{result.text}\n</file>\n"
84
+ when /^<system-reminder>/
85
+ # Missing gem
86
+ display&.agent_print(ANSIColors.yellow(" \u26A0\uFE0F @#{path} requires gem"))
87
+ match # Keep original
88
+ when /^Error:/
89
+ # Conversion error
90
+ display&.agent_print(ANSIColors.yellow(" \u26A0\uFE0F Could not read @#{path}"))
91
+ match # Keep original
92
+ else
93
+ # Text content
94
+ display&.agent_print(ANSIColors.dim(" \u{1F4C4} Read @#{path}"))
95
+ "\n\n<file path=\"#{path}\">\n#{result}\n</file>\n"
96
+ end
70
97
  elsif File.directory?(path)
71
98
  entries = Dir.children(path).sort
72
99
  display&.agent_print(ANSIColors.dim(" \u{1F4C2} Read @#{path}/ (#{entries.size} entries)"))
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: 3.0.0.alpha3
4
+ version: 3.0.0.alpha4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paulo Arruda