Module: ClaudeMemory::Observe::ObservationsRenderer
- Defined in:
- lib/claude_memory/observe/observations_renderer.rb
Overview
Renders episodic observation rows into the actor-facing markdown block —the front-loaded “what happened” log that complements the fact snapshot (“what is true”).
Priority is an internal Observer/Reflector signal. Following Mastra, only 🔴 (important) survives as a marker when shown to the actor; 🟡/🟢 are stripped as visual noise. The observation bodies themselves are always shown — the emoji is the only thing filtered.
Constant Summary collapse
- IMPORTANT_MARKER =
"🔴"
Class Method Summary collapse
-
.format_line(obs) ⇒ String
id tag lets the reflection step reference an observation for promote/consolidate; it’s omitted when the row carries no id.
-
.render(observations, title: "Observations (what happened)", intro: true) ⇒ String?
Markdown block, or nil when there is nothing to show.
Class Method Details
.format_line(obs) ⇒ String
id tag lets the reflection step reference an observation for promote/consolidate; it’s omitted when the row carries no id.
39 40 41 42 43 44 45 46 |
# File 'lib/claude_memory/observe/observations_renderer.rb', line 39 def format_line(obs) body = obs[:body].to_s.strip id_tag = obs[:id] ? "[##{obs[:id]}] " : "" marker = (obs[:priority] == Domain::Observation::IMPORTANT) ? "#{IMPORTANT_MARKER} " : "" ago = Core::RelativeTime.format(obs[:observed_at]) suffix = ago ? " (#{ago})" : "" "- #{id_tag}#{marker}#{body}#{suffix}" end |
.render(observations, title: "Observations (what happened)", intro: true) ⇒ String?
Returns markdown block, or nil when there is nothing to show.
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/claude_memory/observe/observations_renderer.rb', line 22 def render(observations, title: "Observations (what happened)", intro: true) rows = Array(observations).reject { |o| o[:body].to_s.strip.empty? } return nil if rows.empty? lines = ["## #{title}"] if intro lines << "" lines << "Episodic log of what happened in this project — complements the facts above (what is true). Newest first." end lines << "" rows.each { |obs| lines << format_line(obs) } lines.join("\n") end |