pikuri-core 0.0.7 → 0.2.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 (60) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +17 -30
  3. data/lib/pikuri/agent/chat_transport.rb +168 -107
  4. data/lib/pikuri/agent/configurator.rb +194 -173
  5. data/lib/pikuri/agent/control/cancellable.rb +100 -70
  6. data/lib/pikuri/agent/control/handoff.rb +75 -0
  7. data/lib/pikuri/agent/control/interloper.rb +107 -118
  8. data/lib/pikuri/agent/control.rb +13 -35
  9. data/lib/pikuri/agent/event.rb +144 -197
  10. data/lib/pikuri/agent/extension.rb +83 -95
  11. data/lib/pikuri/agent/history.rb +247 -0
  12. data/lib/pikuri/agent/listener/in_memory_event_list.rb +1 -1
  13. data/lib/pikuri/agent/listener/terminal.rb +169 -136
  14. data/lib/pikuri/agent/listener/token_log.rb +84 -157
  15. data/lib/pikuri/agent/listener.rb +24 -44
  16. data/lib/pikuri/agent/listener_list.rb +32 -47
  17. data/lib/pikuri/agent/request_instrumenter.rb +102 -0
  18. data/lib/pikuri/agent.rb +1095 -577
  19. data/lib/pikuri/attachment.rb +65 -0
  20. data/lib/pikuri/bundler_env.rb +68 -0
  21. data/lib/pikuri/extractor/passthrough.rb +24 -31
  22. data/lib/pikuri/extractor.rb +125 -155
  23. data/lib/pikuri/file_type.rb +64 -136
  24. data/lib/pikuri/finalizers.rb +32 -47
  25. data/lib/pikuri/paths.rb +104 -13
  26. data/lib/pikuri/sanitizer.rb +46 -67
  27. data/lib/pikuri/subprocess.rb +86 -118
  28. data/lib/pikuri/testing.rb +369 -0
  29. data/lib/pikuri/tool/calculator.rb +168 -74
  30. data/lib/pikuri/tool/execute_context.rb +42 -0
  31. data/lib/pikuri/tool/parameters.rb +31 -29
  32. data/lib/pikuri/tool/result.rb +164 -0
  33. data/lib/pikuri/tool/trifecta_legs.rb +248 -0
  34. data/lib/pikuri/tool.rb +416 -67
  35. data/lib/pikuri/trifecta/contribution.rb +43 -0
  36. data/lib/pikuri/trifecta/node.rb +47 -0
  37. data/lib/pikuri/trifecta/report.rb +228 -0
  38. data/lib/pikuri/trifecta.rb +126 -0
  39. data/lib/pikuri/version.rb +1 -1
  40. data/lib/pikuri-core.rb +70 -92
  41. data/prompts/agent-loop.txt +5 -0
  42. data/prompts/pikuri-chat.txt +3 -12
  43. metadata +26 -72
  44. data/lib/pikuri/agent/context_window_detector.rb +0 -222
  45. data/lib/pikuri/agent/control/step_limit.rb +0 -111
  46. data/lib/pikuri/agent/extension_context.rb +0 -147
  47. data/lib/pikuri/agent/listener/rate_limited.rb +0 -172
  48. data/lib/pikuri/agent/synthesizer.rb +0 -171
  49. data/lib/pikuri/extractor/html.rb +0 -303
  50. data/lib/pikuri/tool/fetch.rb +0 -172
  51. data/lib/pikuri/tool/scraper.rb +0 -186
  52. data/lib/pikuri/tool/search/brave.rb +0 -198
  53. data/lib/pikuri/tool/search/duckduckgo.rb +0 -207
  54. data/lib/pikuri/tool/search/engines.rb +0 -186
  55. data/lib/pikuri/tool/search/exa.rb +0 -229
  56. data/lib/pikuri/tool/search/rate_limiter.rb +0 -92
  57. data/lib/pikuri/tool/search/result.rb +0 -29
  58. data/lib/pikuri/tool/web_scrape.rb +0 -121
  59. data/lib/pikuri/tool/web_search.rb +0 -57
  60. data/lib/pikuri/url_cache.rb +0 -112
@@ -1,80 +1,89 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'rainbow'
4
+ require 'io/console'
4
5
 
5
6
  module Pikuri
6
7
  class Agent
7
8
  module Listener
8
- # Terminal renderer for the normalized event stream: dim grey
9
- # reasoning, assistant content printed raw (Markdown as-is),
10
- # cyan tool-call and tool-result lines, yellow fallback
11
- # notice, red cancelled notice, magenta model-switch notice.
12
- # An {Event::SystemInjected} block (recalled
13
- # memory / context an extension injected) renders dim grey
14
- # with a +⊕+ marker. {Event::UserTurn} is intentionally silent
15
- # (the terminal user just typed the message, so re-rendering
16
- # it adds nothing); {Event::Tokens} and {Event::ContextCap}
17
- # are silent too (their consumer is {TokenLog}).
9
+ # Terminal renderer for the normalized event stream: dim grey reasoning,
10
+ # assistant Markdown printed unrendered, tool-call/result lines in Kuri's coat
11
+ # ({TOOL_COLOR}), yellow fallback notice, red cancelled, magenta
12
+ # model-switch. A tool call renders as the two strings the tool composed,
13
+ # never an argument dump or a slice of the observation:
18
14
  #
19
- # Assistant Markdown deliberately prints raw, with no
20
- # Markdown-to-ANSI rendering. A renderer (+tty-markdown+)
21
- # used to sit on the non-streaming path; it was dropped:
22
- # rendering can never apply to the streaming path anyway
23
- # (half-finished Markdown — broken code fences, half-built
24
- # tables — doesn't render), the gem hadn't shipped a release
25
- # since 2023 (its known ANSI-in-table crashes forced a
26
- # rescue-and-degrade carve-out here), and it pulled seven
27
- # transitive gems into the audit surface. Raw Markdown is
28
- # perfectly readable in a terminal; proper rendering belongs
29
- # to a richer host (the planned pikuri-tui).
15
+ # → Write(lib/shared/config.rb)
16
+ # = Added 2 lines, removed 3 lines
30
17
  #
31
- # Optionally prepends a fixed number of leading spaces to
32
- # every rendered line via the +padding:+ kwarg. Sub-agents
33
- # get a fresh padded instance through {#for_sub_agent}
34
- # (dispatched by {ListenerList#for_sub_agent}) so their
35
- # output is visually indented under the parent's stream.
18
+ # {Event::UserTurn} / {Event::Tokens} are silent
19
+ # (echo, or {TokenLog}'s business); {Event::SystemInjected} renders dim
20
+ # grey with a +⊕+ marker. Any unrecognized event — notably a gem
21
+ # *domain* event — renders generically via its +to_s+ (dim grey, +·+
22
+ # marker), so a new variant shows in the demo without a change here. Its
23
+ # text is defanged through {Pikuri::Sanitizer} — a +to_s+ may carry a
24
+ # filename, a skill name or a server's own words.
36
25
  #
37
- # == Streaming mode
26
+ # Prose — reasoning, assistant Markdown, an injected block — prints as
27
+ # written except for the bytes a terminal *acts on*, which show escaped:
28
+ #
29
+ # "done\e[1A\e[2K" # prints done\x1b[1A\x1b[2K
38
30
  #
39
- # When constructed with +streaming: true+ (typically because
40
- # the host's {Agent} was constructed with the matching flag):
31
+ # A model echoing an attacker's bytes could otherwise recolor, overwrite
32
+ # or erase lines already on screen, a guard's warning among them. Tabs
33
+ # and zero-width joiners pass, since honest prose carries them (Go code,
34
+ # 👩‍💻) — which is why this isn't {Pikuri::Sanitizer} wholesale.
41
35
  #
42
- # - {Event::ThinkingDelta} fragments print live in the same
43
- # dim grey as the non-streaming {Event::Thinking}, with no
44
- # trailing newline so the next fragment continues the line.
45
- # - {Event::AssistantDelta} fragments print live the same
46
- # way, uncolored.
47
- # - {Event::Thinking} and {Event::Assistant} bookends print
48
- # a single blank line as a stream terminator, not their
49
- # content (the content already landed via the deltas). The
50
- # terminator gives the next event (tool call, next round,
51
- # final REPL prompt) a clean line to start on.
36
+ # Assistant Markdown prints unrendered, no Markdown-to-ANSI: rendering can't
37
+ # apply to the streaming path anyway (half-built fences/tables), and the
38
+ # one gem for it (tty-markdown) was unmaintained, crashed on
39
+ # ANSI-in-tables, and pulled seven transitive deps — proper rendering
40
+ # belongs to a richer host (the planned pikuri-tui).
52
41
  #
53
- # In non-streaming mode (+streaming: false+, the default),
54
- # the deltas are silently ignored and the bookend events
55
- # render the full text the way they always have.
42
+ # +padding:+ prepends a fixed number of leading spaces to every line;
43
+ # sub-agents get a fresh padded instance via {#for_sub_agent}.
44
+ #
45
+ # == Streaming mode
46
+ #
47
+ # With +streaming: true+ (matching the {Agent}'s flag):
48
+ # {Event::ThinkingDelta} / {Event::AssistantDelta} print live (dim grey /
49
+ # uncolored, no trailing newline), and the {Event::Thinking} /
50
+ # {Event::Assistant} bookends print a single blank line as a terminator,
51
+ # not their content (already landed via deltas). With +streaming: false+
52
+ # (default) the deltas are ignored and the bookends render full text.
56
53
  class Terminal < Base
57
- # Cap, in characters, applied to tool-result content
58
- # rendered to the terminal. Anything longer is truncated
59
- # with a marker that reports the original byte size so the
60
- # reader can tell a 200-char return apart from a 50KB HTML
61
- # dump.
62
- MAX_TOOL_RESULT_CHARS = 200
54
+ # Char cap on a tool's display strings ({Event::ToolResult}'s summary, a
55
+ # display name). Generous — these are one short line by construction,
56
+ # and the cap is a backstop against an +"Error: ..."+ observation
57
+ # passing a long message through.
58
+ MAX_SUMMARY_CHARS = 200
59
+
60
+ # Floor on the room a tool-call argument gets, for the narrow terminal
61
+ # where the budget arithmetic would otherwise leave it nothing.
62
+ MIN_ARGUMENT_CHARS = 20
63
+
64
+ # The bytes a terminal acts on rather than prints, as prose may carry
65
+ # them: C0 controls bar tab and newline, DEL, C1, the bidi overrides.
66
+ # {Pikuri::Sanitizer::SUSPECT} minus tab and the zero-width set.
67
+ PROSE_SUSPECT = /[\u0000-\u0008\u000b-\u001f\u007f-\u009f‪-‮⁦-⁩]/
63
68
 
64
- # Padding applied to a sub-agent's rendered stream.
65
- # Absolute, not additive — sub-agent recursion is blocked
66
- # (the sub-agent's tool set excludes +sub_agent+ itself),
67
- # so the depth never exceeds 1 in practice and a fixed
68
- # indent reads cleanly.
69
+ # Color of the +→ call+ / += result+ lines: Kuri's Talus coat
70
+ # (+assets/kuri.svg+) with the chroma lifted, because the coat verbatim
71
+ # (+#a89c8e+, 13% saturation) lands on the dim reasoning grey's
72
+ # lightness and reads as a second shade of it. An absolute RGB rather
73
+ # than a named ANSI color, so a remapped terminal palette can't repaint
74
+ # pikuri's own color — the same hex the tui and web shells paint.
75
+ # @return [String]
76
+ TOOL_COLOR = '#c1a586'
77
+
78
+ # Padding for a sub-agent's stream. Absolute, not additive — sub-agent
79
+ # recursion is blocked (the sub-agent's toolset excludes +sub_agent+),
80
+ # so depth never exceeds 1 and a fixed indent reads cleanly.
69
81
  SUB_AGENT_PADDING = 2
70
82
 
71
- # @param padding [Integer] non-negative number of leading
72
- # spaces prepended to every rendered line. Defaults to 0;
73
- # sub-agents get a fresh instance with
74
- # {SUB_AGENT_PADDING} via {#for_sub_agent}.
75
- # @param streaming [Boolean] render the chunk-level delta
76
- # stream live. See the class header's "Streaming mode"
77
- # section for the behavior swap. Defaults to +false+.
83
+ # @param padding [Integer] non-negative leading spaces per line
84
+ # (default 0; sub-agents get {SUB_AGENT_PADDING} via {#for_sub_agent}).
85
+ # @param streaming [Boolean] render the chunk-level delta stream live
86
+ # (default +false+; see "Streaming mode").
78
87
  def initialize(padding: 0, streaming: false)
79
88
  super()
80
89
  @padding = padding
@@ -82,22 +91,15 @@ module Pikuri
82
91
  @at_line_start = true
83
92
  end
84
93
 
85
- # @return [Integer] current padding width; exposed so
86
- # callers can introspect it (and so tests can assert it).
94
+ # @return [Integer] current padding width.
87
95
  attr_reader :padding
88
96
 
89
- # @return [Boolean] +true+ when this Terminal is in
90
- # streaming mode (deltas rendered live; bookends emit a
91
- # terminator newline only).
97
+ # @return [Boolean] +true+ in streaming mode.
92
98
  attr_reader :streaming
93
99
 
94
- # Sub-agent variant: a fresh +Terminal+ at
95
- # {SUB_AGENT_PADDING}, carrying the same +streaming+ flag
96
- # the parent had, so sub-agent output is visually indented
97
- # under the parent's stream and the stream mode stays
98
- # consistent across the agent tree. Called by
99
- # {ListenerList#for_sub_agent}; ignores any params it's
100
- # handed (Terminal has no caller-provided knobs).
100
+ # Sub-agent variant: a fresh +Terminal+ at {SUB_AGENT_PADDING} carrying
101
+ # the parent's +streaming+ flag, so sub-agent output indents under the
102
+ # parent's stream. Ignores any params (Terminal has no caller knobs).
101
103
  #
102
104
  # @return [Terminal]
103
105
  def for_sub_agent(**)
@@ -113,40 +115,41 @@ module Pikuri
113
115
  if @streaming
114
116
  terminate_stream
115
117
  else
116
- println(indent(Rainbow(content).color(85, 85, 85)))
118
+ println(indent(Rainbow(defang_prose(content)).color(85, 85, 85)))
117
119
  end
118
120
  in Event::Assistant(content:)
119
121
  if @streaming
120
122
  terminate_stream
121
123
  else
122
- println(indent(content))
124
+ println(indent(defang_prose(content)))
123
125
  end
124
126
  in Event::ThinkingDelta(content:)
125
- stream_fragment(Rainbow(content).color(85, 85, 85)) if @streaming
127
+ stream_fragment(Rainbow(defang_prose(content)).color(85, 85, 85)) if @streaming
126
128
  in Event::AssistantDelta(content:)
127
- stream_fragment(content) if @streaming
129
+ stream_fragment(defang_prose(content)) if @streaming
128
130
  in Event::SystemInjected(content:)
129
- println(indent(Rainbow("⊕ #{content}").color(85, 85, 85)))
130
- in Event::ToolCall(name:, arguments:)
131
- args = arguments.map { |k, v| "#{k}=#{v.inspect}" }.join(', ')
132
- println(indent(Rainbow("→ #{name}(#{args})").cyan))
133
- in Event::ToolResult(content:)
134
- println(indent(Rainbow("= #{truncate_tool_result(content)}").cyan))
131
+ println(indent(Rainbow("⊕ #{defang_prose(content)}").color(85, 85, 85)))
132
+ in Event::ToolCall(display_name:, argument:)
133
+ println(indent(Rainbow("→ #{tool_call_line(display_name, argument)}").color(TOOL_COLOR)))
134
+ in Event::ToolResult(summary:)
135
+ println(indent(Rainbow("= #{defang(summary, MAX_SUMMARY_CHARS)}").color(TOOL_COLOR)))
135
136
  in Event::ModelSwitched(from:, to:)
136
137
  println(indent(Rainbow("⇄ model: #{from.model} → #{to.model}").magenta))
137
- in Event::FallbackNotice(reason:)
138
- println(indent(Rainbow("! #{reason}").yellow))
138
+ in Event::HistoryCompacted(messages_before:, messages_after:)
139
+ println(indent(Rainbow("⇣ compacted: #{messages_before} → #{messages_after} messages").magenta))
139
140
  in Event::Cancelled
140
141
  println(indent(Rainbow('! cancelled').red))
142
+ in Event::UserTurn | Event::Tokens
143
+ # Silent: UserTurn echoes just-typed input; Tokens are TokenLog's. (Non-streaming deltas no-op in their branches above.)
141
144
  else
142
- # UserTurn / Tokens / ContextCap silent on the terminal.
143
- # In non-streaming mode the deltas fall through here
144
- # too (the final Thinking / Assistant bookend already
145
- # renders the full text).
145
+ # Any other event — notably a gem *domain* event — renders via its
146
+ # own to_s; core needs no knowledge of the type. A richer host
147
+ # pattern-matches the variants it styles.
148
+ domain_event(event)
146
149
  end
147
150
  end
148
151
 
149
- # @return [String] short label for {Agent#to_s}; appends
152
+ # @return [String] short label for {ListenerList#to_s}; appends
150
153
  # each non-default knob (+padding+, +streaming+) so the
151
154
  # default form stays +"Terminal"+
152
155
  def to_s
@@ -158,12 +161,9 @@ module Pikuri
158
161
 
159
162
  private
160
163
 
161
- # +puts+ wrapper that also resets the streaming line-state
162
- # to "at line start" — every full-line print necessarily
163
- # leaves the cursor at column 0, so the next fragment
164
- # printed in streaming mode knows to insert padding before
165
- # its first character. Used by every branch in
166
- # {#on_event} except the delta branches.
164
+ # +puts+ wrapper that resets the streaming line-state to "at line
165
+ # start" (a full-line print leaves the cursor at column 0, so the next
166
+ # streamed fragment knows to insert padding first).
167
167
  #
168
168
  # @param text [String]
169
169
  # @return [void]
@@ -172,12 +172,18 @@ module Pikuri
172
172
  @at_line_start = true
173
173
  end
174
174
 
175
- # Emit a single newline as a stream terminator and reset
176
- # the line-state. Called on {Event::Thinking} /
177
- # {Event::Assistant} bookends in streaming mode, where the
178
- # content has already been rendered via the delta stream
179
- # and what's left to do is give the next event a clean
180
- # line to start on.
175
+ # A gem domain event as one defanged, dimmed line.
176
+ #
177
+ # @param event [Object] any event variant this listener does not style.
178
+ # @return [void]
179
+ def domain_event(event)
180
+ text = Sanitizer.sanitize(event.to_s.gsub(/\s+/, ' ').strip).text
181
+ println(indent(Rainbow("· #{text}").color(85, 85, 85)))
182
+ end
183
+
184
+ # Emit a newline as a stream terminator and reset line-state — the
185
+ # {Event::Thinking}/{Event::Assistant} bookend in streaming mode, where
186
+ # the content already rendered via deltas.
181
187
  #
182
188
  # @return [void]
183
189
  def terminate_stream
@@ -185,16 +191,12 @@ module Pikuri
185
191
  @at_line_start = true
186
192
  end
187
193
 
188
- # Print one streaming fragment to stdout *without* a
189
- # trailing newline (so the next fragment continues the
190
- # line) and flush so the bytes actually reach the
191
- # terminal. Threads padding through any mid-fragment
192
- # newlines: a fragment that contains "foo\nbar" with
193
- # padding 2 prints +" foo\n bar"+ when the cursor was
194
- # at line start.
194
+ # Print one streaming fragment without a trailing newline (so the next
195
+ # continues the line) and flush. Threads padding through mid-fragment
196
+ # newlines: "foo\nbar" at padding 2 from line start prints
197
+ # +" foo\n bar"+.
195
198
  #
196
- # @param text [String] the fragment to emit; +nil+ / empty
197
- # short-circuits
199
+ # @param text [String] the fragment; +nil+/empty short-circuits
198
200
  # @return [void]
199
201
  def stream_fragment(text)
200
202
  return if text.nil? || text.empty?
@@ -215,11 +217,9 @@ module Pikuri
215
217
  $stdout.flush
216
218
  end
217
219
 
218
- # Prepend +@padding+ spaces to every line of +text+. Splits
219
- # on +each_line+ rather than a +gsub+ trick so a trailing
220
- # newline in the input doesn't produce a stray padded blank
221
- # line at the end — +puts+ adds the final newline if
222
- # missing, same as before.
220
+ # Prepend +@padding+ spaces to every line of +text+. Uses +each_line+,
221
+ # not a +gsub+, so a trailing newline doesn't produce a stray padded
222
+ # blank line.
223
223
  #
224
224
  # @param text [String]
225
225
  # @return [String]
@@ -230,30 +230,63 @@ module Pikuri
230
230
  text.to_s.each_line.map { |line| prefix + line }.join
231
231
  end
232
232
 
233
- # Flatten whitespace and cap to {MAX_TOOL_RESULT_CHARS}. The
234
- # cap keeps multi-screen dumps (rendered HTML, PDF text)
235
- # from drowning the terminal stream; the byte-count suffix
236
- # on a truncated result distinguishes "tool returned
237
- # exactly this" from "tool returned much more, you're
238
- # seeing a slice."
233
+ # The +Name(argument)+ half of a tool-call line, the argument capped to
234
+ # whatever the row has left — a +command+ can be a 4 kB script and a
235
+ # +path+ a very long one, and only a renderer knows its width.
239
236
  #
240
- # Whitespace is flattened *first* (collapsing real tabs, CRs and
241
- # newlines into single spaces — fine here, since this passive
242
- # echo is a status line, not an approval artifact), then the
243
- # result runs through {Pikuri::Sanitizer} so a tool observation
244
- # can't smuggle an ESC or other control byte into this cyan line.
245
- # The sanitizer's warnings are dropped — they belong at a
246
- # confirmation prompt, not the stream narration.
237
+ # tool_call_line('Write', 'lib/shared/config.rb') # => "Write(lib/shared/config.rb)"
238
+ # tool_call_line('Status', '') # => "Status"
247
239
  #
248
- # @param content [String] tool observation
249
- # @return [String] single-line display form, possibly
250
- # truncated
251
- def truncate_tool_result(content)
252
- original_bytes = content.to_s.bytesize
253
- flattened = Sanitizer.sanitize(content.to_s.gsub(/\s+/, ' ').strip).text
254
- return flattened if flattened.length <= MAX_TOOL_RESULT_CHARS
240
+ # @param display_name [String] see {Pikuri::Tool#display_name}
241
+ # @param argument [String] see {Pikuri::Tool#describe_call}
242
+ # @return [String]
243
+ def tool_call_line(display_name, argument)
244
+ name = defang(display_name, MAX_SUMMARY_CHARS)
245
+ return name if argument.to_s.empty?
246
+
247
+ # "→ ", the parens, and the padding are all on this row too.
248
+ budget = terminal_width - @padding - name.length - 5
249
+ "#{name}(#{defang(argument, [budget, MIN_ARGUMENT_CHARS].max)})"
250
+ end
251
+
252
+ # Flatten whitespace, defang, and cap to +limit+ — every display string
253
+ # off the event stream goes through this.
254
+ #
255
+ # Whitespace flattening is safe here (a passive status line, not an
256
+ # approval artifact); {Pikuri::Sanitizer} is what stops a path carrying
257
+ # +ESC[+ or a CR from recoloring or overwriting the transcript, now that
258
+ # these strings no longer pass through +inspect+. Its warnings are
259
+ # dropped — they belong at a confirmation prompt.
260
+ #
261
+ # @param text [String, nil]
262
+ # @param limit [Integer] max characters, +…+ marking a cut
263
+ # @return [String]
264
+ def defang(text, limit)
265
+ flattened = Sanitizer.sanitize(text.to_s.gsub(/\s+/, ' ').strip).text
266
+ return flattened if flattened.length <= limit
267
+
268
+ "#{flattened[0, limit - 1]}…"
269
+ end
270
+
271
+ # Escape the {PROSE_SUSPECT} bytes in Sanitizer's notation, +\x1b+ /
272
+ # +\u{202e}+; per character, so an escape split across two streamed
273
+ # fragments is caught in whichever half its ESC lands.
274
+ #
275
+ # @param text [String] model- or host-authored prose
276
+ # @return [String]
277
+ def defang_prose(text)
278
+ text.gsub(PROSE_SUSPECT) do |ch|
279
+ cp = ch.ord
280
+ cp >= 0x202a ? format('\\u{%04x}', cp) : format('\\x%02x', cp)
281
+ end
282
+ end
255
283
 
256
- "#{flattened[0, MAX_TOOL_RESULT_CHARS]}… (#{original_bytes} bytes total)"
284
+ # @return [Integer] terminal columns; 80 when stdout has no window size
285
+ # (a pipe, a file, a captured StringIO).
286
+ def terminal_width
287
+ $stdout.winsize[1]
288
+ rescue StandardError
289
+ 80
257
290
  end
258
291
  end
259
292
  end