aicli 0.2.9 → 0.3.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.
- checksums.yaml +4 -4
- data/lib/aicli/helpers/completion.rb +13 -3
- data/lib/aicli/version.rb +1 -1
- 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: 3502a13ce44daa62a15e1e9bfe0bb20d372bca46b782f35dae8be05dac9dba1f
|
|
4
|
+
data.tar.gz: 7d4462f9b8bd94263aaf5da5ec87d35406f2b814842ad6217b0db0434ff027b1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3f6c788b8aa265951ac9dd7ad859659c8c695f57c0760e68b4f2d8683bd11070c78c714836a077e8c9cc161790e77899f0fdc83823b4a2c9657725a6340d4536
|
|
7
|
+
data.tar.gz: 0ac353b46b92efc2a4fc887e0732d767017c313bd54c0ff8dddfdf8300ffa2eba386c3c15843aa4bbfd99b0c5c17d94616cdf36c162e02838bf118711023ae62
|
|
@@ -4,7 +4,9 @@ module AiCli
|
|
|
4
4
|
module Helpers
|
|
5
5
|
module Completion
|
|
6
6
|
EXPLAIN_IN_SECOND_REQUEST = true
|
|
7
|
-
|
|
7
|
+
# Opening fence must include a newline after optional language tag (e.g. ```zsh\n).
|
|
8
|
+
# Using \n? allowed ``` alone to match while streaming, leaking "zsh" into "zshfind".
|
|
9
|
+
SHELL_CODE_EXCLUSIONS = [/```[a-zA-Z]*\n/i, /```[a-zA-Z]*/i, "\n"].freeze
|
|
8
10
|
|
|
9
11
|
module_function
|
|
10
12
|
|
|
@@ -184,7 +186,15 @@ module AiCli
|
|
|
184
186
|
handle_ruby_llm_error(e)
|
|
185
187
|
end
|
|
186
188
|
|
|
187
|
-
data
|
|
189
|
+
sanitize_script(data)
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
def sanitize_script(script)
|
|
193
|
+
text = script.to_s.strip
|
|
194
|
+
return text if text.empty?
|
|
195
|
+
|
|
196
|
+
shell = Regexp.escape(OsDetect.detect_shell)
|
|
197
|
+
text.sub(/\A#{shell}/i, '')
|
|
188
198
|
end
|
|
189
199
|
|
|
190
200
|
def handle_ruby_llm_error(error)
|
|
@@ -225,7 +235,7 @@ module AiCli
|
|
|
225
235
|
#{message}
|
|
226
236
|
MSG
|
|
227
237
|
end
|
|
228
|
-
private_class_method :stream_to_writer, :handle_ruby_llm_error
|
|
238
|
+
private_class_method :stream_to_writer, :handle_ruby_llm_error, :sanitize_script
|
|
229
239
|
end
|
|
230
240
|
end
|
|
231
241
|
end
|
data/lib/aicli/version.rb
CHANGED