legion-tty 0.4.36 → 0.4.38
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/CHANGELOG.md +16 -0
- data/lib/legion/tty/screens/chat.rb +47 -4
- data/lib/legion/tty/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5015163992ac8b889c19088f2caa60b3e80fc09445c7feb27085f4c39c0857a5
|
|
4
|
+
data.tar.gz: 6eadf44a9366956867b097b1a10769ae18b01d1a644daae91c3ea5fade6681b3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 914de3d2b07691224655ac5b1dd4bb7b1dd9b88083fde6a0b719c9398a654c0b91640c621ea88865d11ad8b737909af0a24dcbae9ff1e4d200be8eda58d14af6
|
|
7
|
+
data.tar.gz: dd740544c87c71fa843e72ad602f49d029cd485f16d4b2532e55927ce33b2019042772812f59281aa00633c75af9ed5b3ce0f89c84070bd250ce51c27db304bf
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.4.38] - 2026-03-26
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
- `build_system_prompt` injects a live self-awareness section from `lex-agentic-self` Metacognition when the gem is loaded; guarded with a `defined?` check and `rescue StandardError` so chat is unaffected if the module is absent or raises; narrative is stripped and capped at 2000 chars to prevent prompt bloat
|
|
7
|
+
|
|
8
|
+
## [0.4.37] - 2026-03-26
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
- Token tracking uses `model_id` from RubyLLM::Message response (was incorrectly checking non-existent `model` method)
|
|
12
|
+
- Initialize TokenTracker with actual model from LLM chat session when available
|
|
13
|
+
- Guard against blank `model_id` in `track_response_tokens` — a nil `model_id` no longer overwrites the previously-set model with an empty string
|
|
14
|
+
|
|
15
|
+
### Added
|
|
16
|
+
- Daemon path token tracking via `track_daemon_tokens` (reads `meta[:tokens_in]`/`meta[:tokens_out]` from daemon response)
|
|
17
|
+
- Extracted `update_status_bar_tokens` helper to DRY up status bar updates after tracking
|
|
18
|
+
|
|
3
19
|
## [0.4.36] - 2026-03-26
|
|
4
20
|
|
|
5
21
|
### Changed
|
|
@@ -74,7 +74,10 @@ module Legion
|
|
|
74
74
|
@message_stream = Components::MessageStream.new
|
|
75
75
|
@status_bar = Components::StatusBar.new
|
|
76
76
|
@llm_chat = app.respond_to?(:llm_chat) ? app.llm_chat : nil
|
|
77
|
-
@token_tracker = Components::TokenTracker.new(
|
|
77
|
+
@token_tracker = Components::TokenTracker.new(
|
|
78
|
+
provider: detect_provider,
|
|
79
|
+
model: @llm_chat.respond_to?(:model) ? @llm_chat.model.to_s : nil
|
|
80
|
+
)
|
|
78
81
|
@session_store = SessionStore.new
|
|
79
82
|
@session_name = 'default'
|
|
80
83
|
@plan_mode = false
|
|
@@ -251,6 +254,7 @@ module Legion
|
|
|
251
254
|
parser = build_tool_call_parser
|
|
252
255
|
parser.feed(result[:response])
|
|
253
256
|
parser.flush
|
|
257
|
+
track_daemon_tokens(result)
|
|
254
258
|
when :error
|
|
255
259
|
err = result.dig(:error, :message) || 'Unknown error'
|
|
256
260
|
@message_stream.append_streaming("\n[Daemon error: #{err}]")
|
|
@@ -340,6 +344,26 @@ module Legion
|
|
|
340
344
|
lines << "Top languages: #{env[:top_languages].keys.join(', ')}" if env[:top_languages]&.any?
|
|
341
345
|
end
|
|
342
346
|
|
|
347
|
+
if defined?(Legion::Extensions::Agentic::Self::Metacognition::Runners::Metacognition)
|
|
348
|
+
begin
|
|
349
|
+
result = Legion::Extensions::Agentic::Self::Metacognition::Runners::Metacognition.self_narrative
|
|
350
|
+
narrative = result[:prose] if result.is_a?(Hash) && result[:prose]
|
|
351
|
+
if narrative
|
|
352
|
+
narrative = narrative.strip
|
|
353
|
+
narrative = narrative[0, 2000] if narrative.length > 2000
|
|
354
|
+
end
|
|
355
|
+
if narrative && !narrative.empty?
|
|
356
|
+
lines << ''
|
|
357
|
+
lines << 'Current self-awareness:'
|
|
358
|
+
lines << narrative
|
|
359
|
+
end
|
|
360
|
+
rescue StandardError => e
|
|
361
|
+
if defined?(Legion::Logging)
|
|
362
|
+
Legion::Logging.warn("Metacognition.self_narrative failed: #{e.class}: #{e.message}")
|
|
363
|
+
end
|
|
364
|
+
end
|
|
365
|
+
end
|
|
366
|
+
|
|
343
367
|
lines.join("\n")
|
|
344
368
|
end
|
|
345
369
|
# rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
|
|
@@ -602,12 +626,31 @@ module Legion
|
|
|
602
626
|
def track_response_tokens(response)
|
|
603
627
|
return unless response.respond_to?(:input_tokens)
|
|
604
628
|
|
|
605
|
-
|
|
629
|
+
raw_model = response.respond_to?(:model_id) ? response.model_id.to_s : nil
|
|
630
|
+
model_id = raw_model && !raw_model.empty? ? raw_model : nil
|
|
631
|
+
input_tokens = response.input_tokens.to_i
|
|
632
|
+
output_tokens = response.respond_to?(:output_tokens) ? response.output_tokens.to_i : 0
|
|
606
633
|
@token_tracker.track(
|
|
607
|
-
input_tokens:
|
|
608
|
-
output_tokens:
|
|
634
|
+
input_tokens: input_tokens,
|
|
635
|
+
output_tokens: output_tokens,
|
|
609
636
|
model: model_id
|
|
610
637
|
)
|
|
638
|
+
update_status_bar_tokens
|
|
639
|
+
end
|
|
640
|
+
|
|
641
|
+
def track_daemon_tokens(result)
|
|
642
|
+
meta = result[:meta]
|
|
643
|
+
return unless meta.is_a?(Hash) && (meta[:tokens_in] || meta[:tokens_out])
|
|
644
|
+
|
|
645
|
+
@token_tracker.track(
|
|
646
|
+
input_tokens: meta[:tokens_in].to_i,
|
|
647
|
+
output_tokens: meta[:tokens_out].to_i,
|
|
648
|
+
model: meta[:model]&.to_s
|
|
649
|
+
)
|
|
650
|
+
update_status_bar_tokens
|
|
651
|
+
end
|
|
652
|
+
|
|
653
|
+
def update_status_bar_tokens
|
|
611
654
|
@status_bar.update(
|
|
612
655
|
tokens: @token_tracker.total_input_tokens + @token_tracker.total_output_tokens,
|
|
613
656
|
cost: @token_tracker.total_cost
|
data/lib/legion/tty/version.rb
CHANGED