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.
- checksums.yaml +4 -4
- data/lib/swarm_cli/v3/cli.rb +30 -3
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a4a46dc28301d9944d4780989720a455736cdd45f5f770c7ac1b3d0d44e4740e
|
|
4
|
+
data.tar.gz: daf3e6f7887eef22b502e74da0c527f19c10c99e4a99da7441367cc131ad62bc
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2a9f88d5825f7c5d2ac65d5c891d5f44c35902fb54ba1caf691c8a79a22ecccce5957a6c8e03144ab51077f34b02c440afd6f79ff596f27cdddef5a1c30aad10
|
|
7
|
+
data.tar.gz: c77b804edb2b3c2f348630424ad803d4d1da6d047f0717ba74d593f3989f0a0fe854407163feab417bf7816a96b37fafc852e23133bfc3789becd5e0653e9d17
|
data/lib/swarm_cli/v3/cli.rb
CHANGED
|
@@ -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
|
-
|
|
68
|
-
|
|
69
|
-
|
|
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)"))
|