gitlab-cloud-connector 1.0.0 → 1.2.0

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: 17fe80dc098578ea54c50cf02e06e83bb516a4b18d6fbb649d9fd7d593e853c8
4
- data.tar.gz: 89cbb45796d3eaa078a36e084b872f7b820f6fbf85fb745490cb164c52a66447
3
+ metadata.gz: '08c7db0c9954f05f5d443707897e0b65510833196d84fe0232b8ea683dbe54e4'
4
+ data.tar.gz: 2fab7c9d5729454622896fe48211341e993e27a1e924921de2358c9b38cccb8c
5
5
  SHA512:
6
- metadata.gz: 52f2b3ac0efb7d0aff0a360bf2272cdaf3151a8b912ce3d60503ac0cb2297f72809e879254751afeec188d7976c80b94f5f1fcd318792559f3460a7f32de8331
7
- data.tar.gz: a4f104be9c1c99486d2b44a5183aba2c71d2f398cb4454557e27684e2669ac7c95394c6abe4321fb3f2e928ed59617a917886431fdf87c1e136255270bef8fa5
6
+ metadata.gz: bb6be93bbb1f0bd7e3808832618fc2f1532b06ab3cbab62cf9a05eac234f3ff0b2b0ac4dddeb2d5b57e5c7337d8d80d36167817bf418c0d0fbb3cb29c88b531f
7
+ data.tar.gz: e32d689a3358fd29e8fd7431f9a815b9fd9adb8056e102d1f8efd4918cd907f00a8e3ca0f84cbc89691c0903f27cbc9d1c272b4c96a9d68511ca560a37fe418c
data/README.md CHANGED
@@ -10,8 +10,6 @@ We expect Bundler is used to manage dependencies. To add the dependency, add it
10
10
  gem "gitlab-cloud-connector", "~> 1.0.0", require: 'gitlab/cloud_connector'
11
11
  ```
12
12
 
13
- ## Usage
14
-
15
13
  ### Data Storage
16
14
 
17
15
  Cloud Connector uses YAML files stored in the project's `/config` directory. The data is organized by model type:
@@ -10,3 +10,4 @@ unit_primitives:
10
10
  - summarize_issue_discussions
11
11
  - summarize_new_merge_request
12
12
  - summarize_review
13
+ - description_composer
@@ -10,7 +10,6 @@ unit_primitives:
10
10
  - documentation_search
11
11
  - duo_chat
12
12
  - explain_code
13
- - explain_terminal
14
13
  - fix_code
15
14
  - include_dependency_context
16
15
  - include_file_context
@@ -18,5 +17,6 @@ unit_primitives:
18
17
  - include_local_git_context
19
18
  - include_merge_request_context
20
19
  - include_snippet_context
20
+ - include_terminal_context
21
21
  - refactor_code
22
- - write_tests
22
+ - write_tests
@@ -20,5 +20,6 @@ unit_primitives:
20
20
  - include_local_git_context
21
21
  - include_merge_request_context
22
22
  - include_snippet_context
23
+ - include_terminal_context
23
24
  - refactor_code
24
25
  - write_tests
@@ -6,4 +6,3 @@ unit_primitives:
6
6
  - glab_ask_git_command
7
7
  - semantic_search_issue
8
8
  - summarize_issue_discussions
9
- - summarize_merge_request
@@ -0,0 +1,11 @@
1
+ ---
2
+ name: description_composer
3
+ description: Composes a description for a merge request.
4
+ cut_off_date: 2024-10-17T00:00:00+00:00
5
+ group: group::code review
6
+ feature_category: code_review_workflow
7
+ introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/183512
8
+ backend_services:
9
+ - ai_gateway
10
+ add_ons:
11
+ - duo_enterprise
@@ -1,6 +1,6 @@
1
1
  ---
2
- name: explain_terminal
3
- description: Explain terminal or command line interface output.
2
+ name: include_terminal_context
3
+ description: Include terminal context in the prompt.
4
4
  cut_off_date: 2024-10-17T00:00:00+00:00
5
5
  group: group::duo_chat
6
6
  feature_category: duo_chat
@@ -28,7 +28,6 @@ module Gitlab
28
28
  security_scans
29
29
  semantic_search_issue
30
30
  summarize_issue_discussions
31
- summarize_merge_request
32
31
  write_tests
33
32
  ].freeze
34
33
 
@@ -1,21 +1,48 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative 'data_model/yaml_data_loader'
4
+ require_relative 'data_model/abstract_data_loader'
5
+
3
6
  module Gitlab
4
7
  module CloudConnector
5
8
  module Configuration
9
+ DEFAULT_DATA_LOADER_CLASS = Gitlab::CloudConnector::DataModel::YamlDataLoader
10
+ INVALID_LOADER_MESSAGE = "Data loader must inherit from Gitlab::CloudConnector::DataModel::AbstractDataLoader"
11
+
12
+ InvalidDataLoaderError = Class.new(StandardError)
13
+
6
14
  class << self
7
- attr_writer :config_dir
15
+ attr_writer :config_dir, :memoize_data
8
16
 
9
17
  def config_dir
10
18
  @config_dir ||= File.expand_path("../../../config", __dir__).freeze
11
19
  end
12
20
 
21
+ def data_loader_class
22
+ @data_loader_class ||= DEFAULT_DATA_LOADER_CLASS
23
+ end
24
+
25
+ def data_loader_class=(klass)
26
+ validate_data_loader!(klass)
27
+ @data_loader_class = klass
28
+ end
29
+
30
+ def memoize_data?
31
+ return @memoize_data unless @memoize_data.nil?
32
+
33
+ (data_loader_class == DEFAULT_DATA_LOADER_CLASS)
34
+ end
35
+
13
36
  def configure
14
37
  yield self if block_given?
15
38
  end
16
39
 
17
- def reset!
18
- @config_dir = nil
40
+ private
41
+
42
+ def validate_data_loader!(klass)
43
+ return if klass && klass < Gitlab::CloudConnector::DataModel::AbstractDataLoader
44
+
45
+ raise InvalidDataLoaderError, INVALID_LOADER_MESSAGE
19
46
  end
20
47
  end
21
48
  end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Gitlab
4
+ module CloudConnector
5
+ module DataModel
6
+ class AbstractDataLoader
7
+ def initialize(model_class)
8
+ @model_class = model_class
9
+ end
10
+
11
+ def load!
12
+ raise NotImplementedError, "#{self.class} must implement #load!"
13
+ end
14
+
15
+ protected
16
+
17
+ attr_reader :model_class
18
+ end
19
+ end
20
+ end
21
+ end
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative 'associations'
4
- require_relative 'data_loader'
5
4
 
6
5
  module Gitlab
7
6
  module CloudConnector
@@ -24,13 +23,17 @@ module Gitlab
24
23
  end
25
24
 
26
25
  def all
27
- @all ||= data_loader.load!
26
+ if Configuration.memoize_data?
27
+ @all ||= data_loader.load!
28
+ else
29
+ data_loader.load!
30
+ end
28
31
  end
29
32
 
30
33
  private
31
34
 
32
35
  def data_loader
33
- @data_loader ||= DataLoader.new(self)
36
+ Configuration.data_loader_class.new(self)
34
37
  end
35
38
  end
36
39
 
@@ -43,6 +46,13 @@ module Gitlab
43
46
  def [](name)
44
47
  instance_variable_get(:"@#{name}")
45
48
  end
49
+
50
+ def to_hash
51
+ instance_variables.each_with_object({}) do |var, hash|
52
+ key = var.to_s.delete('@').to_sym
53
+ hash[key] = instance_variable_get(var)
54
+ end
55
+ end
46
56
  end
47
57
  end
48
58
  end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'yaml'
4
+ require_relative 'abstract_data_loader'
5
+
6
+ module Gitlab
7
+ module CloudConnector
8
+ module DataModel
9
+ class YamlDataLoader < AbstractDataLoader
10
+ def load!
11
+ Dir.glob(data_files_path).map { |file| load_model_from_file(file) }
12
+ end
13
+
14
+ private
15
+
16
+ def data_files_path
17
+ File.join(CloudConnector::Configuration.config_dir, model_class.model_name.tableize, '*.yml')
18
+ end
19
+
20
+ def load_model_from_file(file_path)
21
+ data = YAML.safe_load(
22
+ File.read(file_path),
23
+ permitted_classes: [Time],
24
+ symbolize_names: true
25
+ ).deep_symbolize_keys!
26
+
27
+ model_class.new(**data)
28
+ rescue StandardError => e
29
+ raise "Error loading file #{file_path}: #{e.message}"
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Gitlab
4
4
  module CloudConnector
5
- VERSION = '1.0.0'
5
+ VERSION = '1.2.0'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gitlab-cloud-connector
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nikola Milojevic
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-01-20 00:00:00.000000000 Z
11
+ date: 2025-03-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -128,11 +128,11 @@ files:
128
128
  - config/unit_primitives/categorize_duo_chat_question.yml
129
129
  - config/unit_primitives/code_suggestions.yml
130
130
  - config/unit_primitives/complete_code.yml
131
+ - config/unit_primitives/description_composer.yml
131
132
  - config/unit_primitives/documentation_search.yml
132
133
  - config/unit_primitives/duo_chat.yml
133
134
  - config/unit_primitives/duo_workflow_execute_workflow.yml
134
135
  - config/unit_primitives/explain_code.yml
135
- - config/unit_primitives/explain_terminal.yml
136
136
  - config/unit_primitives/explain_vulnerability.yml
137
137
  - config/unit_primitives/fix_code.yml
138
138
  - config/unit_primitives/generate_code.yml
@@ -146,6 +146,7 @@ files:
146
146
  - config/unit_primitives/include_local_git_context.yml
147
147
  - config/unit_primitives/include_merge_request_context.yml
148
148
  - config/unit_primitives/include_snippet_context.yml
149
+ - config/unit_primitives/include_terminal_context.yml
149
150
  - config/unit_primitives/measure_comment_temperature.yml
150
151
  - config/unit_primitives/observability_all.yml
151
152
  - config/unit_primitives/refactor_code.yml
@@ -155,7 +156,6 @@ files:
155
156
  - config/unit_primitives/semantic_search_issue.yml
156
157
  - config/unit_primitives/summarize_comments.yml
157
158
  - config/unit_primitives/summarize_issue_discussions.yml
158
- - config/unit_primitives/summarize_merge_request.yml
159
159
  - config/unit_primitives/summarize_new_merge_request.yml
160
160
  - config/unit_primitives/summarize_review.yml
161
161
  - config/unit_primitives/troubleshoot_job.yml
@@ -163,9 +163,11 @@ files:
163
163
  - lib/gitlab/cloud_connector.rb
164
164
  - lib/gitlab/cloud_connector/available_services_generator.rb
165
165
  - lib/gitlab/cloud_connector/configuration.rb
166
+ - lib/gitlab/cloud_connector/data_model/abstract_data_loader.rb
166
167
  - lib/gitlab/cloud_connector/data_model/associations.rb
167
168
  - lib/gitlab/cloud_connector/data_model/base.rb
168
169
  - lib/gitlab/cloud_connector/data_model/data_loader.rb
170
+ - lib/gitlab/cloud_connector/data_model/yaml_data_loader.rb
169
171
  - lib/gitlab/cloud_connector/data_models.rb
170
172
  - lib/gitlab/cloud_connector/json_web_token.rb
171
173
  - lib/gitlab/cloud_connector/version.rb
@@ -1,11 +0,0 @@
1
- ---
2
- name: summarize_merge_request
3
- description: Summarize merge request from the comments.
4
- cut_off_date: 2024-10-17T00:00:00+00:00
5
- group: group::code review
6
- feature_category: code_review_workflow
7
- documentation_url: https://docs.gitlab.com/ee/user/gitlab_duo/#merge-request-summary
8
- backend_services:
9
- - ai_gateway
10
- add_ons:
11
- - duo_enterprise