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.
- checksums.yaml +4 -4
- data/LICENSE +21 -0
- data/README.md +24 -160
- data/exe/llm-shell +7 -0
- data/llm-shell.gemspec +26 -32
- metadata +36 -372
- data/bin/llm-shell +0 -21
- data/lib/llm/shell/command.rb +0 -88
- data/lib/llm/shell/commands/clear_screen.rb +0 -18
- data/lib/llm/shell/commands/debug_mode.rb +0 -12
- data/lib/llm/shell/commands/dir_import.rb +0 -33
- data/lib/llm/shell/commands/disable_tool.rb +0 -33
- data/lib/llm/shell/commands/enable_tool.rb +0 -33
- data/lib/llm/shell/commands/file_import.rb +0 -25
- data/lib/llm/shell/commands/help.rb +0 -53
- data/lib/llm/shell/commands/show_chat.rb +0 -31
- data/lib/llm/shell/commands/show_version.rb +0 -17
- data/lib/llm/shell/commands/system_prompt.rb +0 -21
- data/lib/llm/shell/completion.rb +0 -40
- data/lib/llm/shell/config.rb +0 -34
- data/lib/llm/shell/default.rb +0 -23
- data/lib/llm/shell/formatter.rb +0 -41
- data/lib/llm/shell/internal/coderay/lib/coderay/duo.rb +0 -81
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/_map.rb +0 -17
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/comment_filter.rb +0 -25
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/count.rb +0 -39
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/debug.rb +0 -49
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/debug_lint.rb +0 -63
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/div.rb +0 -23
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/encoder.rb +0 -190
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/filter.rb +0 -58
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/html/css.rb +0 -65
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/html/numbering.rb +0 -108
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/html/output.rb +0 -164
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/html.rb +0 -333
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/json.rb +0 -83
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/lines_of_code.rb +0 -45
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/lint.rb +0 -59
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/null.rb +0 -18
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/page.rb +0 -24
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/span.rb +0 -23
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/statistic.rb +0 -95
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/terminal.rb +0 -195
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/text.rb +0 -46
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/token_kind_filter.rb +0 -111
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/xml.rb +0 -72
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/yaml.rb +0 -50
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders.rb +0 -18
- data/lib/llm/shell/internal/coderay/lib/coderay/for_redcloth.rb +0 -95
- data/lib/llm/shell/internal/coderay/lib/coderay/helpers/file_type.rb +0 -151
- data/lib/llm/shell/internal/coderay/lib/coderay/helpers/plugin.rb +0 -55
- data/lib/llm/shell/internal/coderay/lib/coderay/helpers/plugin_host.rb +0 -221
- data/lib/llm/shell/internal/coderay/lib/coderay/helpers/word_list.rb +0 -72
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/_map.rb +0 -24
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/c.rb +0 -189
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/clojure.rb +0 -217
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/cpp.rb +0 -217
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/css.rb +0 -196
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/debug.rb +0 -75
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/delphi.rb +0 -144
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/diff.rb +0 -221
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/erb.rb +0 -81
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/go.rb +0 -208
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/groovy.rb +0 -268
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/haml.rb +0 -168
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/html.rb +0 -275
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/java/builtin_types.rb +0 -421
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/java.rb +0 -174
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/java_script.rb +0 -236
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/json.rb +0 -98
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/lua.rb +0 -280
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/php.rb +0 -527
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/python.rb +0 -287
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/raydebug.rb +0 -75
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/ruby/patterns.rb +0 -178
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/ruby/string_state.rb +0 -79
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/ruby.rb +0 -477
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/sass.rb +0 -232
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/scanner.rb +0 -337
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/sql.rb +0 -169
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/taskpaper.rb +0 -36
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/text.rb +0 -26
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/xml.rb +0 -17
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/yaml.rb +0 -140
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners.rb +0 -27
- data/lib/llm/shell/internal/coderay/lib/coderay/styles/_map.rb +0 -7
- data/lib/llm/shell/internal/coderay/lib/coderay/styles/alpha.rb +0 -153
- data/lib/llm/shell/internal/coderay/lib/coderay/styles/style.rb +0 -18
- data/lib/llm/shell/internal/coderay/lib/coderay/styles.rb +0 -15
- data/lib/llm/shell/internal/coderay/lib/coderay/token_kinds.rb +0 -85
- data/lib/llm/shell/internal/coderay/lib/coderay/tokens.rb +0 -164
- data/lib/llm/shell/internal/coderay/lib/coderay/tokens_proxy.rb +0 -55
- data/lib/llm/shell/internal/coderay/lib/coderay/version.rb +0 -3
- data/lib/llm/shell/internal/coderay/lib/coderay.rb +0 -284
- data/lib/llm/shell/internal/io-line/lib/io/line/multiple.rb +0 -19
- data/lib/llm/shell/internal/io-line/lib/io/line.rb +0 -28
- data/lib/llm/shell/internal/llm.rb/lib/llm/bot/builder.rb +0 -31
- data/lib/llm/shell/internal/llm.rb/lib/llm/bot/conversable.rb +0 -37
- data/lib/llm/shell/internal/llm.rb/lib/llm/bot/prompt/completion.rb +0 -49
- data/lib/llm/shell/internal/llm.rb/lib/llm/bot/prompt/respond.rb +0 -49
- data/lib/llm/shell/internal/llm.rb/lib/llm/bot.rb +0 -150
- data/lib/llm/shell/internal/llm.rb/lib/llm/buffer.rb +0 -162
- data/lib/llm/shell/internal/llm.rb/lib/llm/client.rb +0 -36
- data/lib/llm/shell/internal/llm.rb/lib/llm/error.rb +0 -49
- data/lib/llm/shell/internal/llm.rb/lib/llm/eventhandler.rb +0 -44
- data/lib/llm/shell/internal/llm.rb/lib/llm/eventstream/event.rb +0 -69
- data/lib/llm/shell/internal/llm.rb/lib/llm/eventstream/parser.rb +0 -88
- data/lib/llm/shell/internal/llm.rb/lib/llm/eventstream.rb +0 -8
- data/lib/llm/shell/internal/llm.rb/lib/llm/file.rb +0 -91
- data/lib/llm/shell/internal/llm.rb/lib/llm/function.rb +0 -177
- data/lib/llm/shell/internal/llm.rb/lib/llm/message.rb +0 -178
- data/lib/llm/shell/internal/llm.rb/lib/llm/mime.rb +0 -140
- data/lib/llm/shell/internal/llm.rb/lib/llm/multipart.rb +0 -101
- data/lib/llm/shell/internal/llm.rb/lib/llm/object/builder.rb +0 -38
- data/lib/llm/shell/internal/llm.rb/lib/llm/object/kernel.rb +0 -53
- data/lib/llm/shell/internal/llm.rb/lib/llm/object.rb +0 -89
- data/lib/llm/shell/internal/llm.rb/lib/llm/provider.rb +0 -352
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/anthropic/error_handler.rb +0 -36
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/anthropic/files.rb +0 -155
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/anthropic/format/completion_format.rb +0 -88
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/anthropic/format.rb +0 -29
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/anthropic/models.rb +0 -54
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/anthropic/response/completion.rb +0 -39
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/anthropic/response/enumerable.rb +0 -11
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/anthropic/response/file.rb +0 -23
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/anthropic/response/web_search.rb +0 -21
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/anthropic/stream_parser.rb +0 -66
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/anthropic.rb +0 -138
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/deepseek/format/completion_format.rb +0 -68
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/deepseek/format.rb +0 -27
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/deepseek.rb +0 -75
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/gemini/audio.rb +0 -73
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/gemini/error_handler.rb +0 -47
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/gemini/files.rb +0 -146
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/gemini/format/completion_format.rb +0 -69
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/gemini/format.rb +0 -39
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/gemini/images.rb +0 -133
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/gemini/models.rb +0 -60
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/gemini/response/completion.rb +0 -35
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/gemini/response/embedding.rb +0 -8
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/gemini/response/file.rb +0 -11
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/gemini/response/files.rb +0 -15
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/gemini/response/image.rb +0 -31
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/gemini/response/models.rb +0 -15
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/gemini/response/web_search.rb +0 -22
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/gemini/stream_parser.rb +0 -86
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/gemini.rb +0 -173
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/llamacpp.rb +0 -74
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/ollama/error_handler.rb +0 -36
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/ollama/format/completion_format.rb +0 -77
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/ollama/format.rb +0 -29
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/ollama/models.rb +0 -56
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/ollama/response/completion.rb +0 -28
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/ollama/response/embedding.rb +0 -9
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/ollama/stream_parser.rb +0 -44
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/ollama.rb +0 -116
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/audio.rb +0 -91
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/error_handler.rb +0 -46
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/files.rb +0 -134
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/format/completion_format.rb +0 -90
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/format/moderation_format.rb +0 -35
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/format/respond_format.rb +0 -72
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/format.rb +0 -54
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/images.rb +0 -109
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/models.rb +0 -55
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/moderations.rb +0 -65
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/response/audio.rb +0 -7
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/response/completion.rb +0 -40
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/response/embedding.rb +0 -9
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/response/enumerable.rb +0 -23
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/response/file.rb +0 -7
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/response/image.rb +0 -16
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/response/moderations.rb +0 -34
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/response/responds.rb +0 -48
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/response/web_search.rb +0 -21
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/responses/stream_parser.rb +0 -76
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/responses.rb +0 -99
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/stream_parser.rb +0 -86
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/vector_stores.rb +0 -228
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai.rb +0 -206
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/xai/images.rb +0 -58
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/xai.rb +0 -72
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/zai.rb +0 -74
- data/lib/llm/shell/internal/llm.rb/lib/llm/response.rb +0 -67
- data/lib/llm/shell/internal/llm.rb/lib/llm/schema/array.rb +0 -26
- data/lib/llm/shell/internal/llm.rb/lib/llm/schema/boolean.rb +0 -13
- data/lib/llm/shell/internal/llm.rb/lib/llm/schema/integer.rb +0 -43
- data/lib/llm/shell/internal/llm.rb/lib/llm/schema/leaf.rb +0 -78
- data/lib/llm/shell/internal/llm.rb/lib/llm/schema/null.rb +0 -13
- data/lib/llm/shell/internal/llm.rb/lib/llm/schema/number.rb +0 -43
- data/lib/llm/shell/internal/llm.rb/lib/llm/schema/object.rb +0 -41
- data/lib/llm/shell/internal/llm.rb/lib/llm/schema/string.rb +0 -34
- data/lib/llm/shell/internal/llm.rb/lib/llm/schema/version.rb +0 -8
- data/lib/llm/shell/internal/llm.rb/lib/llm/schema.rb +0 -81
- data/lib/llm/shell/internal/llm.rb/lib/llm/server_tool.rb +0 -32
- data/lib/llm/shell/internal/llm.rb/lib/llm/tool/param.rb +0 -75
- data/lib/llm/shell/internal/llm.rb/lib/llm/tool.rb +0 -78
- data/lib/llm/shell/internal/llm.rb/lib/llm/utils.rb +0 -19
- data/lib/llm/shell/internal/llm.rb/lib/llm/version.rb +0 -5
- data/lib/llm/shell/internal/llm.rb/lib/llm.rb +0 -121
- data/lib/llm/shell/internal/optparse/lib/optionparser.rb +0 -2
- data/lib/llm/shell/internal/optparse/lib/optparse/ac.rb +0 -70
- data/lib/llm/shell/internal/optparse/lib/optparse/date.rb +0 -18
- data/lib/llm/shell/internal/optparse/lib/optparse/kwargs.rb +0 -27
- data/lib/llm/shell/internal/optparse/lib/optparse/shellwords.rb +0 -7
- data/lib/llm/shell/internal/optparse/lib/optparse/time.rb +0 -11
- data/lib/llm/shell/internal/optparse/lib/optparse/uri.rb +0 -7
- data/lib/llm/shell/internal/optparse/lib/optparse/version.rb +0 -80
- data/lib/llm/shell/internal/optparse/lib/optparse.rb +0 -2469
- data/lib/llm/shell/internal/paint/lib/paint/constants.rb +0 -104
- data/lib/llm/shell/internal/paint/lib/paint/pa.rb +0 -13
- data/lib/llm/shell/internal/paint/lib/paint/rgb_colors.rb +0 -14
- data/lib/llm/shell/internal/paint/lib/paint/shortcuts.rb +0 -100
- data/lib/llm/shell/internal/paint/lib/paint/shortcuts_version.rb +0 -5
- data/lib/llm/shell/internal/paint/lib/paint/util.rb +0 -16
- data/lib/llm/shell/internal/paint/lib/paint/version.rb +0 -5
- data/lib/llm/shell/internal/paint/lib/paint.rb +0 -261
- data/lib/llm/shell/internal/reline/lib/reline/config.rb +0 -378
- data/lib/llm/shell/internal/reline/lib/reline/face.rb +0 -199
- data/lib/llm/shell/internal/reline/lib/reline/history.rb +0 -76
- data/lib/llm/shell/internal/reline/lib/reline/io/ansi.rb +0 -322
- data/lib/llm/shell/internal/reline/lib/reline/io/dumb.rb +0 -120
- data/lib/llm/shell/internal/reline/lib/reline/io/windows.rb +0 -530
- data/lib/llm/shell/internal/reline/lib/reline/io.rb +0 -55
- data/lib/llm/shell/internal/reline/lib/reline/key_actor/base.rb +0 -37
- data/lib/llm/shell/internal/reline/lib/reline/key_actor/composite.rb +0 -17
- data/lib/llm/shell/internal/reline/lib/reline/key_actor/emacs.rb +0 -517
- data/lib/llm/shell/internal/reline/lib/reline/key_actor/vi_command.rb +0 -518
- data/lib/llm/shell/internal/reline/lib/reline/key_actor/vi_insert.rb +0 -517
- data/lib/llm/shell/internal/reline/lib/reline/key_actor.rb +0 -8
- data/lib/llm/shell/internal/reline/lib/reline/key_stroke.rb +0 -119
- data/lib/llm/shell/internal/reline/lib/reline/kill_ring.rb +0 -125
- data/lib/llm/shell/internal/reline/lib/reline/line_editor.rb +0 -2356
- data/lib/llm/shell/internal/reline/lib/reline/unicode/east_asian_width.rb +0 -1292
- data/lib/llm/shell/internal/reline/lib/reline/unicode.rb +0 -421
- data/lib/llm/shell/internal/reline/lib/reline/version.rb +0 -3
- data/lib/llm/shell/internal/reline/lib/reline.rb +0 -527
- data/lib/llm/shell/internal/tomlrb/lib/tomlrb/generated_parser.rb +0 -712
- data/lib/llm/shell/internal/tomlrb/lib/tomlrb/handler.rb +0 -268
- data/lib/llm/shell/internal/tomlrb/lib/tomlrb/local_date.rb +0 -35
- data/lib/llm/shell/internal/tomlrb/lib/tomlrb/local_date_time.rb +0 -42
- data/lib/llm/shell/internal/tomlrb/lib/tomlrb/local_time.rb +0 -40
- data/lib/llm/shell/internal/tomlrb/lib/tomlrb/parser.rb +0 -21
- data/lib/llm/shell/internal/tomlrb/lib/tomlrb/scanner.rb +0 -92
- data/lib/llm/shell/internal/tomlrb/lib/tomlrb/string_utils.rb +0 -40
- data/lib/llm/shell/internal/tomlrb/lib/tomlrb/version.rb +0 -5
- data/lib/llm/shell/internal/tomlrb/lib/tomlrb.rb +0 -49
- data/lib/llm/shell/markdown.rb +0 -83
- data/lib/llm/shell/options.rb +0 -39
- data/lib/llm/shell/renderer.rb +0 -51
- data/lib/llm/shell/repl.rb +0 -111
- data/lib/llm/shell/tool.rb +0 -42
- data/lib/llm/shell/tools/read_file.rb +0 -15
- data/lib/llm/shell/tools/system.rb +0 -17
- data/lib/llm/shell/tools/write_file.rb +0 -16
- data/lib/llm/shell/version.rb +0 -8
- data/lib/llm/shell.rb +0 -132
- data/lib/llm-shell.rb +0 -3
- data/libexec/llm-shell/shell +0 -43
- data/share/llm-shell/prompts/default.txt +0 -21
data/lib/llm/shell/options.rb
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
class LLM::Shell
|
|
4
|
-
##
|
|
5
|
-
# The {LLM::Shell::Options LLM::Shell::Options} class represents
|
|
6
|
-
# the options provided to the shell at the command line, and the
|
|
7
|
-
# configuration file (if any). The command-line options take precedence
|
|
8
|
-
# over the configuration file.
|
|
9
|
-
class Options
|
|
10
|
-
##
|
|
11
|
-
# @param [Hash] options
|
|
12
|
-
# @param [LLM::Shell::Default] default
|
|
13
|
-
# @return [LLM::Shell::Options]
|
|
14
|
-
def initialize(options, default)
|
|
15
|
-
@options = options.transform_keys(&:to_sym)
|
|
16
|
-
@provider = @options.delete(:provider)
|
|
17
|
-
@tools = @options.delete(:tools)
|
|
18
|
-
@prompt = @options[:prompt] ? custom_prompt : default.prompt
|
|
19
|
-
@files = Dir[*@options.delete(:files) || []].reject { File.directory?(_1) }
|
|
20
|
-
@bot_options = {model: @options.delete(:model)}.compact
|
|
21
|
-
@default = default
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
def provider = @provider
|
|
25
|
-
def tools = @tools
|
|
26
|
-
def files = @files
|
|
27
|
-
def llm = @options
|
|
28
|
-
def bot = @bot_options
|
|
29
|
-
def default = @default
|
|
30
|
-
def prompt = File.read(@prompt)
|
|
31
|
-
|
|
32
|
-
private
|
|
33
|
-
|
|
34
|
-
def custom_prompt
|
|
35
|
-
prompt = @options.delete(:prompt)
|
|
36
|
-
File.join(LLM::Shell.home_data, "prompts", prompt)
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
end
|
data/lib/llm/shell/renderer.rb
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
class LLM::Shell
|
|
4
|
-
class Renderer
|
|
5
|
-
RenderError = Class.new(RuntimeError)
|
|
6
|
-
|
|
7
|
-
##
|
|
8
|
-
# @param [LLM::Message] message
|
|
9
|
-
# The message to render
|
|
10
|
-
# @return [LLM::Shell::MessageRenderer]
|
|
11
|
-
# Returns an instance of the renderer
|
|
12
|
-
def initialize(message)
|
|
13
|
-
@message = message
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def render
|
|
17
|
-
if message.user?
|
|
18
|
-
render_message(message, :yellow)
|
|
19
|
-
elsif message.assistant?
|
|
20
|
-
render_message(message, :green)
|
|
21
|
-
elsif message.system?
|
|
22
|
-
render_message(message, :red)
|
|
23
|
-
else
|
|
24
|
-
raise RenderError.new("no handler for message role '#{message.role}'")
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
private
|
|
29
|
-
|
|
30
|
-
attr_reader :message
|
|
31
|
-
|
|
32
|
-
def render_message(message, color)
|
|
33
|
-
role = Paint[message.role, :bold, color]
|
|
34
|
-
title = "#{role} says: "
|
|
35
|
-
content = message.content
|
|
36
|
-
if message.tool_call?
|
|
37
|
-
body = "Tool call(s) request"
|
|
38
|
-
elsif message.tool_return?
|
|
39
|
-
body = "Tool call(s) return"
|
|
40
|
-
elsif Array === content
|
|
41
|
-
body = content.map { |c| render_message(c, color) }.join("\n")
|
|
42
|
-
elsif content =~ LLM::Shell.pattern
|
|
43
|
-
path = content.match(LLM::Shell.pattern) ? Regexp.last_match[1] : nil
|
|
44
|
-
body = "<file path=#{path} />"
|
|
45
|
-
else
|
|
46
|
-
body = Markdown.render(content)
|
|
47
|
-
end
|
|
48
|
-
[title, "\n", body, "\n"].join
|
|
49
|
-
end
|
|
50
|
-
end
|
|
51
|
-
end
|
data/lib/llm/shell/repl.rb
DELETED
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
class LLM::Shell
|
|
4
|
-
##
|
|
5
|
-
# The {LLM::Shell::REPL LLM::Shell::REPL} class represents a loop
|
|
6
|
-
# that accepts user input, evaluates it via the LLM, and prints the
|
|
7
|
-
# response to stdout.
|
|
8
|
-
class REPL
|
|
9
|
-
##
|
|
10
|
-
# @param [LLM::Chat] bot
|
|
11
|
-
# @param [LLM::Shell::Options] options
|
|
12
|
-
# @return [LLM::Shell::REPL]
|
|
13
|
-
def initialize(bot:, options:)
|
|
14
|
-
@bot = bot
|
|
15
|
-
@console = IO.console
|
|
16
|
-
@options = options
|
|
17
|
-
@io = IO::Line.new($stdout)
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
##
|
|
21
|
-
# Performs initial setup
|
|
22
|
-
# @return [void]
|
|
23
|
-
def setup
|
|
24
|
-
Reline.completion_proc = Completion.to_proc
|
|
25
|
-
chat(options.prompt, role: options.default.role).flush
|
|
26
|
-
unread.each(&:read!)
|
|
27
|
-
clear_screen
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
##
|
|
31
|
-
# Enters the main loop
|
|
32
|
-
# @return [void]
|
|
33
|
-
def start
|
|
34
|
-
loop do
|
|
35
|
-
read
|
|
36
|
-
eval while functions.any?
|
|
37
|
-
emit
|
|
38
|
-
rescue LLM::ResponseError => ex
|
|
39
|
-
print Paint[ex.response.class, :red], "\n"
|
|
40
|
-
print ex.response.body, "\n"
|
|
41
|
-
rescue => ex
|
|
42
|
-
print Paint[ex.class, :red], "\n"
|
|
43
|
-
print ex.message, "\n"
|
|
44
|
-
print ex.backtrace[0..5].join("\n")
|
|
45
|
-
rescue Interrupt
|
|
46
|
-
throw(:exit, 0)
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
private
|
|
51
|
-
|
|
52
|
-
def read
|
|
53
|
-
input = Reline.readline("llm> ", true) || throw(:exit, 0)
|
|
54
|
-
words = input.split(" ")
|
|
55
|
-
if cmd = LLM::Shell.find_command(words[0])
|
|
56
|
-
argv = words[1..]
|
|
57
|
-
cmd.new(bot, io).call(*argv)
|
|
58
|
-
else
|
|
59
|
-
chat(input.tap { clear_screen }, tools:)
|
|
60
|
-
io.rewind.print(Paint["Thinking", :bold])
|
|
61
|
-
unread.tap { io.rewind }
|
|
62
|
-
end
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
def eval
|
|
66
|
-
callables = []
|
|
67
|
-
cancels = []
|
|
68
|
-
results = []
|
|
69
|
-
functions.each do |function|
|
|
70
|
-
args = function.arguments.to_json
|
|
71
|
-
print Paint["system", :bold, :red], " says: ", "\n"
|
|
72
|
-
print "function ".ljust(20), function.name, "\n"
|
|
73
|
-
print "arguments ".ljust(20), ((args.size >= 80) ? "#{args[0..79]} ...}" : args), "\n"
|
|
74
|
-
print "argument count".ljust(20), function.arguments.to_h.size, "\n\n"
|
|
75
|
-
input = Reline.readline("Should we proceed? ", true)
|
|
76
|
-
puts
|
|
77
|
-
if %w(y yes yep yeah ok).include?(input)
|
|
78
|
-
callables << function
|
|
79
|
-
else
|
|
80
|
-
cancels << function
|
|
81
|
-
end
|
|
82
|
-
end
|
|
83
|
-
results.concat callables.map(&:call)
|
|
84
|
-
results.concat cancels.map(&:cancel)
|
|
85
|
-
bot.chat(results).flush
|
|
86
|
-
end
|
|
87
|
-
|
|
88
|
-
def emit
|
|
89
|
-
LLM::Shell.pager do |io|
|
|
90
|
-
io.write formatter(unread).format!(:user), "\n"
|
|
91
|
-
io.write formatter(unread).format!(:assistant), "\n"
|
|
92
|
-
end unless unread.empty?
|
|
93
|
-
end
|
|
94
|
-
|
|
95
|
-
##
|
|
96
|
-
# @return [Array<LLM::Tool>]
|
|
97
|
-
def tools
|
|
98
|
-
LLM::Shell
|
|
99
|
-
.tools
|
|
100
|
-
.select(&:enabled?)
|
|
101
|
-
end
|
|
102
|
-
|
|
103
|
-
attr_reader :bot, :console, :io, :default, :options
|
|
104
|
-
|
|
105
|
-
def formatter(messages) = Formatter.new(messages)
|
|
106
|
-
def unread = bot.messages.unread
|
|
107
|
-
def functions = bot.functions
|
|
108
|
-
def clear_screen = console.clear_screen
|
|
109
|
-
def chat(...) = bot.chat(...)
|
|
110
|
-
end
|
|
111
|
-
end
|
data/lib/llm/shell/tool.rb
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
class LLM::Tool
|
|
4
|
-
module Patch
|
|
5
|
-
##
|
|
6
|
-
# Returns true for an enabled tool
|
|
7
|
-
# @return [Boolean]
|
|
8
|
-
def enabled?
|
|
9
|
-
@enabled
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
##
|
|
13
|
-
# Enable the tool
|
|
14
|
-
# @return [void]
|
|
15
|
-
def enable!
|
|
16
|
-
@enabled = true
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
##
|
|
20
|
-
# Disable the tool
|
|
21
|
-
# @return [void]
|
|
22
|
-
def disable!
|
|
23
|
-
@enabled = false
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
##
|
|
27
|
-
# @return [Boolean]
|
|
28
|
-
def builtin?
|
|
29
|
-
path, _ = instance_method(:call).source_location
|
|
30
|
-
path&.include?(LLM::Shell.root)
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
m = method(:inherited)
|
|
35
|
-
define_singleton_method(:inherited) do |tool|
|
|
36
|
-
LLM::Shell.tools << tool
|
|
37
|
-
m.call(tool)
|
|
38
|
-
tool.enable!
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
extend Patch
|
|
42
|
-
end
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module LLM::Shell::Tools
|
|
4
|
-
class ReadFile < LLM::Tool
|
|
5
|
-
name "read-file"
|
|
6
|
-
description "Read the contents of a file"
|
|
7
|
-
param :path, String, "The path to a file", required: true
|
|
8
|
-
|
|
9
|
-
def call(path:)
|
|
10
|
-
{ok: true, content: File.read(path)}
|
|
11
|
-
rescue => ex
|
|
12
|
-
{ok: false, error: {class: ex.class.to_s, message: ex.message}}
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
end
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module LLM::Shell::Tools
|
|
4
|
-
class System < LLM::Tool
|
|
5
|
-
name "system"
|
|
6
|
-
description "Run a system command"
|
|
7
|
-
param :command, String, "The command to execute", required: true
|
|
8
|
-
|
|
9
|
-
def call(command:)
|
|
10
|
-
ro, wo = IO.pipe
|
|
11
|
-
re, we = IO.pipe
|
|
12
|
-
Process.wait Process.spawn(command, out: wo, err: we)
|
|
13
|
-
[wo, we].each(&:close)
|
|
14
|
-
{stderr: re.read, stdout: ro.read}
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
end
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module LLM::Shell::Tools
|
|
4
|
-
class WriteFile < LLM::Tool
|
|
5
|
-
name "write-file"
|
|
6
|
-
description "Write the contents of a file"
|
|
7
|
-
param :path, String, "The path to a file", required: true
|
|
8
|
-
param :content, String, "The contents of a file", required: true
|
|
9
|
-
|
|
10
|
-
def call(path:, content:)
|
|
11
|
-
{ok: true, content: File.binwrite(path, content)}
|
|
12
|
-
rescue => ex
|
|
13
|
-
{ok: false, error: {class: ex.class.to_s, message: ex.message}}
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
end
|
data/lib/llm/shell/version.rb
DELETED
data/lib/llm/shell.rb
DELETED
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module LLM
|
|
4
|
-
$:.unshift(*Dir[File.join(__dir__, "shell", "internal", "*", "lib")])
|
|
5
|
-
require "optparse"
|
|
6
|
-
require "io/line"
|
|
7
|
-
require "paint"
|
|
8
|
-
require "reline"
|
|
9
|
-
require "coderay"
|
|
10
|
-
require "llm"
|
|
11
|
-
require "tomlrb"
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
class LLM::Shell
|
|
15
|
-
require_relative "shell/tool"
|
|
16
|
-
require_relative "shell/command"
|
|
17
|
-
require_relative "shell/markdown"
|
|
18
|
-
require_relative "shell/renderer"
|
|
19
|
-
require_relative "shell/formatter"
|
|
20
|
-
require_relative "shell/default"
|
|
21
|
-
require_relative "shell/options"
|
|
22
|
-
require_relative "shell/repl"
|
|
23
|
-
require_relative "shell/config"
|
|
24
|
-
require_relative "shell/completion"
|
|
25
|
-
require_relative "shell/version"
|
|
26
|
-
|
|
27
|
-
##
|
|
28
|
-
# Returns the lib/ directory
|
|
29
|
-
# @return [String]
|
|
30
|
-
def self.root
|
|
31
|
-
__dir__
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
##
|
|
35
|
-
# Returns the directory where configuration files are kept
|
|
36
|
-
# @return [String]
|
|
37
|
-
def self.home_config
|
|
38
|
-
if ENV.key?("XDG_CONFIG_HOME")
|
|
39
|
-
ENV["XDG_CONFIG_HOME"]
|
|
40
|
-
else
|
|
41
|
-
File.join Dir.home, ".config"
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
##
|
|
46
|
-
# Returns the directory where commands and tools are kept
|
|
47
|
-
# @return [String]
|
|
48
|
-
def self.home_data
|
|
49
|
-
if ENV.key?("XDG_DATA_HOME")
|
|
50
|
-
File.join ENV["XDG_DATA_HOME"], ".llm-shell"
|
|
51
|
-
else
|
|
52
|
-
File.join Dir.home, ".local", "share", ".llm-shell"
|
|
53
|
-
end
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
##
|
|
57
|
-
# @return [Array<LLM::Command>]
|
|
58
|
-
def self.commands
|
|
59
|
-
@commands ||= []
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
##
|
|
63
|
-
# @return [Array<LLM::Tool>]
|
|
64
|
-
def self.tools
|
|
65
|
-
@tools ||= []
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
##
|
|
69
|
-
# Returns an instance of {LLM::Command LLM::Command}, or nil.
|
|
70
|
-
# @return [LLM::Command, nil]
|
|
71
|
-
def self.find_command(name)
|
|
72
|
-
commands.find { _1.name == name }
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
##
|
|
76
|
-
# @return [Regexp]
|
|
77
|
-
def self.pattern
|
|
78
|
-
/\A<file path=(.+?)>/
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
##
|
|
82
|
-
# Opens a pager
|
|
83
|
-
# @return [void]
|
|
84
|
-
def self.pager(...)
|
|
85
|
-
IO.popen("less -FRX", "w", ...)
|
|
86
|
-
end
|
|
87
|
-
|
|
88
|
-
##
|
|
89
|
-
# Load commands & tools
|
|
90
|
-
Dir[File.join(home_data, "commands", "*.rb")].each { require(_1) }
|
|
91
|
-
Dir[File.join(home_data, "tools", "*.rb")].each { require(_1) }
|
|
92
|
-
Dir[File.join(root, "shell", "commands", "*.rb")].each { require(_1) }
|
|
93
|
-
Dir[File.join(root, "shell", "tools", "*.rb")].each { require(_1) }
|
|
94
|
-
|
|
95
|
-
##
|
|
96
|
-
# @param [Hash] opts
|
|
97
|
-
# @return [LLM::Shell]
|
|
98
|
-
def initialize(opts)
|
|
99
|
-
@config = Config.new(opts[:provider])
|
|
100
|
-
@options = Options.new @config.merge(opts), Default.new(opts[:provider])
|
|
101
|
-
@bot = LLM::Bot.new(llm, options.bot)
|
|
102
|
-
@repl = REPL.new(bot:, options:)
|
|
103
|
-
end
|
|
104
|
-
|
|
105
|
-
##
|
|
106
|
-
# Start the shell
|
|
107
|
-
# @return [void]
|
|
108
|
-
def start
|
|
109
|
-
repl.setup
|
|
110
|
-
repl.start
|
|
111
|
-
end
|
|
112
|
-
|
|
113
|
-
private
|
|
114
|
-
|
|
115
|
-
attr_reader :options, :bot, :repl
|
|
116
|
-
|
|
117
|
-
##
|
|
118
|
-
# @return [Method]
|
|
119
|
-
def provider
|
|
120
|
-
LLM.method(options.provider)
|
|
121
|
-
end
|
|
122
|
-
|
|
123
|
-
##
|
|
124
|
-
# @return [LLM::Provider]
|
|
125
|
-
def llm
|
|
126
|
-
provider.call(**options.llm)
|
|
127
|
-
end
|
|
128
|
-
end
|
|
129
|
-
|
|
130
|
-
module LLM
|
|
131
|
-
Command = LLM::Shell::Command
|
|
132
|
-
end
|
data/lib/llm-shell.rb
DELETED
data/libexec/llm-shell/shell
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
# frozen_string_literal: true
|
|
3
|
-
|
|
4
|
-
def main(argv)
|
|
5
|
-
if argv.include?("-v") || argv.include?("--version")
|
|
6
|
-
puts LLM::Shell::VERSION
|
|
7
|
-
else
|
|
8
|
-
options = {tools: []}
|
|
9
|
-
option_parser.parse(argv, into: options)
|
|
10
|
-
if argv.empty? || options[:provider].nil?
|
|
11
|
-
warn option_parser.help
|
|
12
|
-
throw(:exit, 1)
|
|
13
|
-
else
|
|
14
|
-
LLM::Shell.new(options).start
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def option_parser
|
|
20
|
-
OptionParser.new do |o|
|
|
21
|
-
o.banner = "Usage: llm-shell [OPTIONS]"
|
|
22
|
-
o.on("-p PROVIDER", "--provider NAME", "Required. Options: gemini, openai, anthropic, ollama or llamacpp.", String)
|
|
23
|
-
o.on("-k [KEY]", "--key [KEY]", "Optional. Required by gemini, openai, and anthropic.", String)
|
|
24
|
-
o.on("-m [MODEL]", "--model [MODEL]", "Optional. The name of a model.", Array)
|
|
25
|
-
o.on("-h [HOST]", "--host [HOST]", "Optional. Sometimes required by ollama.", String)
|
|
26
|
-
o.on("-o [PORT]", "--port [PORT]", "Optional. Sometimes required by ollama.", Integer)
|
|
27
|
-
o.on("-r [PROMPT]", "--prompt [PROMPT]", "Optional. The prompt to use.", String)
|
|
28
|
-
o.on("-v", "--version", "Optional. Print the version and exit.")
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
excode = catch(:exit) do
|
|
33
|
-
require_relative "../../lib/llm/shell"
|
|
34
|
-
main(ARGV)
|
|
35
|
-
throw(:exit, 0)
|
|
36
|
-
rescue => ex
|
|
37
|
-
print Paint[ex.class, :red, :bold], "\n"
|
|
38
|
-
print ex.message, "\n\n"
|
|
39
|
-
print Paint["Backtrace", :bold], "\n"
|
|
40
|
-
print ex.backtrace[0..7].join("\n"), "\n"
|
|
41
|
-
throw(:exit, 1)
|
|
42
|
-
end
|
|
43
|
-
exit excode
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
## Task
|
|
2
|
-
|
|
3
|
-
Your task is to provide helpful assistance to the user.
|
|
4
|
-
|
|
5
|
-
## Context
|
|
6
|
-
|
|
7
|
-
The user is talking to you from a terminal-based application.
|
|
8
|
-
|
|
9
|
-
## Inputs
|
|
10
|
-
|
|
11
|
-
The user might send you the content of file(s) from their filesystem.
|
|
12
|
-
When the user sends you a file, it will be in this format:
|
|
13
|
-
|
|
14
|
-
<file path="/path/to/file">
|
|
15
|
-
CONTENT
|
|
16
|
-
</file>
|
|
17
|
-
|
|
18
|
-
## Outputs
|
|
19
|
-
|
|
20
|
-
Always respond in markdown.
|
|
21
|
-
When the user sends a file, reply with "Got it" and nothing else.
|