ad-agent_architecture 0.0.12 → 0.0.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +7 -0
- data/CHANGELOG.md +7 -0
- data/Gemfile +1 -0
- data/Guardfile +0 -6
- data/bin/watch.rb +29 -0
- data/lib/ad/agent_architecture/dsl/actions/save_database.rb +12 -1
- data/lib/ad/agent_architecture/dsl/agent_dsl.rb +5 -1
- data/lib/ad/agent_architecture/dsl/attribute_dsl.rb +2 -0
- data/lib/ad/agent_architecture/dsl/prompt_dsl.rb +3 -1
- data/lib/ad/agent_architecture/dsl/section_dsl.rb +3 -1
- data/lib/ad/agent_architecture/dsl/step_dsl.rb +8 -3
- data/lib/ad/agent_architecture/version.rb +1 -1
- data/package-lock.json +2 -2
- data/package.json +1 -1
- metadata +3 -3
- data/lib/ad/agent_architecture/dsl/agent_workflow_dsl.rb.old +0 -84
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c41297848057dc821b24cf29aa498f6cf409a03ca73d742d00cc44dc82a77a23
|
4
|
+
data.tar.gz: 187f2ba5232c9f28e11812a1458e3ee24aea85019465c31ee851f1ec3ca06489
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 17fb7a95b7fc0d0259be2574be526d638de70cd5c25ffefcd22318c8a01b296537a544e249445594e4a32a65676b1d58eb8cb367f46a613084961671698ca994
|
7
|
+
data.tar.gz: f930948d7983e1dbced9d35379b3fff71e8145966bad9c63829494bb9f8850d3c4514de345536f852f4f622f11bd64e074b0dce2aa1b2b2b56c3a0e28085a2a2
|
data/.rubocop.yml
CHANGED
@@ -90,10 +90,15 @@ Lint/AmbiguousBlockAssociation:
|
|
90
90
|
|
91
91
|
Style/AccessorGrouping:
|
92
92
|
Enabled: false
|
93
|
+
|
93
94
|
Metrics/AbcSize:
|
94
95
|
Exclude:
|
95
96
|
- "lib/ad/agent_architecture/**/*"
|
96
97
|
|
98
|
+
Metrics/PerceivedComplexity:
|
99
|
+
Exclude:
|
100
|
+
- "lib/ad/agent_architecture/dsl/actions/save_database.rb"
|
101
|
+
|
97
102
|
Layout/SpaceBeforeComma:
|
98
103
|
Enabled: false
|
99
104
|
# My Preferences - End
|
@@ -125,3 +130,5 @@ RSpec/MultipleMemoizedHelpers:
|
|
125
130
|
Metrics/CyclomaticComplexity:
|
126
131
|
Exclude:
|
127
132
|
- "lib/ad/agent_architecture/dsl/actions/save_database.rb"
|
133
|
+
|
134
|
+
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
## [0.0.12](https://github.com/appydave/ad-agent_architecture/compare/v0.0.11...v0.0.12) (2024-07-02)
|
2
|
+
|
3
|
+
|
4
|
+
### Bug Fixes
|
5
|
+
|
6
|
+
* refactor DSL and Child DSL components, add support for prompt loading ([f260260](https://github.com/appydave/ad-agent_architecture/commit/f260260ea416d0c9d3a39dc1dd7fd0b66d145a80))
|
7
|
+
|
1
8
|
## [0.0.11](https://github.com/appydave/ad-agent_architecture/compare/v0.0.10...v0.0.11) (2024-06-29)
|
2
9
|
|
3
10
|
|
data/Gemfile
CHANGED
data/Guardfile
CHANGED
@@ -27,10 +27,4 @@ group :green_pass_then_cop, halt_on_fail: true do
|
|
27
27
|
watch(/{.+\.rb$/)
|
28
28
|
watch(%r{(?:.+/)?\.rubocop(?:_todo)?\.yml$}) { |m| File.dirname(m[0]) }
|
29
29
|
end
|
30
|
-
|
31
|
-
# guard :shell do
|
32
|
-
# watch(%r{^spec/usecases/.+\.rbx$}) do |m|
|
33
|
-
# `ruby -r ./spec/usecases/dsl_initialize.rb #{m[0]}`
|
34
|
-
# end
|
35
|
-
# end
|
36
30
|
end
|
data/bin/watch.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
puts 'Watch Agent Workflow DSLs'
|
5
|
+
|
6
|
+
require 'pry'
|
7
|
+
require 'listen'
|
8
|
+
|
9
|
+
$LOAD_PATH.unshift(File.expand_path('../lib', __dir__))
|
10
|
+
|
11
|
+
require 'ad/agent_architecture'
|
12
|
+
|
13
|
+
directory_to_watch = File.expand_path('../spec/usecases', __dir__)
|
14
|
+
|
15
|
+
callback = proc do |modified, added, _removed|
|
16
|
+
(modified + added).each do |file|
|
17
|
+
if file.match(%r{spec/usecases/.+\.rbx$})
|
18
|
+
# puts "Detected change in #{file}, running command..."
|
19
|
+
load file
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
listener = Listen.to(directory_to_watch, &callback)
|
25
|
+
listener.start
|
26
|
+
|
27
|
+
puts "Listening for changes in #{directory_to_watch}..."
|
28
|
+
|
29
|
+
sleep
|
@@ -11,12 +11,15 @@ module Ad
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def save
|
14
|
+
# puts JSON.pretty_generate(@workflow_hash)
|
14
15
|
DB.transaction do
|
16
|
+
# puts "Saving Workflow: #{@workflow_hash[:name]}"
|
15
17
|
# Save workflow
|
16
18
|
workflow_record = Ad::AgentArchitecture::Database::Workflow.create(name: @workflow_hash[:name])
|
17
19
|
|
18
|
-
#
|
20
|
+
# Saving attributes
|
19
21
|
attribute_records = @workflow_hash[:attributes].map do |_name, attr|
|
22
|
+
# puts "Saving Attribute: #{attr}"
|
20
23
|
Ad::AgentArchitecture::Database::Attribute.create(
|
21
24
|
name: attr[:name], type: attr[:type], is_array: attr[:is_array], workflow: workflow_record
|
22
25
|
)
|
@@ -26,6 +29,7 @@ module Ad
|
|
26
29
|
|
27
30
|
# Save prompts
|
28
31
|
@workflow_hash[:prompts].each_value do |prompt|
|
32
|
+
# puts "Saving Prompt: #{prompt}"
|
29
33
|
Ad::AgentArchitecture::Database::Prompt.create(
|
30
34
|
name: prompt[:name], path: prompt[:path], content: prompt[:content], workflow: workflow_record
|
31
35
|
)
|
@@ -33,22 +37,26 @@ module Ad
|
|
33
37
|
|
34
38
|
# Save sections and steps
|
35
39
|
@workflow_hash[:sections].each do |section|
|
40
|
+
# puts "Saving Section: #{section}"
|
36
41
|
section_record = Ad::AgentArchitecture::Database::Section.create(
|
37
42
|
name: section[:name], order: section[:order], workflow: workflow_record
|
38
43
|
)
|
39
44
|
|
40
45
|
section[:steps].each do |step|
|
46
|
+
# puts "Saving Step: #{step}"
|
41
47
|
step_record = Ad::AgentArchitecture::Database::Step.create(
|
42
48
|
name: step[:name], order: step[:order], prompt: step[:prompt], section: section_record
|
43
49
|
)
|
44
50
|
|
45
51
|
step[:input_attributes].each do |attr_name|
|
52
|
+
# puts "Saving Input Attribute for Step: #{attr_name}"
|
46
53
|
Ad::AgentArchitecture::Database::InputAttribute.create(
|
47
54
|
step: step_record, attribute: attribute_map[attr_name.to_sym]
|
48
55
|
)
|
49
56
|
end
|
50
57
|
|
51
58
|
step[:output_attributes].each do |attr_name|
|
59
|
+
# puts "Saving Output Attribute for Step: #{attr_name}"
|
52
60
|
Ad::AgentArchitecture::Database::OutputAttribute.create(
|
53
61
|
step: step_record, attribute: attribute_map[attr_name.to_sym]
|
54
62
|
)
|
@@ -56,6 +64,9 @@ module Ad
|
|
56
64
|
end
|
57
65
|
end
|
58
66
|
end
|
67
|
+
rescue StandardError => e
|
68
|
+
puts "An error occurred: #{e.message}"
|
69
|
+
raise
|
59
70
|
end
|
60
71
|
end
|
61
72
|
end
|
@@ -7,13 +7,15 @@ module Ad
|
|
7
7
|
class AgentDsl
|
8
8
|
attr_reader :workflow
|
9
9
|
|
10
|
-
def self.create(name
|
10
|
+
def self.create(name, &block)
|
11
11
|
new(name).tap do |dsl|
|
12
12
|
dsl.instance_eval(&block) if block_given?
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
16
|
def initialize(name)
|
17
|
+
raise ArgumentError, 'Agent name must be a string or symbol' unless name.is_a?(String) || name.is_a?(Symbol)
|
18
|
+
|
17
19
|
@workflow = WorkflowDsl.new(name)
|
18
20
|
end
|
19
21
|
|
@@ -30,6 +32,8 @@ module Ad
|
|
30
32
|
end
|
31
33
|
|
32
34
|
def section(name, &block)
|
35
|
+
raise ArgumentError, 'Section name must be a string or symbol' unless name.is_a?(String) || name.is_a?(Symbol)
|
36
|
+
|
33
37
|
@workflow.section(name, &block)
|
34
38
|
end
|
35
39
|
|
@@ -6,6 +6,8 @@ module Ad
|
|
6
6
|
# This class is responsible for defining the attributes of a workflow
|
7
7
|
class AttributeDsl < ChildDsl
|
8
8
|
def attribute(name, type:, is_array: false)
|
9
|
+
raise ArgumentError, 'Attribute name must be a string or symbol' unless name.is_a?(String) || name.is_a?(Symbol)
|
10
|
+
|
9
11
|
workflow[:attributes][name] = { name: name, type: type, is_array: is_array }
|
10
12
|
end
|
11
13
|
end
|
@@ -6,12 +6,14 @@ module Ad
|
|
6
6
|
# This class is responsible for defining the prompts of a workflow
|
7
7
|
class PromptDsl < ChildDsl
|
8
8
|
def prompt(name, path: nil, content: nil)
|
9
|
+
raise ArgumentError, 'Prompt name must be a string or symbol' unless name.is_a?(String) || name.is_a?(Symbol)
|
10
|
+
|
9
11
|
workflow[:prompts][name] = { name: name, content: content }
|
10
12
|
end
|
11
13
|
|
12
14
|
def prompt_file(file)
|
13
15
|
prompt_path = workflow[:settings][:prompt_path]
|
14
|
-
raise 'Prompt path not defined in settings' unless prompt_path
|
16
|
+
raise 'Prompt path not defined in settings. Set "prompt_path" to the path where you are keping prompts' unless prompt_path
|
15
17
|
|
16
18
|
full_path = File.join(prompt_path, file)
|
17
19
|
File.read(full_path)
|
@@ -13,7 +13,9 @@ module Ad
|
|
13
13
|
@current_step_order = 1
|
14
14
|
end
|
15
15
|
|
16
|
-
def step(name
|
16
|
+
def step(name, &block)
|
17
|
+
raise ArgumentError, 'Step name must be a string or symbol' unless name.is_a?(String) || name.is_a?(Symbol)
|
18
|
+
|
17
19
|
StepDsl.new(workflow, @section, name, @current_step_order).instance_eval(&block)
|
18
20
|
@current_step_order += 1
|
19
21
|
end
|
@@ -4,8 +4,12 @@ module Ad
|
|
4
4
|
module AgentArchitecture
|
5
5
|
module Dsl
|
6
6
|
# This class is responsible for defining the steps of a section
|
7
|
-
class StepDsl
|
8
|
-
|
7
|
+
class StepDsl < ChildDsl
|
8
|
+
attr_reader :section
|
9
|
+
attr_reader :step
|
10
|
+
|
11
|
+
def initialize(workflow, section, name, order)
|
12
|
+
super(workflow)
|
9
13
|
@step = {
|
10
14
|
name: name,
|
11
15
|
order: order,
|
@@ -14,7 +18,8 @@ module Ad
|
|
14
18
|
output_attributes: []
|
15
19
|
}
|
16
20
|
|
17
|
-
section
|
21
|
+
@section = section
|
22
|
+
@section[:steps] << @step
|
18
23
|
end
|
19
24
|
|
20
25
|
def input(attr_name, **_opts)
|
data/package-lock.json
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
{
|
2
2
|
"name": "ad-agent_architecture",
|
3
|
-
"version": "0.0.
|
3
|
+
"version": "0.0.13",
|
4
4
|
"lockfileVersion": 3,
|
5
5
|
"requires": true,
|
6
6
|
"packages": {
|
7
7
|
"": {
|
8
8
|
"name": "ad-agent_architecture",
|
9
|
-
"version": "0.0.
|
9
|
+
"version": "0.0.13",
|
10
10
|
"devDependencies": {
|
11
11
|
"@klueless-js/semantic-release-rubygem": "github:klueless-js/semantic-release-rubygem",
|
12
12
|
"@semantic-release/changelog": "^6.0.3",
|
data/package.json
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ad-agent_architecture
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Cruwys
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-07-
|
11
|
+
date: 2024-07-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: k_log
|
@@ -75,6 +75,7 @@ files:
|
|
75
75
|
- Rakefile
|
76
76
|
- bin/console
|
77
77
|
- bin/setup
|
78
|
+
- bin/watch.rb
|
78
79
|
- docs/erd.svg
|
79
80
|
- docs/images/sample-workflow.png
|
80
81
|
- docs/requirements.md
|
@@ -87,7 +88,6 @@ files:
|
|
87
88
|
- lib/ad/agent_architecture/dsl/actions/save_json.rb
|
88
89
|
- lib/ad/agent_architecture/dsl/actions/save_yaml.rb
|
89
90
|
- lib/ad/agent_architecture/dsl/agent_dsl.rb
|
90
|
-
- lib/ad/agent_architecture/dsl/agent_workflow_dsl.rb.old
|
91
91
|
- lib/ad/agent_architecture/dsl/attribute_dsl.rb
|
92
92
|
- lib/ad/agent_architecture/dsl/child_dsl.rb
|
93
93
|
- lib/ad/agent_architecture/dsl/prompt_dsl.rb
|
@@ -1,84 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Ad
|
4
|
-
module AgentArchitecture
|
5
|
-
module Dsl
|
6
|
-
# DSL for defining agent workflows
|
7
|
-
class AgentWorkflowDsl
|
8
|
-
def self.create(name:, &block)
|
9
|
-
new(name).tap do |dsl|
|
10
|
-
dsl.instance_eval(&block) if block_given?
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
def initialize(name)
|
15
|
-
@workflow = { name: name, sections: [], attributes: {}, prompts: [] }
|
16
|
-
@current_section_order = 1
|
17
|
-
end
|
18
|
-
|
19
|
-
def attributes(&block)
|
20
|
-
instance_eval(&block) if block_given?
|
21
|
-
end
|
22
|
-
|
23
|
-
def attribute(name, type:, is_array: false)
|
24
|
-
@workflow[:attributes][name] = { name: name, type: type, is_array: is_array }
|
25
|
-
end
|
26
|
-
|
27
|
-
def prompts(&block)
|
28
|
-
instance_eval(&block) if block_given?
|
29
|
-
end
|
30
|
-
|
31
|
-
def define_prompt(name, path: nil, content: nil)
|
32
|
-
@workflow[:prompts] << { name: name, path: path, content: content }
|
33
|
-
end
|
34
|
-
|
35
|
-
def section(name:, &block)
|
36
|
-
@current_step_order = 1
|
37
|
-
@current_section = { name: name, order: @current_section_order, steps: [] }
|
38
|
-
@current_section_order += 1
|
39
|
-
instance_eval(&block) if block_given?
|
40
|
-
@workflow[:sections] << @current_section
|
41
|
-
end
|
42
|
-
|
43
|
-
def step(name:, &block)
|
44
|
-
@current_step = { name: name, order: @current_step_order, input_attributes: [], output_attributes: [] }
|
45
|
-
@current_step_order += 1
|
46
|
-
instance_eval(&block) if block_given?
|
47
|
-
@current_section[:steps] << @current_step
|
48
|
-
end
|
49
|
-
|
50
|
-
def input(attr_name, **_opts)
|
51
|
-
@current_step[:input_attributes] << attr_name
|
52
|
-
end
|
53
|
-
|
54
|
-
def output(attr_name, **_opts)
|
55
|
-
@current_step[:output_attributes] << attr_name
|
56
|
-
end
|
57
|
-
|
58
|
-
def prompt(prompt_text, **_opts)
|
59
|
-
@current_step[:prompt] = prompt_text
|
60
|
-
end
|
61
|
-
|
62
|
-
def save
|
63
|
-
Ad::AgentArchitecture::Dsl::Actions::SaveDatabase.new(@workflow).save
|
64
|
-
|
65
|
-
self
|
66
|
-
end
|
67
|
-
|
68
|
-
def save_json(file_name: nil)
|
69
|
-
full_file_name = file_name || 'workflow.json'
|
70
|
-
Ad::AgentArchitecture::Dsl::Actions::SaveJson.new(@workflow).save(full_file_name)
|
71
|
-
|
72
|
-
self
|
73
|
-
end
|
74
|
-
|
75
|
-
def save_yaml(file_name: nil)
|
76
|
-
full_file_name = file_name || 'workflow.yaml'
|
77
|
-
Ad::AgentArchitecture::Dsl::Actions::SaveYaml.new(@workflow).save(full_file_name)
|
78
|
-
|
79
|
-
self
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|