legion-tty 0.4.41 → 0.4.42

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2e5ecb9de86922a5a3d4dd3b3eca6b4f7864103c89399a8a945bbae95e749814
4
- data.tar.gz: 0d25f75d79303fd7a42a9fbf125768503c48f16e5c749b799cd2013d68bae99a
3
+ metadata.gz: 544115343036952adfc2f3accc8ce189ec8bb13c06f04ce383d0536549118e49
4
+ data.tar.gz: 806f22df6bed2c34ce6c47c6eab8c1af6bb611cc458db878087a86163f7e0248
5
5
  SHA512:
6
- metadata.gz: 804bc560650b61a6987a8f9d4d02cd7a315caeaccd1823f1b11a4e1b1fe024fc0eb37a35c59bafe654c0738f2e201af9b04d7274bd9c7d8df02b563c6551336b
7
- data.tar.gz: 15ab28737a1677ae28285400d1e9ae6b794f1ea021e4cc7c194e949e59a97df56c054419d21fd351c70ea97636608d09a8a6737ca7a690e17b398e87531e6c1c
6
+ metadata.gz: 4a90450fe8ba541b1823f43cfc89eb97ed2ef6185029afffc022771c87f8909583fab80715098789240b8bab4ee3c8c2ae240987dc9630352c76d89ee3acad6a
7
+ data.tar.gz: '0667478fd7867da23c0c5f4a83fdeac3056cc97ff18a2bf1dbe0c447f4a29088b0e1d6aafeb6d9b19ffc8a1784b4cd80f1a94a2d9ea5a2563fca063004020ee5'
data/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.4.42] - 2026-04-08
4
+
5
+ ### Changed
6
+ - `DaemonClient` now uses `Legion::Logging::Helper` (structured logging via `log.info`/`log.debug`) instead of inline `Legion::Logging.method if defined?` guards for all logging and exception handling
7
+ - Bumped `legion-logging` minimum dependency from `>= 1.2.8` to `>= 1.5.0` to use `handle_exception` from `Legion::Logging::Helper`
8
+ - Extracted `store_manifest` and `parse_inference_response` private helpers to reduce method complexity in `fetch_manifest` and `inference`
9
+
10
+ ### Fixed
11
+ - `KerberosProbe#days_in_month` used `Time.new(year, month, -1)` which raises `ArgumentError` for day `-1`; replaced with `Date.new(year, month, -1).day` (correct Ruby idiom for last day of month)
12
+
3
13
  ## [0.4.41] - 2026-03-31
4
14
 
5
15
  ### Added
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Rich terminal UI for the LegionIO async cognition engine.
4
4
 
5
- **Version**: 0.4.35
5
+ **Version**: 0.4.42
6
6
 
7
7
  Think Claude Code meets Codex CLI, but for LegionIO: onboarding wizard with identity detection, streaming AI chat shell with 115 slash commands, operational dashboard, extensions browser, config editor, and session persistence - all rendered with the [tty-ruby](https://ttytoolkit.org/) gem ecosystem.
8
8
 
@@ -289,8 +289,8 @@ Boot logs go to `~/.legionio/logs/tty-boot.log`.
289
289
 
290
290
  ```bash
291
291
  bundle install
292
- bundle exec rspec # 1817 examples, 0 failures
293
- bundle exec rubocop # 150 files, 0 offenses
292
+ bundle exec rspec # 1952 examples, 0 failures
293
+ bundle exec rubocop # 163 files, 0 offenses
294
294
  ```
295
295
 
296
296
  ## License
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'date'
3
4
  require 'resolv'
4
5
  require 'shellwords'
5
6
 
@@ -185,7 +186,7 @@ module Legion
185
186
  # rubocop:enable Metrics/AbcSize
186
187
 
187
188
  def days_in_month(month, year)
188
- Time.new(year, month, -1).day
189
+ Date.new(year, month, -1).day
189
190
  end
190
191
 
191
192
  def log_result(result, elapsed)
@@ -4,6 +4,7 @@ require 'net/http'
4
4
  require 'uri'
5
5
  require 'fileutils'
6
6
  require 'legion/json'
7
+ require 'legion/logging'
7
8
 
8
9
  module Legion
9
10
  module TTY
@@ -12,11 +13,14 @@ module Legion
12
13
 
13
14
  # rubocop:disable Metrics/ClassLength
14
15
  class << self
16
+ include Legion::Logging::Helper
17
+
15
18
  def configure(daemon_url: 'http://127.0.0.1:4567', cache_file: nil, timeout: 5)
16
19
  @daemon_url = daemon_url
17
20
  @cache_file = cache_file || File.expand_path('~/.legionio/catalog.json')
18
21
  @timeout = timeout
19
22
  @manifest = nil
23
+ log.info { "TTY daemon client configured daemon_url=#{@daemon_url} timeout=#{@timeout}" }
20
24
  end
21
25
 
22
26
  def available?
@@ -26,7 +30,7 @@ module Legion
26
30
  end
27
31
  response.code.to_i == 200
28
32
  rescue StandardError => e
29
- Legion::Logging.debug("daemon available? check failed: #{e.message}") if defined?(Legion::Logging)
33
+ handle_exception(e, level: :debug, operation: 'tty.daemon_client.available?', daemon_url: daemon_url)
30
34
  false
31
35
  end
32
36
 
@@ -37,12 +41,9 @@ module Legion
37
41
  end
38
42
  return nil unless response.code.to_i == 200
39
43
 
40
- body = Legion::JSON.load(response.body)
41
- @manifest = body[:data]
42
- write_cache(@manifest)
43
- @manifest
44
+ store_manifest(Legion::JSON.load(response.body)[:data])
44
45
  rescue StandardError => e
45
- Legion::Logging.warn("fetch_manifest failed: #{e.message}") if defined?(Legion::Logging)
46
+ handle_exception(e, level: :warn, operation: 'tty.daemon_client.fetch_manifest', daemon_url: daemon_url)
46
47
  nil
47
48
  end
48
49
 
@@ -53,7 +54,7 @@ module Legion
53
54
 
54
55
  @manifest = Legion::JSON.load(File.read(@cache_file))
55
56
  rescue StandardError => e
56
- Legion::Logging.warn("cached_manifest failed: #{e.message}") if defined?(Legion::Logging)
57
+ handle_exception(e, level: :warn, operation: 'tty.daemon_client.cached_manifest', cache_file: @cache_file)
57
58
  nil
58
59
  end
59
60
 
@@ -80,26 +81,28 @@ module Legion
80
81
 
81
82
  uri = URI("#{daemon_url}/api/llm/chat")
82
83
  payload = Legion::JSON.dump({ message: message, model: model, provider: provider })
84
+ log.debug { "TTY chat request model=#{model} provider=#{provider} message_length=#{message.to_s.length}" }
83
85
  response = post_json(uri, payload)
84
86
 
85
87
  return nil unless response && SUCCESS_CODES.include?(response.code.to_i)
86
88
 
87
89
  Legion::JSON.load(response.body)
88
90
  rescue StandardError => e
89
- Legion::Logging.warn("chat failed: #{e.message}") if defined?(Legion::Logging)
91
+ handle_exception(e, level: :warn, operation: 'tty.daemon_client.chat',
92
+ daemon_url: daemon_url, model: model, provider: provider)
90
93
  nil
91
94
  end
92
95
 
93
96
  def inference(messages:, tools: [], model: nil, provider: nil, timeout: 120)
97
+ log.debug { "TTY inference model=#{model} provider=#{provider} msgs=#{Array(messages).size}" }
94
98
  response = post_inference(messages: messages, tools: tools, model: model,
95
99
  provider: provider, timeout: timeout)
96
100
  return inference_error_result(response) unless SUCCESS_CODES.include?(response.code.to_i)
97
101
 
98
- body = Legion::JSON.load(response.body)
99
- data = body[:data] || body
100
- { status: :ok, data: data }
102
+ parse_inference_response(response)
101
103
  rescue StandardError => e
102
- Legion::Logging.warn("inference failed: #{e.message}") if defined?(Legion::Logging)
104
+ handle_exception(e, level: :warn, operation: 'tty.daemon_client.inference',
105
+ daemon_url: daemon_url, model: model, provider: provider, timeout: timeout)
103
106
  { status: :unavailable, error: { message: e.message } }
104
107
  end
105
108
 
@@ -112,6 +115,19 @@ module Legion
112
115
 
113
116
  private
114
117
 
118
+ def parse_inference_response(response)
119
+ body = Legion::JSON.load(response.body)
120
+ data = body[:data] || body
121
+ { status: :ok, data: data }
122
+ end
123
+
124
+ def store_manifest(data)
125
+ @manifest = data
126
+ write_cache(@manifest)
127
+ log.info { "TTY fetched daemon manifest entries=#{Array(@manifest).size}" }
128
+ @manifest
129
+ end
130
+
115
131
  def post_inference(messages:, tools:, model:, provider:, timeout:)
116
132
  uri = URI("#{daemon_url}/api/llm/inference")
117
133
  payload = Legion::JSON.dump({ messages: messages, tools: tools,
@@ -151,8 +167,9 @@ module Legion
151
167
 
152
168
  FileUtils.mkdir_p(File.dirname(@cache_file))
153
169
  File.write(@cache_file, Legion::JSON.dump(data))
170
+ log.debug { "TTY daemon manifest cache updated file=#{@cache_file}" }
154
171
  rescue StandardError => e
155
- Legion::Logging.warn("write_cache failed: #{e.message}") if defined?(Legion::Logging)
172
+ handle_exception(e, level: :warn, operation: 'tty.daemon_client.write_cache', cache_file: @cache_file)
156
173
  nil
157
174
  end
158
175
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Legion
4
4
  module TTY
5
- VERSION = '0.4.41'
5
+ VERSION = '0.4.42'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: legion-tty
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.41
4
+ version: 0.4.42
5
5
  platform: ruby
6
6
  authors:
7
7
  - Esity
@@ -197,14 +197,14 @@ dependencies:
197
197
  requirements:
198
198
  - - ">="
199
199
  - !ruby/object:Gem::Version
200
- version: 1.2.8
200
+ version: 1.5.0
201
201
  type: :runtime
202
202
  prerelease: false
203
203
  version_requirements: !ruby/object:Gem::Requirement
204
204
  requirements:
205
205
  - - ">="
206
206
  - !ruby/object:Gem::Version
207
- version: 1.2.8
207
+ version: 1.5.0
208
208
  description: Rich TUI with onboarding wizard, AI chat shell, and operational dashboards
209
209
  for LegionIO
210
210
  email: