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
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
class LLM::Shell
|
|
4
|
-
class Command::DirImport < Command
|
|
5
|
-
name "dir-import"
|
|
6
|
-
description "Import the contents of a directory"
|
|
7
|
-
|
|
8
|
-
##
|
|
9
|
-
# Completes a path with a wildcard.
|
|
10
|
-
# @param path [String]
|
|
11
|
-
# The path to complete.
|
|
12
|
-
# @return [Array<String>]
|
|
13
|
-
# Returns the completed path(s)
|
|
14
|
-
def self.complete(path)
|
|
15
|
-
Dir["#{path}*"]
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
##
|
|
19
|
-
# Recursively imports all files in a directory.
|
|
20
|
-
# @return [void]
|
|
21
|
-
def call(dir)
|
|
22
|
-
Dir.entries(dir).each do |file|
|
|
23
|
-
if file == "." || file == ".."
|
|
24
|
-
next
|
|
25
|
-
elsif File.directory? File.join(dir, file)
|
|
26
|
-
call File.join(dir, file)
|
|
27
|
-
else
|
|
28
|
-
import File.join(dir, file)
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
end
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
class LLM::Shell
|
|
4
|
-
class Command::DisableTool < Command
|
|
5
|
-
Error = Class.new(RuntimeError)
|
|
6
|
-
|
|
7
|
-
name "disable-tool"
|
|
8
|
-
description "Disable a tool"
|
|
9
|
-
|
|
10
|
-
##
|
|
11
|
-
# Completes a tool name.
|
|
12
|
-
# @param name [String]
|
|
13
|
-
# The tool name to complete.
|
|
14
|
-
# @return [Array<String>]
|
|
15
|
-
# Returns the completed tool name(s)
|
|
16
|
-
def self.complete(name)
|
|
17
|
-
LLM::Shell.tools.map(&:name).select { _1.start_with?(name) }
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
##
|
|
21
|
-
# Disables the given tool.
|
|
22
|
-
# @return [void]
|
|
23
|
-
def call(name)
|
|
24
|
-
tool = LLM::Shell.tools.find { _1.name == name }
|
|
25
|
-
if tool
|
|
26
|
-
tool.disable!
|
|
27
|
-
io.rewind.print("tool disabled").end
|
|
28
|
-
else
|
|
29
|
-
raise Error, "unknown tool: #{name}"
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
end
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
class LLM::Shell
|
|
4
|
-
class Command::EnableTool < Command
|
|
5
|
-
Error = Class.new(RuntimeError)
|
|
6
|
-
|
|
7
|
-
name "enable-tool"
|
|
8
|
-
description "Enable a tool"
|
|
9
|
-
|
|
10
|
-
##
|
|
11
|
-
# Completes a tool name.
|
|
12
|
-
# @param name [String]
|
|
13
|
-
# The tool name to complete.
|
|
14
|
-
# @return [Array<String>]
|
|
15
|
-
# Returns the completed tool name(s)
|
|
16
|
-
def self.complete(name)
|
|
17
|
-
LLM::Shell.tools.map(&:name).select { _1.start_with?(name) }
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
##
|
|
21
|
-
# Enables the given tool.
|
|
22
|
-
# @return [void]
|
|
23
|
-
def call(name)
|
|
24
|
-
tool = LLM::Shell.tools.find { _1.name == name }
|
|
25
|
-
if tool
|
|
26
|
-
tool.enable!
|
|
27
|
-
io.rewind.print("tool enabled").end
|
|
28
|
-
else
|
|
29
|
-
raise Error, "unknown tool: #{name}"
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
end
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
class LLM::Shell
|
|
4
|
-
class Command::FileImport < Command
|
|
5
|
-
name "file-import"
|
|
6
|
-
description "Import a file"
|
|
7
|
-
|
|
8
|
-
##
|
|
9
|
-
# Completes a path with a wildcard.
|
|
10
|
-
# @param path [String]
|
|
11
|
-
# The path to complete.
|
|
12
|
-
# @return [Array<String>]
|
|
13
|
-
# Returns the completed path(s)
|
|
14
|
-
def self.complete(path)
|
|
15
|
-
Dir["#{path}*"]
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
##
|
|
19
|
-
# Imports one or more globbed files.
|
|
20
|
-
# @return [void]
|
|
21
|
-
def call(*files)
|
|
22
|
-
Dir[*files].each { import(_1) }
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
end
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
class LLM::Shell
|
|
4
|
-
class Command::Help < Command
|
|
5
|
-
name "help"
|
|
6
|
-
description "Show help"
|
|
7
|
-
|
|
8
|
-
##
|
|
9
|
-
# Prints help
|
|
10
|
-
# @return [void]
|
|
11
|
-
def call
|
|
12
|
-
pager do |io|
|
|
13
|
-
io.print(Paint["Help", :bold, :underline], "\n\n")
|
|
14
|
-
render_commands(io)
|
|
15
|
-
io.print("\n")
|
|
16
|
-
render_functions(io)
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
private
|
|
21
|
-
|
|
22
|
-
def render_commands(io)
|
|
23
|
-
io.print(Paint["Commands", :bold, :underline], "\n\n")
|
|
24
|
-
render_group(io, "Builtin", commands.select(&:builtin?), :cyan)
|
|
25
|
-
io.print("\n")
|
|
26
|
-
render_group(io, "User", commands.reject(&:builtin?), :cyan)
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
def render_functions(io)
|
|
30
|
-
io.print(Paint["Functions", :bold, :underline], "\n\n")
|
|
31
|
-
render_group(io, "Builtin (Enabled)", functions.select { |f| f.builtin? && f.enabled? }, :blue)
|
|
32
|
-
render_group(io, "Builtin (Disabled)", functions.select { |f| f.builtin? && !f.enabled? }, :blue)
|
|
33
|
-
io.print("\n")
|
|
34
|
-
render_group(io, "User (Enabled)", functions.select { |f| !f.builtin? && f.enabled? }, :blue)
|
|
35
|
-
render_group(io, "User (Disabled)", functions.select { |f| !f.builtin? && !f.enabled? }, :blue)
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
def render_group(io, title, items, color)
|
|
39
|
-
io.print(Paint[title, :bold], "\n")
|
|
40
|
-
if items.empty?
|
|
41
|
-
io.print(Paint[" None available", :yellow], "\n")
|
|
42
|
-
else
|
|
43
|
-
items.each do |item|
|
|
44
|
-
status = item.enabled? ? Paint["enabled", :green] : Paint["disabled", :red]
|
|
45
|
-
io.print(" ", Paint[item.name, color, :bold], " - ", item.description || "No description", " (", status, ")\n")
|
|
46
|
-
end
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
def commands = LLM::Shell.commands.sort_by(&:name)
|
|
51
|
-
def functions = LLM::Shell.tools.sort_by(&:name)
|
|
52
|
-
end
|
|
53
|
-
end
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
class LLM::Shell
|
|
4
|
-
class Command::ShowChat < Command
|
|
5
|
-
name "show-chat"
|
|
6
|
-
description "Show the chat"
|
|
7
|
-
|
|
8
|
-
##
|
|
9
|
-
# Emits the full chat history to standard output
|
|
10
|
-
# @return [void]
|
|
11
|
-
def call
|
|
12
|
-
clear_screen
|
|
13
|
-
emit
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
private
|
|
17
|
-
|
|
18
|
-
def emit
|
|
19
|
-
pager do |io|
|
|
20
|
-
messages.each.with_index do |message, index|
|
|
21
|
-
io << render(message) << "\n"
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
def console = IO.console
|
|
27
|
-
def clear_screen = console.clear_screen
|
|
28
|
-
def messages = bot.messages
|
|
29
|
-
def render(message) = LLM::Shell::Renderer.new(message).render
|
|
30
|
-
end
|
|
31
|
-
end
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
class LLM::Shell
|
|
4
|
-
class Command::ShowVersion < Command
|
|
5
|
-
name "show-version"
|
|
6
|
-
description "Show the version"
|
|
7
|
-
|
|
8
|
-
##
|
|
9
|
-
# Shows the current llm-shell version
|
|
10
|
-
# @return [void]
|
|
11
|
-
def call
|
|
12
|
-
pager do |io|
|
|
13
|
-
io.write("llm-shell version: #{LLM::Shell::VERSION}\n")
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
end
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
class LLM::Shell
|
|
4
|
-
class Command::SystemPrompt < Command
|
|
5
|
-
name "system-prompt"
|
|
6
|
-
description "Show the system prompt"
|
|
7
|
-
|
|
8
|
-
##
|
|
9
|
-
# Emits the system prompt to standard output
|
|
10
|
-
# @return [void]
|
|
11
|
-
def call
|
|
12
|
-
pager do |io|
|
|
13
|
-
io.write render(bot.messages[0])
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
private
|
|
18
|
-
|
|
19
|
-
def render(message) = LLM::Shell::Renderer.new(message).render
|
|
20
|
-
end
|
|
21
|
-
end
|
data/lib/llm/shell/completion.rb
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
class LLM::Shell
|
|
4
|
-
class Completion
|
|
5
|
-
##
|
|
6
|
-
# Returns a proc suitable for Reline completion.
|
|
7
|
-
# @return [Proc]
|
|
8
|
-
def self.to_proc
|
|
9
|
-
new.to_proc
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
##
|
|
13
|
-
# @return [LLM::Shell::Completion]
|
|
14
|
-
def initialize
|
|
15
|
-
@commands = LLM::Shell.commands.map { [_1.name, _1] }.to_h
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
##
|
|
19
|
-
# Returns a proc suitable for Reline completion.
|
|
20
|
-
# @return [Proc]
|
|
21
|
-
def to_proc
|
|
22
|
-
method(:complete).to_proc
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
private
|
|
26
|
-
|
|
27
|
-
def complete(input)
|
|
28
|
-
words = Reline.line_buffer.split(" ")
|
|
29
|
-
command = words[0]
|
|
30
|
-
if commands[command]
|
|
31
|
-
object = commands[command]
|
|
32
|
-
object.respond_to?(:complete) ? object.complete(input) : []
|
|
33
|
-
else
|
|
34
|
-
commands.keys.grep(/\A#{command}/)
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
attr_reader :commands
|
|
39
|
-
end
|
|
40
|
-
end
|
data/lib/llm/shell/config.rb
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
class LLM::Shell
|
|
4
|
-
class Config
|
|
5
|
-
##
|
|
6
|
-
# @param [String] provider
|
|
7
|
-
# @return [LLM::Shell::Config]
|
|
8
|
-
def initialize(provider)
|
|
9
|
-
@provider = provider
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
##
|
|
13
|
-
# @return [Hash]
|
|
14
|
-
def merge(other)
|
|
15
|
-
to_h.merge(other)
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
##
|
|
19
|
-
# @return [Hash]
|
|
20
|
-
def to_h
|
|
21
|
-
toml[@provider] || {}
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
private
|
|
25
|
-
|
|
26
|
-
def toml
|
|
27
|
-
@toml ||= Tomlrb.load_file(path)
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
def path
|
|
31
|
-
File.join LLM::Shell.home_config, "llm-shell.toml"
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
end
|
data/lib/llm/shell/default.rb
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
class LLM::Shell
|
|
4
|
-
class Default
|
|
5
|
-
def initialize(provider)
|
|
6
|
-
@provider = provider
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
def prompt
|
|
10
|
-
File.join(SHAREDIR, "prompts", "default.txt")
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def role
|
|
14
|
-
case @provider
|
|
15
|
-
when "openai", "ollama" then :system
|
|
16
|
-
else :user
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
SHAREDIR = File.join(__dir__, "..", "..", "..", "share", "llm-shell")
|
|
21
|
-
private_constant :SHAREDIR
|
|
22
|
-
end
|
|
23
|
-
end
|
data/lib/llm/shell/formatter.rb
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
class LLM::Shell
|
|
4
|
-
class Formatter
|
|
5
|
-
FormatError = Class.new(RuntimeError)
|
|
6
|
-
|
|
7
|
-
def initialize(messages)
|
|
8
|
-
@messages = messages.reject(&:tool_call?)
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
def format!(role)
|
|
12
|
-
case role
|
|
13
|
-
when :user then format_user(messages)
|
|
14
|
-
when :assistant then format_assistant(messages)
|
|
15
|
-
else raise FormatError.new("#{role} is not known")
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
private
|
|
20
|
-
|
|
21
|
-
def format_user(messages)
|
|
22
|
-
messages.filter_map do |message|
|
|
23
|
-
next unless message.user?
|
|
24
|
-
next unless String === message.content
|
|
25
|
-
next unless message.content !~ LLM::Shell.pattern
|
|
26
|
-
render(message.tap(&:read!))
|
|
27
|
-
end.join("\n")
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
def format_assistant(messages)
|
|
31
|
-
messages.filter_map do |message|
|
|
32
|
-
next unless message.assistant?
|
|
33
|
-
next unless String === message.content
|
|
34
|
-
render(message.tap(&:read!))
|
|
35
|
-
end.join("\n")
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
attr_reader :messages
|
|
39
|
-
def render(message) = Renderer.new(message).render
|
|
40
|
-
end
|
|
41
|
-
end
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
module CodeRay
|
|
2
|
-
|
|
3
|
-
# = Duo
|
|
4
|
-
#
|
|
5
|
-
# A Duo is a convenient way to use CodeRay. You just create a Duo,
|
|
6
|
-
# giving it a lang (language of the input code) and a format (desired
|
|
7
|
-
# output format), and call Duo#highlight with the code.
|
|
8
|
-
#
|
|
9
|
-
# Duo makes it easy to re-use both scanner and encoder for a repetitive
|
|
10
|
-
# task. It also provides a very easy interface syntax:
|
|
11
|
-
#
|
|
12
|
-
# require 'coderay'
|
|
13
|
-
# CodeRay::Duo[:python, :div].highlight 'import this'
|
|
14
|
-
#
|
|
15
|
-
# Until you want to do uncommon things with CodeRay, I recommend to use
|
|
16
|
-
# this method, since it takes care of everything.
|
|
17
|
-
class Duo
|
|
18
|
-
|
|
19
|
-
attr_accessor :lang, :format, :options
|
|
20
|
-
|
|
21
|
-
# Create a new Duo, holding a lang and a format to highlight code.
|
|
22
|
-
#
|
|
23
|
-
# simple:
|
|
24
|
-
# CodeRay::Duo[:ruby, :html].highlight 'bla 42'
|
|
25
|
-
#
|
|
26
|
-
# with options:
|
|
27
|
-
# CodeRay::Duo[:ruby, :html, :hint => :debug].highlight '????::??'
|
|
28
|
-
#
|
|
29
|
-
# alternative syntax without options:
|
|
30
|
-
# CodeRay::Duo[:ruby => :statistic].encode 'class << self; end'
|
|
31
|
-
#
|
|
32
|
-
# alternative syntax with options:
|
|
33
|
-
# CodeRay::Duo[{ :ruby => :statistic }, :do => :something].encode 'abc'
|
|
34
|
-
#
|
|
35
|
-
# The options are forwarded to scanner and encoder
|
|
36
|
-
# (see CodeRay.get_scanner_options).
|
|
37
|
-
def initialize lang = nil, format = nil, options = {}
|
|
38
|
-
if format.nil? && lang.is_a?(Hash) && lang.size == 1
|
|
39
|
-
@lang = lang.keys.first
|
|
40
|
-
@format = lang[@lang]
|
|
41
|
-
else
|
|
42
|
-
@lang = lang
|
|
43
|
-
@format = format
|
|
44
|
-
end
|
|
45
|
-
@options = options
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
class << self
|
|
49
|
-
# To allow calls like Duo[:ruby, :html].highlight.
|
|
50
|
-
alias [] new
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
# The scanner of the duo. Only created once.
|
|
54
|
-
def scanner
|
|
55
|
-
@scanner ||= CodeRay.scanner @lang, CodeRay.get_scanner_options(@options)
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
# The encoder of the duo. Only created once.
|
|
59
|
-
def encoder
|
|
60
|
-
@encoder ||= CodeRay.encoder @format, @options
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
# Tokenize and highlight the code using +scanner+ and +encoder+.
|
|
64
|
-
def encode code, options = {}
|
|
65
|
-
options = @options.merge options
|
|
66
|
-
encoder.encode(code, @lang, options)
|
|
67
|
-
end
|
|
68
|
-
alias highlight encode
|
|
69
|
-
|
|
70
|
-
# Allows to use Duo like a proc object:
|
|
71
|
-
#
|
|
72
|
-
# CodeRay::Duo[:python => :yaml].call(code)
|
|
73
|
-
#
|
|
74
|
-
# or, in Ruby 1.9 and later:
|
|
75
|
-
#
|
|
76
|
-
# CodeRay::Duo[:python => :yaml].(code)
|
|
77
|
-
alias call encode
|
|
78
|
-
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
end
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
module CodeRay
|
|
2
|
-
module Encoders
|
|
3
|
-
|
|
4
|
-
map \
|
|
5
|
-
:loc => :lines_of_code,
|
|
6
|
-
:plain => :text,
|
|
7
|
-
:plaintext => :text,
|
|
8
|
-
:remove_comments => :comment_filter,
|
|
9
|
-
:stats => :statistic,
|
|
10
|
-
:term => :terminal,
|
|
11
|
-
:tty => :terminal,
|
|
12
|
-
:yml => :yaml
|
|
13
|
-
|
|
14
|
-
# No default because Tokens#nonsense should raise NoMethodError.
|
|
15
|
-
|
|
16
|
-
end
|
|
17
|
-
end
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
module CodeRay
|
|
2
|
-
module Encoders
|
|
3
|
-
|
|
4
|
-
load :token_kind_filter
|
|
5
|
-
|
|
6
|
-
# A simple Filter that removes all tokens of the :comment kind.
|
|
7
|
-
#
|
|
8
|
-
# Alias: +remove_comments+
|
|
9
|
-
#
|
|
10
|
-
# Usage:
|
|
11
|
-
# CodeRay.scan('print # foo', :ruby).comment_filter.text
|
|
12
|
-
# #-> "print "
|
|
13
|
-
#
|
|
14
|
-
# See also: TokenKindFilter, LinesOfCode
|
|
15
|
-
class CommentFilter < TokenKindFilter
|
|
16
|
-
|
|
17
|
-
register_for :comment_filter
|
|
18
|
-
|
|
19
|
-
DEFAULT_OPTIONS = superclass::DEFAULT_OPTIONS.merge \
|
|
20
|
-
:exclude => [:comment, :docstring]
|
|
21
|
-
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
end
|
|
25
|
-
end
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
module CodeRay
|
|
2
|
-
module Encoders
|
|
3
|
-
|
|
4
|
-
# Returns the number of tokens.
|
|
5
|
-
#
|
|
6
|
-
# Text and block tokens are counted.
|
|
7
|
-
class Count < Encoder
|
|
8
|
-
|
|
9
|
-
register_for :count
|
|
10
|
-
|
|
11
|
-
protected
|
|
12
|
-
|
|
13
|
-
def setup options
|
|
14
|
-
super
|
|
15
|
-
|
|
16
|
-
@count = 0
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def finish options
|
|
20
|
-
output @count
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
public
|
|
24
|
-
|
|
25
|
-
def text_token text, kind
|
|
26
|
-
@count += 1
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
def begin_group kind
|
|
30
|
-
@count += 1
|
|
31
|
-
end
|
|
32
|
-
alias end_group begin_group
|
|
33
|
-
alias begin_line begin_group
|
|
34
|
-
alias end_line begin_group
|
|
35
|
-
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
end
|
|
39
|
-
end
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
module CodeRay
|
|
2
|
-
module Encoders
|
|
3
|
-
|
|
4
|
-
# = Debug Encoder
|
|
5
|
-
#
|
|
6
|
-
# Fast encoder producing simple debug output.
|
|
7
|
-
#
|
|
8
|
-
# It is readable and diff-able and is used for testing.
|
|
9
|
-
#
|
|
10
|
-
# You cannot fully restore the tokens information from the
|
|
11
|
-
# output, because consecutive :space tokens are merged.
|
|
12
|
-
#
|
|
13
|
-
# See also: Scanners::Debug
|
|
14
|
-
class Debug < Encoder
|
|
15
|
-
|
|
16
|
-
register_for :debug
|
|
17
|
-
|
|
18
|
-
FILE_EXTENSION = 'raydebug'
|
|
19
|
-
|
|
20
|
-
def text_token text, kind
|
|
21
|
-
if kind == :space
|
|
22
|
-
@out << text
|
|
23
|
-
else
|
|
24
|
-
text = text.gsub('\\', '\\\\\\\\') if text.index('\\')
|
|
25
|
-
text = text.gsub(')', '\\\\)') if text.index(')')
|
|
26
|
-
@out << "#{kind}(#{text})"
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
def begin_group kind
|
|
31
|
-
@out << "#{kind}<"
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
def end_group kind
|
|
35
|
-
@out << '>'
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
def begin_line kind
|
|
39
|
-
@out << "#{kind}["
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
def end_line kind
|
|
43
|
-
@out << ']'
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
end
|
|
49
|
-
end
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
module CodeRay
|
|
2
|
-
module Encoders
|
|
3
|
-
|
|
4
|
-
load :lint
|
|
5
|
-
|
|
6
|
-
# = Debug Lint Encoder
|
|
7
|
-
#
|
|
8
|
-
# Debug encoder with additional checks for:
|
|
9
|
-
#
|
|
10
|
-
# - empty tokens
|
|
11
|
-
# - incorrect nesting
|
|
12
|
-
#
|
|
13
|
-
# It will raise an InvalidTokenStream exception when any of the above occurs.
|
|
14
|
-
#
|
|
15
|
-
# See also: Encoders::Debug
|
|
16
|
-
class DebugLint < Debug
|
|
17
|
-
|
|
18
|
-
register_for :debug_lint
|
|
19
|
-
|
|
20
|
-
def text_token text, kind
|
|
21
|
-
raise Lint::EmptyToken, 'empty token for %p' % [kind] if text.empty?
|
|
22
|
-
raise Lint::UnknownTokenKind, 'unknown token kind %p (text was %p)' % [kind, text] unless TokenKinds.has_key? kind
|
|
23
|
-
super
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
def begin_group kind
|
|
27
|
-
@opened << kind
|
|
28
|
-
super
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
def end_group kind
|
|
32
|
-
raise Lint::IncorrectTokenGroupNesting, 'We are inside %s, not %p (end_group)' % [@opened.reverse.map(&:inspect).join(' < '), kind] if @opened.last != kind
|
|
33
|
-
@opened.pop
|
|
34
|
-
super
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
def begin_line kind
|
|
38
|
-
@opened << kind
|
|
39
|
-
super
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
def end_line kind
|
|
43
|
-
raise Lint::IncorrectTokenGroupNesting, 'We are inside %s, not %p (end_line)' % [@opened.reverse.map(&:inspect).join(' < '), kind] if @opened.last != kind
|
|
44
|
-
@opened.pop
|
|
45
|
-
super
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
protected
|
|
49
|
-
|
|
50
|
-
def setup options
|
|
51
|
-
super
|
|
52
|
-
@opened = []
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
def finish options
|
|
56
|
-
raise 'Some tokens still open at end of token stream: %p' % [@opened] unless @opened.empty?
|
|
57
|
-
super
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
end
|
|
63
|
-
end
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
module CodeRay
|
|
2
|
-
module Encoders
|
|
3
|
-
|
|
4
|
-
load :html
|
|
5
|
-
|
|
6
|
-
# Wraps HTML output into a DIV element, using inline styles by default.
|
|
7
|
-
#
|
|
8
|
-
# See Encoders::HTML for available options.
|
|
9
|
-
class Div < HTML
|
|
10
|
-
|
|
11
|
-
FILE_EXTENSION = 'div.html'
|
|
12
|
-
|
|
13
|
-
register_for :div
|
|
14
|
-
|
|
15
|
-
DEFAULT_OPTIONS = HTML::DEFAULT_OPTIONS.merge \
|
|
16
|
-
:css => :style,
|
|
17
|
-
:wrap => :div,
|
|
18
|
-
:line_numbers => false
|
|
19
|
-
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
end
|
|
23
|
-
end
|