legion-settings 1.3.7 → 1.3.8
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 +8 -0
- data/lib/legion/settings/agent_loader.rb +45 -0
- data/lib/legion/settings/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1f33fc603ef7e3e977a241fce4e06dc22d3d63dc1781c99108a13f3b13b139dc
|
|
4
|
+
data.tar.gz: dc072b339d377a53bab15abee76acb38be1774658f5e6bd89b76c30b468781bb
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 21767fcba605c3bd7e81191ed5f0268d743735ac71d8c3158cb3a0f5e615cbf809ac172f725110bb857ee511758d4c9d2b05b5063efb7425244879789c878dc3
|
|
7
|
+
data.tar.gz: 4cc7013a89fe254b562d8f3eb325b004f858ca8928cc50e91b58014213608f36c14a892f5a3b15758a5795acf133300d4ab9e395b0d998d328a97afe61a0677a
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Legion::Settings Changelog
|
|
2
2
|
|
|
3
|
+
## [1.3.8] - 2026-03-20
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
- `AgentLoader` module for loading YAML/JSON agent definitions from a directory
|
|
7
|
+
- `AgentLoader.load_agents(directory)` — returns validated agent definitions as symbol-keyed hashes
|
|
8
|
+
- `AgentLoader.load_file(path)` — parses `.yaml`, `.yml`, and `.json` agent definition files
|
|
9
|
+
- `AgentLoader.valid?(definition)` — validates required `name` and `runner.functions` keys
|
|
10
|
+
|
|
3
11
|
## [1.3.7] - 2026-03-20
|
|
4
12
|
|
|
5
13
|
### Added
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'yaml'
|
|
4
|
+
require 'json'
|
|
5
|
+
|
|
6
|
+
module Legion
|
|
7
|
+
module Settings
|
|
8
|
+
module AgentLoader
|
|
9
|
+
EXTENSIONS = %w[.yaml .yml .json].freeze
|
|
10
|
+
GLOB = '*.{yaml,yml,json}'
|
|
11
|
+
|
|
12
|
+
class << self
|
|
13
|
+
def load_agents(directory)
|
|
14
|
+
return [] unless directory && Dir.exist?(directory)
|
|
15
|
+
|
|
16
|
+
Dir.glob(File.join(directory, GLOB)).filter_map do |path|
|
|
17
|
+
definition = load_file(path)
|
|
18
|
+
next unless definition && valid?(definition)
|
|
19
|
+
|
|
20
|
+
definition.merge(_source_path: path, _source_mtime: File.mtime(path))
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def load_file(path)
|
|
25
|
+
content = File.read(path)
|
|
26
|
+
case File.extname(path).downcase
|
|
27
|
+
when '.yaml', '.yml' then YAML.safe_load(content, symbolize_names: true)
|
|
28
|
+
when '.json' then ::JSON.parse(content, symbolize_names: true)
|
|
29
|
+
end
|
|
30
|
+
rescue StandardError
|
|
31
|
+
nil
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def valid?(definition)
|
|
35
|
+
return false unless definition.is_a?(Hash)
|
|
36
|
+
return false unless definition[:name].is_a?(String) && !definition[:name].empty?
|
|
37
|
+
return false unless definition.dig(:runner, :functions).is_a?(Array)
|
|
38
|
+
return false if definition[:runner][:functions].empty?
|
|
39
|
+
|
|
40
|
+
true
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: legion-settings
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.3.
|
|
4
|
+
version: 1.3.8
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Esity
|
|
@@ -46,6 +46,7 @@ files:
|
|
|
46
46
|
- docs/plans/2026-03-17-config-error-filename-implementation.md
|
|
47
47
|
- legion-settings.gemspec
|
|
48
48
|
- lib/legion/settings.rb
|
|
49
|
+
- lib/legion/settings/agent_loader.rb
|
|
49
50
|
- lib/legion/settings/dns_bootstrap.rb
|
|
50
51
|
- lib/legion/settings/loader.rb
|
|
51
52
|
- lib/legion/settings/os.rb
|