Class: Rubino::Session::Exporter

Inherits:
Object
  • Object
show all
Defined in:
lib/rubino/session/exporter.rb

Overview

Serializes one session’s transcript to clean markdown — the ‘/export` backend. Deliberately minimal: user/assistant turns verbatim, tool calls and tool results as one-liners, system rows (prompt scaffolding, compaction summaries) omitted. Reasoning never reaches the message store, so a transcript export is reasoning-free by construction.

Constant Summary collapse

ARGS_PREVIEW_CHARS =

Tool-call arguments are context, not payload — clamp the one-liner.

120

Instance Method Summary collapse

Constructor Details

#initialize(session, store: Store.new) ⇒ Exporter

Returns a new instance of Exporter.



17
18
19
20
# File 'lib/rubino/session/exporter.rb', line 17

def initialize(session, store: Store.new)
  @session = session
  @store = store
end

Instance Method Details

#default_filenameObject



39
40
41
# File 'lib/rubino/session/exporter.rb', line 39

def default_filename
  "rubino-session-#{@session[:id].to_s[0, 8]}.md"
end

#markdownObject

The full markdown document for the session.



23
24
25
26
27
28
29
# File 'lib/rubino/session/exporter.rb', line 23

def markdown
  lines = header
  @store.for_session(@session[:id]).each do |msg|
    lines.concat(render(msg))
  end
  "#{lines.join("\n")}\n"
end

#write(path = nil) ⇒ Object

Writes #markdown to path (default ./rubino-session-<id8>.md in the current directory) and returns the absolute path written.



33
34
35
36
37
# File 'lib/rubino/session/exporter.rb', line 33

def write(path = nil)
  target = File.expand_path(path.to_s.empty? ? default_filename : path.to_s)
  File.write(target, markdown)
  target
end