codalio_ai 0.0.2.beta.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +20 -0
- data/README.md +28 -0
- data/Rakefile +34 -0
- data/app/assets/config/codalio_ai_manifest.js +0 -0
- data/app/policies/dev_ai_policy.rb +11 -0
- data/app/resources/codalio_ai/dev_ai.rb +79 -0
- data/config/routes.rb +2 -0
- data/lib/codalio_ai/engine.rb +17 -0
- data/lib/codalio_ai/version.rb +15 -0
- data/lib/codalio_ai.rb +6 -0
- data/lib/tasks/codalio_ai_tasks.rake +4 -0
- metadata +102 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 7b9b37584585d47eaa3a8f04fb5e44c91542a68ce3f9de6a393fce552d7e0059
|
4
|
+
data.tar.gz: dd095c68d2abe06913f2946ce8919fa5ff31241f7a8924fe0fc418e3484cce1a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 926844ec22c82e9b51cb3dc4a753ea5ae4019e269b05e6966c8fdb3af84ad377bdb1de9d92b256b103a16fb20d0a4a464b0c377ba80d6f74b0af95e4e201e686
|
7
|
+
data.tar.gz: 78212f891e9e272ebac083227ff4c894d28bcfabe3f62a10dbbc36ecd0faa7f023629f089a85f36dd0646518dab0b8ae69ded81d57ca59ec26beba818285b29f
|
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2024 TODO: Write your name
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# CodalioAi
|
2
|
+
Short description and motivation.
|
3
|
+
|
4
|
+
## Usage
|
5
|
+
How to use my plugin.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
gem "codalio_ai"
|
12
|
+
```
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
```bash
|
16
|
+
$ bundle
|
17
|
+
```
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
```bash
|
21
|
+
$ gem install codalio_ai
|
22
|
+
```
|
23
|
+
|
24
|
+
## Contributing
|
25
|
+
Contribution directions go here.
|
26
|
+
|
27
|
+
## License
|
28
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rdoc/task'
|
8
|
+
|
9
|
+
task :package
|
10
|
+
|
11
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
12
|
+
rdoc.rdoc_dir = 'rdoc'
|
13
|
+
rdoc.title = 'CodalioAi'
|
14
|
+
rdoc.options << '--line-numbers'
|
15
|
+
rdoc.rdoc_files.include('README.md')
|
16
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
17
|
+
end
|
18
|
+
|
19
|
+
APP_RAKEFILE = File.expand_path("test/dummy/Rakefile", __dir__)
|
20
|
+
load 'rails/tasks/engine.rake'
|
21
|
+
|
22
|
+
load 'rails/tasks/statistics.rake'
|
23
|
+
|
24
|
+
require 'bundler/gem_tasks'
|
25
|
+
|
26
|
+
require 'rake/testtask'
|
27
|
+
|
28
|
+
Rake::TestTask.new do |t|
|
29
|
+
t.libs << "test"
|
30
|
+
t.test_files = FileList["test/**/*_test.rb"].exclude("test/system/**/*", "test/dummy/**/*")
|
31
|
+
t.verbose = true
|
32
|
+
end
|
33
|
+
|
34
|
+
task default: :test
|
File without changes
|
@@ -0,0 +1,79 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module CodalioAi
|
4
|
+
class DevAi
|
5
|
+
include Rhino::Resource
|
6
|
+
|
7
|
+
rhino_owner_global
|
8
|
+
|
9
|
+
rhino_routing only: %i[show create], singular: true, path: "dev/ai"
|
10
|
+
rhino_controller :simple
|
11
|
+
rhino_policy :dev_ai
|
12
|
+
|
13
|
+
def self.describe
|
14
|
+
nil
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.model_list
|
18
|
+
Rhino.resource_classes.index_with(&:describe).compact.transform_keys do |r|
|
19
|
+
r.model_name.singular
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.client_path
|
24
|
+
Rails.root.join("../client")
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.rhino_config_path
|
28
|
+
File.join(client_path, "src/rhino.config.js")
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.openapi_schema_get
|
32
|
+
puts "Getting openapi schema"
|
33
|
+
|
34
|
+
JSON.pretty_generate({ response: model_list, response2: File.read(rhino_config_path) })
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.rhino_config
|
38
|
+
File.read(rhino_config_path)
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.rhino_config_set(content:)
|
42
|
+
puts content
|
43
|
+
File.write(rhino_config_path, content)
|
44
|
+
|
45
|
+
{ response: "Updated rhino.config.js to #{content}" }
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.dev_ai_endpoint
|
49
|
+
ENV["CODALIO_ENDPOINT"] || "https://api.codalio.com"
|
50
|
+
end
|
51
|
+
|
52
|
+
def self.client
|
53
|
+
Faraday.new do |f|
|
54
|
+
f.response :logger
|
55
|
+
f.request :json # encode req bodies as JSON
|
56
|
+
f.response :json # decode response bodies as JSON
|
57
|
+
f.adapter :httpclient
|
58
|
+
f.headers["Authorization"] = ENV["CODALIO_API_KEY"]
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def self.show
|
63
|
+
{ enabled: ENV["CODALIO_API_KEY"].present? }
|
64
|
+
end
|
65
|
+
|
66
|
+
def self.create(params)
|
67
|
+
tool_data = params.permit(:content).to_h.merge({ model_list:, rhino_config: })
|
68
|
+
response = client.post("#{dev_ai_endpoint}/api/tool/ai", tool_data)
|
69
|
+
|
70
|
+
rhino_config_set(content: response.body["rhino_config_js"]) if response.success? && response.body["rhino_config_js"].present?
|
71
|
+
|
72
|
+
response.body
|
73
|
+
end
|
74
|
+
|
75
|
+
def self.model_name
|
76
|
+
ActiveModel::Name.new(self)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
data/config/routes.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require "rhino/engine"
|
2
|
+
require "codalio_ai/version"
|
3
|
+
module CodalioAi
|
4
|
+
class Engine < ::Rails::Engine
|
5
|
+
config.autoload_paths << File.expand_path("../../lib", __dir__)
|
6
|
+
|
7
|
+
initializer "codalio_ai.register_module" do
|
8
|
+
config.after_initialize do
|
9
|
+
Rhino.registered_modules[:codalio_ai] = {
|
10
|
+
version: CodalioAi::VERSION::STRING
|
11
|
+
}
|
12
|
+
|
13
|
+
Rhino.resources += ["CodalioAi::DevAi"] if Rails.env.development?
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module CodalioAi
|
2
|
+
# Returns the currently loaded version of CodalioAi core as a +Gem::Version+.
|
3
|
+
def self.gem_version
|
4
|
+
Gem::Version.new VERSION::STRING
|
5
|
+
end
|
6
|
+
|
7
|
+
module VERSION
|
8
|
+
MAJOR = 0
|
9
|
+
MINOR = 0
|
10
|
+
TINY = 2
|
11
|
+
PRE = "beta.1"
|
12
|
+
|
13
|
+
STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
|
14
|
+
end
|
15
|
+
end
|
data/lib/codalio_ai.rb
ADDED
metadata
ADDED
@@ -0,0 +1,102 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: codalio_ai
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2.beta.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- JP Rosevear
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2024-04-06 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 7.0.0
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 7.0.0
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 7.0.0
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 7.0.0
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: rhino_project_core
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: 0.20.0.beta.48
|
40
|
+
type: :runtime
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - "~>"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 0.20.0.beta.48
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: rake
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - "~>"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '13.1'
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - "~>"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '13.1'
|
61
|
+
description: ''
|
62
|
+
email:
|
63
|
+
- jprosevear@nubinary.com
|
64
|
+
executables: []
|
65
|
+
extensions: []
|
66
|
+
extra_rdoc_files: []
|
67
|
+
files:
|
68
|
+
- LICENSE
|
69
|
+
- README.md
|
70
|
+
- Rakefile
|
71
|
+
- app/assets/config/codalio_ai_manifest.js
|
72
|
+
- app/policies/dev_ai_policy.rb
|
73
|
+
- app/resources/codalio_ai/dev_ai.rb
|
74
|
+
- config/routes.rb
|
75
|
+
- lib/codalio_ai.rb
|
76
|
+
- lib/codalio_ai/engine.rb
|
77
|
+
- lib/codalio_ai/version.rb
|
78
|
+
- lib/tasks/codalio_ai_tasks.rake
|
79
|
+
homepage: ''
|
80
|
+
licenses:
|
81
|
+
- MIT
|
82
|
+
metadata: {}
|
83
|
+
post_install_message:
|
84
|
+
rdoc_options: []
|
85
|
+
require_paths:
|
86
|
+
- lib
|
87
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - ">="
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
92
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 1.3.1
|
97
|
+
requirements: []
|
98
|
+
rubygems_version: 3.3.26
|
99
|
+
signing_key:
|
100
|
+
specification_version: 4
|
101
|
+
summary: ''
|
102
|
+
test_files: []
|