llm-shell 0.10.0 → 0.11.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.
Files changed (260) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +21 -0
  3. data/README.md +24 -160
  4. data/exe/llm-shell +7 -0
  5. data/llm-shell.gemspec +26 -32
  6. metadata +36 -372
  7. data/bin/llm-shell +0 -21
  8. data/lib/llm/shell/command.rb +0 -88
  9. data/lib/llm/shell/commands/clear_screen.rb +0 -18
  10. data/lib/llm/shell/commands/debug_mode.rb +0 -12
  11. data/lib/llm/shell/commands/dir_import.rb +0 -33
  12. data/lib/llm/shell/commands/disable_tool.rb +0 -33
  13. data/lib/llm/shell/commands/enable_tool.rb +0 -33
  14. data/lib/llm/shell/commands/file_import.rb +0 -25
  15. data/lib/llm/shell/commands/help.rb +0 -53
  16. data/lib/llm/shell/commands/show_chat.rb +0 -31
  17. data/lib/llm/shell/commands/show_version.rb +0 -17
  18. data/lib/llm/shell/commands/system_prompt.rb +0 -21
  19. data/lib/llm/shell/completion.rb +0 -40
  20. data/lib/llm/shell/config.rb +0 -34
  21. data/lib/llm/shell/default.rb +0 -23
  22. data/lib/llm/shell/formatter.rb +0 -41
  23. data/lib/llm/shell/internal/coderay/lib/coderay/duo.rb +0 -81
  24. data/lib/llm/shell/internal/coderay/lib/coderay/encoders/_map.rb +0 -17
  25. data/lib/llm/shell/internal/coderay/lib/coderay/encoders/comment_filter.rb +0 -25
  26. data/lib/llm/shell/internal/coderay/lib/coderay/encoders/count.rb +0 -39
  27. data/lib/llm/shell/internal/coderay/lib/coderay/encoders/debug.rb +0 -49
  28. data/lib/llm/shell/internal/coderay/lib/coderay/encoders/debug_lint.rb +0 -63
  29. data/lib/llm/shell/internal/coderay/lib/coderay/encoders/div.rb +0 -23
  30. data/lib/llm/shell/internal/coderay/lib/coderay/encoders/encoder.rb +0 -190
  31. data/lib/llm/shell/internal/coderay/lib/coderay/encoders/filter.rb +0 -58
  32. data/lib/llm/shell/internal/coderay/lib/coderay/encoders/html/css.rb +0 -65
  33. data/lib/llm/shell/internal/coderay/lib/coderay/encoders/html/numbering.rb +0 -108
  34. data/lib/llm/shell/internal/coderay/lib/coderay/encoders/html/output.rb +0 -164
  35. data/lib/llm/shell/internal/coderay/lib/coderay/encoders/html.rb +0 -333
  36. data/lib/llm/shell/internal/coderay/lib/coderay/encoders/json.rb +0 -83
  37. data/lib/llm/shell/internal/coderay/lib/coderay/encoders/lines_of_code.rb +0 -45
  38. data/lib/llm/shell/internal/coderay/lib/coderay/encoders/lint.rb +0 -59
  39. data/lib/llm/shell/internal/coderay/lib/coderay/encoders/null.rb +0 -18
  40. data/lib/llm/shell/internal/coderay/lib/coderay/encoders/page.rb +0 -24
  41. data/lib/llm/shell/internal/coderay/lib/coderay/encoders/span.rb +0 -23
  42. data/lib/llm/shell/internal/coderay/lib/coderay/encoders/statistic.rb +0 -95
  43. data/lib/llm/shell/internal/coderay/lib/coderay/encoders/terminal.rb +0 -195
  44. data/lib/llm/shell/internal/coderay/lib/coderay/encoders/text.rb +0 -46
  45. data/lib/llm/shell/internal/coderay/lib/coderay/encoders/token_kind_filter.rb +0 -111
  46. data/lib/llm/shell/internal/coderay/lib/coderay/encoders/xml.rb +0 -72
  47. data/lib/llm/shell/internal/coderay/lib/coderay/encoders/yaml.rb +0 -50
  48. data/lib/llm/shell/internal/coderay/lib/coderay/encoders.rb +0 -18
  49. data/lib/llm/shell/internal/coderay/lib/coderay/for_redcloth.rb +0 -95
  50. data/lib/llm/shell/internal/coderay/lib/coderay/helpers/file_type.rb +0 -151
  51. data/lib/llm/shell/internal/coderay/lib/coderay/helpers/plugin.rb +0 -55
  52. data/lib/llm/shell/internal/coderay/lib/coderay/helpers/plugin_host.rb +0 -221
  53. data/lib/llm/shell/internal/coderay/lib/coderay/helpers/word_list.rb +0 -72
  54. data/lib/llm/shell/internal/coderay/lib/coderay/scanners/_map.rb +0 -24
  55. data/lib/llm/shell/internal/coderay/lib/coderay/scanners/c.rb +0 -189
  56. data/lib/llm/shell/internal/coderay/lib/coderay/scanners/clojure.rb +0 -217
  57. data/lib/llm/shell/internal/coderay/lib/coderay/scanners/cpp.rb +0 -217
  58. data/lib/llm/shell/internal/coderay/lib/coderay/scanners/css.rb +0 -196
  59. data/lib/llm/shell/internal/coderay/lib/coderay/scanners/debug.rb +0 -75
  60. data/lib/llm/shell/internal/coderay/lib/coderay/scanners/delphi.rb +0 -144
  61. data/lib/llm/shell/internal/coderay/lib/coderay/scanners/diff.rb +0 -221
  62. data/lib/llm/shell/internal/coderay/lib/coderay/scanners/erb.rb +0 -81
  63. data/lib/llm/shell/internal/coderay/lib/coderay/scanners/go.rb +0 -208
  64. data/lib/llm/shell/internal/coderay/lib/coderay/scanners/groovy.rb +0 -268
  65. data/lib/llm/shell/internal/coderay/lib/coderay/scanners/haml.rb +0 -168
  66. data/lib/llm/shell/internal/coderay/lib/coderay/scanners/html.rb +0 -275
  67. data/lib/llm/shell/internal/coderay/lib/coderay/scanners/java/builtin_types.rb +0 -421
  68. data/lib/llm/shell/internal/coderay/lib/coderay/scanners/java.rb +0 -174
  69. data/lib/llm/shell/internal/coderay/lib/coderay/scanners/java_script.rb +0 -236
  70. data/lib/llm/shell/internal/coderay/lib/coderay/scanners/json.rb +0 -98
  71. data/lib/llm/shell/internal/coderay/lib/coderay/scanners/lua.rb +0 -280
  72. data/lib/llm/shell/internal/coderay/lib/coderay/scanners/php.rb +0 -527
  73. data/lib/llm/shell/internal/coderay/lib/coderay/scanners/python.rb +0 -287
  74. data/lib/llm/shell/internal/coderay/lib/coderay/scanners/raydebug.rb +0 -75
  75. data/lib/llm/shell/internal/coderay/lib/coderay/scanners/ruby/patterns.rb +0 -178
  76. data/lib/llm/shell/internal/coderay/lib/coderay/scanners/ruby/string_state.rb +0 -79
  77. data/lib/llm/shell/internal/coderay/lib/coderay/scanners/ruby.rb +0 -477
  78. data/lib/llm/shell/internal/coderay/lib/coderay/scanners/sass.rb +0 -232
  79. data/lib/llm/shell/internal/coderay/lib/coderay/scanners/scanner.rb +0 -337
  80. data/lib/llm/shell/internal/coderay/lib/coderay/scanners/sql.rb +0 -169
  81. data/lib/llm/shell/internal/coderay/lib/coderay/scanners/taskpaper.rb +0 -36
  82. data/lib/llm/shell/internal/coderay/lib/coderay/scanners/text.rb +0 -26
  83. data/lib/llm/shell/internal/coderay/lib/coderay/scanners/xml.rb +0 -17
  84. data/lib/llm/shell/internal/coderay/lib/coderay/scanners/yaml.rb +0 -140
  85. data/lib/llm/shell/internal/coderay/lib/coderay/scanners.rb +0 -27
  86. data/lib/llm/shell/internal/coderay/lib/coderay/styles/_map.rb +0 -7
  87. data/lib/llm/shell/internal/coderay/lib/coderay/styles/alpha.rb +0 -153
  88. data/lib/llm/shell/internal/coderay/lib/coderay/styles/style.rb +0 -18
  89. data/lib/llm/shell/internal/coderay/lib/coderay/styles.rb +0 -15
  90. data/lib/llm/shell/internal/coderay/lib/coderay/token_kinds.rb +0 -85
  91. data/lib/llm/shell/internal/coderay/lib/coderay/tokens.rb +0 -164
  92. data/lib/llm/shell/internal/coderay/lib/coderay/tokens_proxy.rb +0 -55
  93. data/lib/llm/shell/internal/coderay/lib/coderay/version.rb +0 -3
  94. data/lib/llm/shell/internal/coderay/lib/coderay.rb +0 -284
  95. data/lib/llm/shell/internal/io-line/lib/io/line/multiple.rb +0 -19
  96. data/lib/llm/shell/internal/io-line/lib/io/line.rb +0 -28
  97. data/lib/llm/shell/internal/llm.rb/lib/llm/bot/builder.rb +0 -31
  98. data/lib/llm/shell/internal/llm.rb/lib/llm/bot/conversable.rb +0 -37
  99. data/lib/llm/shell/internal/llm.rb/lib/llm/bot/prompt/completion.rb +0 -49
  100. data/lib/llm/shell/internal/llm.rb/lib/llm/bot/prompt/respond.rb +0 -49
  101. data/lib/llm/shell/internal/llm.rb/lib/llm/bot.rb +0 -150
  102. data/lib/llm/shell/internal/llm.rb/lib/llm/buffer.rb +0 -162
  103. data/lib/llm/shell/internal/llm.rb/lib/llm/client.rb +0 -36
  104. data/lib/llm/shell/internal/llm.rb/lib/llm/error.rb +0 -49
  105. data/lib/llm/shell/internal/llm.rb/lib/llm/eventhandler.rb +0 -44
  106. data/lib/llm/shell/internal/llm.rb/lib/llm/eventstream/event.rb +0 -69
  107. data/lib/llm/shell/internal/llm.rb/lib/llm/eventstream/parser.rb +0 -88
  108. data/lib/llm/shell/internal/llm.rb/lib/llm/eventstream.rb +0 -8
  109. data/lib/llm/shell/internal/llm.rb/lib/llm/file.rb +0 -91
  110. data/lib/llm/shell/internal/llm.rb/lib/llm/function.rb +0 -177
  111. data/lib/llm/shell/internal/llm.rb/lib/llm/message.rb +0 -178
  112. data/lib/llm/shell/internal/llm.rb/lib/llm/mime.rb +0 -140
  113. data/lib/llm/shell/internal/llm.rb/lib/llm/multipart.rb +0 -101
  114. data/lib/llm/shell/internal/llm.rb/lib/llm/object/builder.rb +0 -38
  115. data/lib/llm/shell/internal/llm.rb/lib/llm/object/kernel.rb +0 -53
  116. data/lib/llm/shell/internal/llm.rb/lib/llm/object.rb +0 -89
  117. data/lib/llm/shell/internal/llm.rb/lib/llm/provider.rb +0 -352
  118. data/lib/llm/shell/internal/llm.rb/lib/llm/providers/anthropic/error_handler.rb +0 -36
  119. data/lib/llm/shell/internal/llm.rb/lib/llm/providers/anthropic/files.rb +0 -155
  120. data/lib/llm/shell/internal/llm.rb/lib/llm/providers/anthropic/format/completion_format.rb +0 -88
  121. data/lib/llm/shell/internal/llm.rb/lib/llm/providers/anthropic/format.rb +0 -29
  122. data/lib/llm/shell/internal/llm.rb/lib/llm/providers/anthropic/models.rb +0 -54
  123. data/lib/llm/shell/internal/llm.rb/lib/llm/providers/anthropic/response/completion.rb +0 -39
  124. data/lib/llm/shell/internal/llm.rb/lib/llm/providers/anthropic/response/enumerable.rb +0 -11
  125. data/lib/llm/shell/internal/llm.rb/lib/llm/providers/anthropic/response/file.rb +0 -23
  126. data/lib/llm/shell/internal/llm.rb/lib/llm/providers/anthropic/response/web_search.rb +0 -21
  127. data/lib/llm/shell/internal/llm.rb/lib/llm/providers/anthropic/stream_parser.rb +0 -66
  128. data/lib/llm/shell/internal/llm.rb/lib/llm/providers/anthropic.rb +0 -138
  129. data/lib/llm/shell/internal/llm.rb/lib/llm/providers/deepseek/format/completion_format.rb +0 -68
  130. data/lib/llm/shell/internal/llm.rb/lib/llm/providers/deepseek/format.rb +0 -27
  131. data/lib/llm/shell/internal/llm.rb/lib/llm/providers/deepseek.rb +0 -75
  132. data/lib/llm/shell/internal/llm.rb/lib/llm/providers/gemini/audio.rb +0 -73
  133. data/lib/llm/shell/internal/llm.rb/lib/llm/providers/gemini/error_handler.rb +0 -47
  134. data/lib/llm/shell/internal/llm.rb/lib/llm/providers/gemini/files.rb +0 -146
  135. data/lib/llm/shell/internal/llm.rb/lib/llm/providers/gemini/format/completion_format.rb +0 -69
  136. data/lib/llm/shell/internal/llm.rb/lib/llm/providers/gemini/format.rb +0 -39
  137. data/lib/llm/shell/internal/llm.rb/lib/llm/providers/gemini/images.rb +0 -133
  138. data/lib/llm/shell/internal/llm.rb/lib/llm/providers/gemini/models.rb +0 -60
  139. data/lib/llm/shell/internal/llm.rb/lib/llm/providers/gemini/response/completion.rb +0 -35
  140. data/lib/llm/shell/internal/llm.rb/lib/llm/providers/gemini/response/embedding.rb +0 -8
  141. data/lib/llm/shell/internal/llm.rb/lib/llm/providers/gemini/response/file.rb +0 -11
  142. data/lib/llm/shell/internal/llm.rb/lib/llm/providers/gemini/response/files.rb +0 -15
  143. data/lib/llm/shell/internal/llm.rb/lib/llm/providers/gemini/response/image.rb +0 -31
  144. data/lib/llm/shell/internal/llm.rb/lib/llm/providers/gemini/response/models.rb +0 -15
  145. data/lib/llm/shell/internal/llm.rb/lib/llm/providers/gemini/response/web_search.rb +0 -22
  146. data/lib/llm/shell/internal/llm.rb/lib/llm/providers/gemini/stream_parser.rb +0 -86
  147. data/lib/llm/shell/internal/llm.rb/lib/llm/providers/gemini.rb +0 -173
  148. data/lib/llm/shell/internal/llm.rb/lib/llm/providers/llamacpp.rb +0 -74
  149. data/lib/llm/shell/internal/llm.rb/lib/llm/providers/ollama/error_handler.rb +0 -36
  150. data/lib/llm/shell/internal/llm.rb/lib/llm/providers/ollama/format/completion_format.rb +0 -77
  151. data/lib/llm/shell/internal/llm.rb/lib/llm/providers/ollama/format.rb +0 -29
  152. data/lib/llm/shell/internal/llm.rb/lib/llm/providers/ollama/models.rb +0 -56
  153. data/lib/llm/shell/internal/llm.rb/lib/llm/providers/ollama/response/completion.rb +0 -28
  154. data/lib/llm/shell/internal/llm.rb/lib/llm/providers/ollama/response/embedding.rb +0 -9
  155. data/lib/llm/shell/internal/llm.rb/lib/llm/providers/ollama/stream_parser.rb +0 -44
  156. data/lib/llm/shell/internal/llm.rb/lib/llm/providers/ollama.rb +0 -116
  157. data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/audio.rb +0 -91
  158. data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/error_handler.rb +0 -46
  159. data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/files.rb +0 -134
  160. data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/format/completion_format.rb +0 -90
  161. data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/format/moderation_format.rb +0 -35
  162. data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/format/respond_format.rb +0 -72
  163. data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/format.rb +0 -54
  164. data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/images.rb +0 -109
  165. data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/models.rb +0 -55
  166. data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/moderations.rb +0 -65
  167. data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/response/audio.rb +0 -7
  168. data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/response/completion.rb +0 -40
  169. data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/response/embedding.rb +0 -9
  170. data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/response/enumerable.rb +0 -23
  171. data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/response/file.rb +0 -7
  172. data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/response/image.rb +0 -16
  173. data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/response/moderations.rb +0 -34
  174. data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/response/responds.rb +0 -48
  175. data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/response/web_search.rb +0 -21
  176. data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/responses/stream_parser.rb +0 -76
  177. data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/responses.rb +0 -99
  178. data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/stream_parser.rb +0 -86
  179. data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/vector_stores.rb +0 -228
  180. data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai.rb +0 -206
  181. data/lib/llm/shell/internal/llm.rb/lib/llm/providers/xai/images.rb +0 -58
  182. data/lib/llm/shell/internal/llm.rb/lib/llm/providers/xai.rb +0 -72
  183. data/lib/llm/shell/internal/llm.rb/lib/llm/providers/zai.rb +0 -74
  184. data/lib/llm/shell/internal/llm.rb/lib/llm/response.rb +0 -67
  185. data/lib/llm/shell/internal/llm.rb/lib/llm/schema/array.rb +0 -26
  186. data/lib/llm/shell/internal/llm.rb/lib/llm/schema/boolean.rb +0 -13
  187. data/lib/llm/shell/internal/llm.rb/lib/llm/schema/integer.rb +0 -43
  188. data/lib/llm/shell/internal/llm.rb/lib/llm/schema/leaf.rb +0 -78
  189. data/lib/llm/shell/internal/llm.rb/lib/llm/schema/null.rb +0 -13
  190. data/lib/llm/shell/internal/llm.rb/lib/llm/schema/number.rb +0 -43
  191. data/lib/llm/shell/internal/llm.rb/lib/llm/schema/object.rb +0 -41
  192. data/lib/llm/shell/internal/llm.rb/lib/llm/schema/string.rb +0 -34
  193. data/lib/llm/shell/internal/llm.rb/lib/llm/schema/version.rb +0 -8
  194. data/lib/llm/shell/internal/llm.rb/lib/llm/schema.rb +0 -81
  195. data/lib/llm/shell/internal/llm.rb/lib/llm/server_tool.rb +0 -32
  196. data/lib/llm/shell/internal/llm.rb/lib/llm/tool/param.rb +0 -75
  197. data/lib/llm/shell/internal/llm.rb/lib/llm/tool.rb +0 -78
  198. data/lib/llm/shell/internal/llm.rb/lib/llm/utils.rb +0 -19
  199. data/lib/llm/shell/internal/llm.rb/lib/llm/version.rb +0 -5
  200. data/lib/llm/shell/internal/llm.rb/lib/llm.rb +0 -121
  201. data/lib/llm/shell/internal/optparse/lib/optionparser.rb +0 -2
  202. data/lib/llm/shell/internal/optparse/lib/optparse/ac.rb +0 -70
  203. data/lib/llm/shell/internal/optparse/lib/optparse/date.rb +0 -18
  204. data/lib/llm/shell/internal/optparse/lib/optparse/kwargs.rb +0 -27
  205. data/lib/llm/shell/internal/optparse/lib/optparse/shellwords.rb +0 -7
  206. data/lib/llm/shell/internal/optparse/lib/optparse/time.rb +0 -11
  207. data/lib/llm/shell/internal/optparse/lib/optparse/uri.rb +0 -7
  208. data/lib/llm/shell/internal/optparse/lib/optparse/version.rb +0 -80
  209. data/lib/llm/shell/internal/optparse/lib/optparse.rb +0 -2469
  210. data/lib/llm/shell/internal/paint/lib/paint/constants.rb +0 -104
  211. data/lib/llm/shell/internal/paint/lib/paint/pa.rb +0 -13
  212. data/lib/llm/shell/internal/paint/lib/paint/rgb_colors.rb +0 -14
  213. data/lib/llm/shell/internal/paint/lib/paint/shortcuts.rb +0 -100
  214. data/lib/llm/shell/internal/paint/lib/paint/shortcuts_version.rb +0 -5
  215. data/lib/llm/shell/internal/paint/lib/paint/util.rb +0 -16
  216. data/lib/llm/shell/internal/paint/lib/paint/version.rb +0 -5
  217. data/lib/llm/shell/internal/paint/lib/paint.rb +0 -261
  218. data/lib/llm/shell/internal/reline/lib/reline/config.rb +0 -378
  219. data/lib/llm/shell/internal/reline/lib/reline/face.rb +0 -199
  220. data/lib/llm/shell/internal/reline/lib/reline/history.rb +0 -76
  221. data/lib/llm/shell/internal/reline/lib/reline/io/ansi.rb +0 -322
  222. data/lib/llm/shell/internal/reline/lib/reline/io/dumb.rb +0 -120
  223. data/lib/llm/shell/internal/reline/lib/reline/io/windows.rb +0 -530
  224. data/lib/llm/shell/internal/reline/lib/reline/io.rb +0 -55
  225. data/lib/llm/shell/internal/reline/lib/reline/key_actor/base.rb +0 -37
  226. data/lib/llm/shell/internal/reline/lib/reline/key_actor/composite.rb +0 -17
  227. data/lib/llm/shell/internal/reline/lib/reline/key_actor/emacs.rb +0 -517
  228. data/lib/llm/shell/internal/reline/lib/reline/key_actor/vi_command.rb +0 -518
  229. data/lib/llm/shell/internal/reline/lib/reline/key_actor/vi_insert.rb +0 -517
  230. data/lib/llm/shell/internal/reline/lib/reline/key_actor.rb +0 -8
  231. data/lib/llm/shell/internal/reline/lib/reline/key_stroke.rb +0 -119
  232. data/lib/llm/shell/internal/reline/lib/reline/kill_ring.rb +0 -125
  233. data/lib/llm/shell/internal/reline/lib/reline/line_editor.rb +0 -2356
  234. data/lib/llm/shell/internal/reline/lib/reline/unicode/east_asian_width.rb +0 -1292
  235. data/lib/llm/shell/internal/reline/lib/reline/unicode.rb +0 -421
  236. data/lib/llm/shell/internal/reline/lib/reline/version.rb +0 -3
  237. data/lib/llm/shell/internal/reline/lib/reline.rb +0 -527
  238. data/lib/llm/shell/internal/tomlrb/lib/tomlrb/generated_parser.rb +0 -712
  239. data/lib/llm/shell/internal/tomlrb/lib/tomlrb/handler.rb +0 -268
  240. data/lib/llm/shell/internal/tomlrb/lib/tomlrb/local_date.rb +0 -35
  241. data/lib/llm/shell/internal/tomlrb/lib/tomlrb/local_date_time.rb +0 -42
  242. data/lib/llm/shell/internal/tomlrb/lib/tomlrb/local_time.rb +0 -40
  243. data/lib/llm/shell/internal/tomlrb/lib/tomlrb/parser.rb +0 -21
  244. data/lib/llm/shell/internal/tomlrb/lib/tomlrb/scanner.rb +0 -92
  245. data/lib/llm/shell/internal/tomlrb/lib/tomlrb/string_utils.rb +0 -40
  246. data/lib/llm/shell/internal/tomlrb/lib/tomlrb/version.rb +0 -5
  247. data/lib/llm/shell/internal/tomlrb/lib/tomlrb.rb +0 -49
  248. data/lib/llm/shell/markdown.rb +0 -83
  249. data/lib/llm/shell/options.rb +0 -39
  250. data/lib/llm/shell/renderer.rb +0 -51
  251. data/lib/llm/shell/repl.rb +0 -111
  252. data/lib/llm/shell/tool.rb +0 -42
  253. data/lib/llm/shell/tools/read_file.rb +0 -15
  254. data/lib/llm/shell/tools/system.rb +0 -17
  255. data/lib/llm/shell/tools/write_file.rb +0 -16
  256. data/lib/llm/shell/version.rb +0 -8
  257. data/lib/llm/shell.rb +0 -132
  258. data/lib/llm-shell.rb +0 -3
  259. data/libexec/llm-shell/shell +0 -43
  260. data/share/llm-shell/prompts/default.txt +0 -21
@@ -1,421 +0,0 @@
1
- class Reline::Unicode
2
- EscapedPairs = {
3
- 0x00 => '^@',
4
- 0x01 => '^A', # C-a
5
- 0x02 => '^B',
6
- 0x03 => '^C',
7
- 0x04 => '^D',
8
- 0x05 => '^E',
9
- 0x06 => '^F',
10
- 0x07 => '^G',
11
- 0x08 => '^H', # Backspace
12
- 0x09 => '^I',
13
- 0x0A => '^J',
14
- 0x0B => '^K',
15
- 0x0C => '^L',
16
- 0x0D => '^M', # Enter
17
- 0x0E => '^N',
18
- 0x0F => '^O',
19
- 0x10 => '^P',
20
- 0x11 => '^Q',
21
- 0x12 => '^R',
22
- 0x13 => '^S',
23
- 0x14 => '^T',
24
- 0x15 => '^U',
25
- 0x16 => '^V',
26
- 0x17 => '^W',
27
- 0x18 => '^X',
28
- 0x19 => '^Y',
29
- 0x1A => '^Z', # C-z
30
- 0x1B => '^[', # C-[ C-3
31
- 0x1C => '^\\', # C-\
32
- 0x1D => '^]', # C-]
33
- 0x1E => '^^', # C-~ C-6
34
- 0x1F => '^_', # C-_ C-7
35
- 0x7F => '^?', # C-? C-8
36
- }
37
-
38
- NON_PRINTING_START = "\1"
39
- NON_PRINTING_END = "\2"
40
- CSI_REGEXP = /\e\[[\d;]*[ABCDEFGHJKSTfminsuhl]/
41
- OSC_REGEXP = /\e\]\d+(?:;[^;\a\e]+)*(?:\a|\e\\)/
42
- WIDTH_SCANNER = /\G(?:(#{NON_PRINTING_START})|(#{NON_PRINTING_END})|(#{CSI_REGEXP})|(#{OSC_REGEXP})|(\X))/o
43
-
44
- def self.escape_for_print(str)
45
- str.chars.map! { |gr|
46
- case gr
47
- when -"\n"
48
- gr
49
- when -"\t"
50
- -' '
51
- else
52
- EscapedPairs[gr.ord] || gr
53
- end
54
- }.join
55
- end
56
-
57
- def self.safe_encode(str, encoding)
58
- # Reline only supports utf-8 convertible string.
59
- converted = str.encode(encoding, invalid: :replace, undef: :replace)
60
- return converted if str.encoding == Encoding::UTF_8 || converted.encoding == Encoding::UTF_8 || converted.ascii_only?
61
-
62
- # This code is essentially doing the same thing as
63
- # `str.encode(utf8, **replace_options).encode(encoding, **replace_options)`
64
- # but also avoids unnecessary irreversible encoding conversion.
65
- converted.gsub(/\X/) do |c|
66
- c.encode(Encoding::UTF_8)
67
- c
68
- rescue Encoding::UndefinedConversionError
69
- '?'
70
- end
71
- end
72
-
73
- require 'reline/unicode/east_asian_width'
74
-
75
- def self.east_asian_width(ord)
76
- chunk_index = EastAsianWidth::CHUNK_LAST.bsearch_index { |o| ord <= o }
77
- size = EastAsianWidth::CHUNK_WIDTH[chunk_index]
78
- size == -1 ? Reline.ambiguous_width : size
79
- end
80
-
81
- def self.get_mbchar_width(mbchar)
82
- ord = mbchar.ord
83
- if ord <= 0x1F # in EscapedPairs
84
- return 2
85
- elsif mbchar.length == 1 && ord <= 0x7E # printable ASCII chars
86
- return 1
87
- end
88
-
89
- utf8_mbchar = mbchar.encode(Encoding::UTF_8)
90
- zwj = false
91
- utf8_mbchar.chars.sum do |c|
92
- if zwj
93
- zwj = false
94
- 0
95
- elsif c.ord == 0x200D # Zero Width Joiner
96
- zwj = true
97
- 0
98
- else
99
- east_asian_width(c.ord)
100
- end
101
- end
102
- end
103
-
104
- def self.calculate_width(str, allow_escape_code = false)
105
- if allow_escape_code
106
- width = 0
107
- rest = str.encode(Encoding::UTF_8)
108
- in_zero_width = false
109
- rest.scan(WIDTH_SCANNER) do |non_printing_start, non_printing_end, csi, osc, gc|
110
- case
111
- when non_printing_start
112
- in_zero_width = true
113
- when non_printing_end
114
- in_zero_width = false
115
- when csi, osc
116
- when gc
117
- unless in_zero_width
118
- width += get_mbchar_width(gc)
119
- end
120
- end
121
- end
122
- width
123
- else
124
- str.encode(Encoding::UTF_8).grapheme_clusters.inject(0) { |w, gc|
125
- w + get_mbchar_width(gc)
126
- }
127
- end
128
- end
129
-
130
- # This method is used by IRB
131
- def self.split_by_width(str, max_width)
132
- lines = split_line_by_width(str, max_width)
133
- [lines, lines.size]
134
- end
135
-
136
- def self.split_line_by_width(str, max_width, encoding = str.encoding, offset: 0)
137
- lines = [String.new(encoding: encoding)]
138
- width = offset
139
- rest = str.encode(Encoding::UTF_8)
140
- in_zero_width = false
141
- seq = String.new(encoding: encoding)
142
- rest.scan(WIDTH_SCANNER) do |non_printing_start, non_printing_end, csi, osc, gc|
143
- case
144
- when non_printing_start
145
- in_zero_width = true
146
- when non_printing_end
147
- in_zero_width = false
148
- when csi
149
- lines.last << csi
150
- unless in_zero_width
151
- if csi == -"\e[m" || csi == -"\e[0m"
152
- seq.clear
153
- else
154
- seq << csi
155
- end
156
- end
157
- when osc
158
- lines.last << osc
159
- seq << osc unless in_zero_width
160
- when gc
161
- unless in_zero_width
162
- mbchar_width = get_mbchar_width(gc)
163
- if (width += mbchar_width) > max_width
164
- width = mbchar_width
165
- lines << seq.dup
166
- end
167
- end
168
- lines.last << gc
169
- end
170
- end
171
- # The cursor moves to next line in first
172
- if width == max_width
173
- lines << String.new(encoding: encoding)
174
- end
175
- lines
176
- end
177
-
178
- def self.strip_non_printing_start_end(prompt)
179
- prompt.gsub(/\x01([^\x02]*)(?:\x02|\z)/) { $1 }
180
- end
181
-
182
- # Take a chunk of a String cut by width with escape sequences.
183
- def self.take_range(str, start_col, max_width)
184
- take_mbchar_range(str, start_col, max_width).first
185
- end
186
-
187
- def self.take_mbchar_range(str, start_col, width, cover_begin: false, cover_end: false, padding: false)
188
- chunk = String.new(encoding: str.encoding)
189
-
190
- end_col = start_col + width
191
- total_width = 0
192
- rest = str.encode(Encoding::UTF_8)
193
- in_zero_width = false
194
- chunk_start_col = nil
195
- chunk_end_col = nil
196
- has_csi = false
197
- rest.scan(WIDTH_SCANNER) do |non_printing_start, non_printing_end, csi, osc, gc|
198
- case
199
- when non_printing_start
200
- in_zero_width = true
201
- when non_printing_end
202
- in_zero_width = false
203
- when csi
204
- has_csi = true
205
- chunk << csi
206
- when osc
207
- chunk << osc
208
- when gc
209
- if in_zero_width
210
- chunk << gc
211
- next
212
- end
213
-
214
- mbchar_width = get_mbchar_width(gc)
215
- prev_width = total_width
216
- total_width += mbchar_width
217
-
218
- if (cover_begin || padding ? total_width <= start_col : prev_width < start_col)
219
- # Current character haven't reached start_col yet
220
- next
221
- elsif padding && !cover_begin && prev_width < start_col && start_col < total_width
222
- # Add preceding padding. This padding might have background color.
223
- chunk << ' ' * (total_width - start_col)
224
- chunk_start_col ||= start_col
225
- chunk_end_col = total_width
226
- next
227
- elsif (cover_end ? prev_width < end_col : total_width <= end_col)
228
- # Current character is in the range
229
- chunk << gc
230
- chunk_start_col ||= prev_width
231
- chunk_end_col = total_width
232
- break if total_width >= end_col
233
- else
234
- # Current character exceeds end_col
235
- if padding && end_col < total_width
236
- # Add succeeding padding. This padding might have background color.
237
- chunk << ' ' * (end_col - prev_width)
238
- chunk_start_col ||= prev_width
239
- chunk_end_col = end_col
240
- end
241
- break
242
- end
243
- end
244
- end
245
- chunk_start_col ||= start_col
246
- chunk_end_col ||= start_col
247
- if padding && chunk_end_col < end_col
248
- # Append padding. This padding should not include background color.
249
- chunk << "\e[0m" if has_csi
250
- chunk << ' ' * (end_col - chunk_end_col)
251
- chunk_end_col = end_col
252
- end
253
- [chunk, chunk_start_col, chunk_end_col - chunk_start_col]
254
- end
255
-
256
- def self.get_next_mbchar_size(line, byte_pointer)
257
- grapheme = line.byteslice(byte_pointer..-1).grapheme_clusters.first
258
- grapheme ? grapheme.bytesize : 0
259
- end
260
-
261
- def self.get_prev_mbchar_size(line, byte_pointer)
262
- if byte_pointer.zero?
263
- 0
264
- else
265
- grapheme = line.byteslice(0..(byte_pointer - 1)).grapheme_clusters.last
266
- grapheme ? grapheme.bytesize : 0
267
- end
268
- end
269
-
270
- def self.em_forward_word(line, byte_pointer)
271
- gcs = line.byteslice(byte_pointer..).grapheme_clusters
272
- nonwords = gcs.take_while { |c| !word_character?(c) }
273
- words = gcs.drop(nonwords.size).take_while { |c| word_character?(c) }
274
- nonwords.sum(&:bytesize) + words.sum(&:bytesize)
275
- end
276
-
277
- def self.em_forward_word_with_capitalization(line, byte_pointer)
278
- gcs = line.byteslice(byte_pointer..).grapheme_clusters
279
- nonwords = gcs.take_while { |c| !word_character?(c) }
280
- words = gcs.drop(nonwords.size).take_while { |c| word_character?(c) }
281
- [nonwords.sum(&:bytesize) + words.sum(&:bytesize), nonwords.join + words.join.capitalize]
282
- end
283
-
284
- def self.em_backward_word(line, byte_pointer)
285
- gcs = line.byteslice(0, byte_pointer).grapheme_clusters.reverse
286
- nonwords = gcs.take_while { |c| !word_character?(c) }
287
- words = gcs.drop(nonwords.size).take_while { |c| word_character?(c) }
288
- nonwords.sum(&:bytesize) + words.sum(&:bytesize)
289
- end
290
-
291
- def self.em_big_backward_word(line, byte_pointer)
292
- gcs = line.byteslice(0, byte_pointer).grapheme_clusters.reverse
293
- spaces = gcs.take_while { |c| space_character?(c) }
294
- nonspaces = gcs.drop(spaces.size).take_while { |c| !space_character?(c) }
295
- spaces.sum(&:bytesize) + nonspaces.sum(&:bytesize)
296
- end
297
-
298
- def self.ed_transpose_words(line, byte_pointer)
299
- gcs = line.byteslice(0, byte_pointer).grapheme_clusters
300
- pos = gcs.size
301
- gcs += line.byteslice(byte_pointer..).grapheme_clusters
302
- pos += 1 while pos < gcs.size && !word_character?(gcs[pos])
303
- if pos == gcs.size # 'aaa bbb [cursor] '
304
- pos -= 1 while pos > 0 && !word_character?(gcs[pos - 1])
305
- second_word_end = gcs.size
306
- else # 'aaa [cursor]bbb'
307
- pos += 1 while pos < gcs.size && word_character?(gcs[pos])
308
- second_word_end = pos
309
- end
310
- pos -= 1 while pos > 0 && word_character?(gcs[pos - 1])
311
- second_word_start = pos
312
- pos -= 1 while pos > 0 && !word_character?(gcs[pos - 1])
313
- first_word_end = pos
314
- pos -= 1 while pos > 0 && word_character?(gcs[pos - 1])
315
- first_word_start = pos
316
-
317
- [first_word_start, first_word_end, second_word_start, second_word_end].map do |idx|
318
- gcs.take(idx).sum(&:bytesize)
319
- end
320
- end
321
-
322
- def self.vi_big_forward_word(line, byte_pointer)
323
- gcs = line.byteslice(byte_pointer..).grapheme_clusters
324
- nonspaces = gcs.take_while { |c| !space_character?(c) }
325
- spaces = gcs.drop(nonspaces.size).take_while { |c| space_character?(c) }
326
- nonspaces.sum(&:bytesize) + spaces.sum(&:bytesize)
327
- end
328
-
329
- def self.vi_big_forward_end_word(line, byte_pointer)
330
- gcs = line.byteslice(byte_pointer..).grapheme_clusters
331
- first = gcs.shift(1)
332
- spaces = gcs.take_while { |c| space_character?(c) }
333
- nonspaces = gcs.drop(spaces.size).take_while { |c| !space_character?(c) }
334
- matched = spaces + nonspaces
335
- matched.pop
336
- first.sum(&:bytesize) + matched.sum(&:bytesize)
337
- end
338
-
339
- def self.vi_big_backward_word(line, byte_pointer)
340
- gcs = line.byteslice(0, byte_pointer).grapheme_clusters.reverse
341
- spaces = gcs.take_while { |c| space_character?(c) }
342
- nonspaces = gcs.drop(spaces.size).take_while { |c| !space_character?(c) }
343
- spaces.sum(&:bytesize) + nonspaces.sum(&:bytesize)
344
- end
345
-
346
- def self.vi_forward_word(line, byte_pointer, drop_terminate_spaces = false)
347
- gcs = line.byteslice(byte_pointer..).grapheme_clusters
348
- return 0 if gcs.empty?
349
-
350
- c = gcs.first
351
- matched =
352
- if word_character?(c)
353
- gcs.take_while { |c| word_character?(c) }
354
- elsif space_character?(c)
355
- gcs.take_while { |c| space_character?(c) }
356
- else
357
- gcs.take_while { |c| !word_character?(c) && !space_character?(c) }
358
- end
359
-
360
- return matched.sum(&:bytesize) if drop_terminate_spaces
361
-
362
- spaces = gcs.drop(matched.size).take_while { |c| space_character?(c) }
363
- matched.sum(&:bytesize) + spaces.sum(&:bytesize)
364
- end
365
-
366
- def self.vi_forward_end_word(line, byte_pointer)
367
- gcs = line.byteslice(byte_pointer..).grapheme_clusters
368
- return 0 if gcs.empty?
369
- return gcs.first.bytesize if gcs.size == 1
370
-
371
- start = gcs.shift
372
- skips = [start]
373
- if space_character?(start) || space_character?(gcs.first)
374
- spaces = gcs.take_while { |c| space_character?(c) }
375
- skips += spaces
376
- gcs.shift(spaces.size)
377
- end
378
- start_with_word = word_character?(gcs.first)
379
- matched = gcs.take_while { |c| start_with_word ? word_character?(c) : !word_character?(c) && !space_character?(c) }
380
- matched.pop
381
- skips.sum(&:bytesize) + matched.sum(&:bytesize)
382
- end
383
-
384
- def self.vi_backward_word(line, byte_pointer)
385
- gcs = line.byteslice(0, byte_pointer).grapheme_clusters.reverse
386
- spaces = gcs.take_while { |c| space_character?(c) }
387
- gcs.shift(spaces.size)
388
- start_with_word = word_character?(gcs.first)
389
- matched = gcs.take_while { |c| start_with_word ? word_character?(c) : !word_character?(c) && !space_character?(c) }
390
- spaces.sum(&:bytesize) + matched.sum(&:bytesize)
391
- end
392
-
393
- def self.common_prefix(list, ignore_case: false)
394
- return '' if list.empty?
395
-
396
- common_prefix_gcs = list.first.grapheme_clusters
397
- list.each do |item|
398
- gcs = item.grapheme_clusters
399
- common_prefix_gcs = common_prefix_gcs.take_while.with_index do |gc, i|
400
- ignore_case ? gc.casecmp?(gcs[i]) : gc == gcs[i]
401
- end
402
- end
403
- common_prefix_gcs.join
404
- end
405
-
406
- def self.vi_first_print(line)
407
- gcs = line.grapheme_clusters
408
- spaces = gcs.take_while { |c| space_character?(c) }
409
- spaces.sum(&:bytesize)
410
- end
411
-
412
- def self.word_character?(s)
413
- s.encode(Encoding::UTF_8).match?(/\p{Word}/) if s
414
- rescue Encoding::UndefinedConversionError
415
- false
416
- end
417
-
418
- def self.space_character?(s)
419
- s.match?(/\s/) if s
420
- end
421
- end
@@ -1,3 +0,0 @@
1
- module Reline
2
- VERSION = '0.6.2'
3
- end