sublayer 0.2.6 → 0.2.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/.contextignore +15 -0
- data/lib/sublayer/cli/commands/action.rb +4 -0
- data/lib/sublayer/cli/commands/agent.rb +4 -0
- data/lib/sublayer/cli/commands/cli_project.rb +79 -0
- data/lib/sublayer/cli/commands/generator.rb +53 -0
- data/lib/sublayer/cli/commands/generators/sublayer_command_generator.rb +55 -0
- data/lib/sublayer/cli/commands/github_action_project.rb +70 -0
- data/lib/sublayer/cli/commands/new_project.rb +14 -89
- data/lib/sublayer/cli/commands/quick_script_project.rb +79 -0
- data/lib/sublayer/cli/templates/cli/log/.keep +0 -0
- data/lib/sublayer/cli/templates/github_action/%project_name%/%project_name%.rb.tt +15 -0
- data/lib/sublayer/cli/templates/github_action/%project_name%/actions/.keep +0 -0
- data/lib/sublayer/cli/templates/github_action/%project_name%/agents/.keep +0 -0
- data/lib/sublayer/cli/templates/github_action/%project_name%/generators/.keep +0 -0
- data/lib/sublayer/cli/templates/github_action/%project_name%.yml.tt +30 -0
- data/lib/sublayer/cli/templates/utilities/cli/command.rb.tt +13 -0
- data/lib/sublayer/cli.rb +3 -0
- data/lib/sublayer/version.rb +1 -1
- metadata +15 -3
- /data/lib/sublayer/cli/templates/cli/{.gitignore → .gitignore.tt} +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f77385d9cac0cf15242c515933970b20181968c2aa63dbb23d1c9e748aef9833
|
4
|
+
data.tar.gz: bd6c59571e7a08d4ea21095a463b23c514e1608374abafc8726fb4b42cfb572f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c850ef7ebe6f33dae8335f0df0ff5a0c7d849b57d4964bdae40991718cda449667006107717131445bf763337b70c533e109d3d006bed583d4c804ec864ee638
|
7
|
+
data.tar.gz: b620565446a6cc96ed843e1a98d850dfca5a519fb95f3b797ea2cf94ba67ef3af1675eb590dc3a373332ab8bd79a74fefd51d7adca615be6313567d348f1ad97
|
data/.contextignore
ADDED
@@ -9,6 +9,10 @@ module Sublayer
|
|
9
9
|
class_option :provider, type: :string, desc: "AI provider (OpenAI, Claude, or Gemini)", aliases: :p
|
10
10
|
class_option :model, type: :string, desc: "AI model name to use (e.g. gpt-4o, claude-3-haiku-20240307, gemini-1.5-flash-latest)", aliases: :m
|
11
11
|
|
12
|
+
def self.banner
|
13
|
+
"sublayer generate:action"
|
14
|
+
end
|
15
|
+
|
12
16
|
def confirm_usage_of_ai_api
|
13
17
|
puts "You are about to generate a new agent that uses an AI API to generate content."
|
14
18
|
puts "Please ensure you have the necessary API keys and that you are aware of the costs associated with using the API."
|
@@ -9,6 +9,10 @@ module Sublayer
|
|
9
9
|
class_option :provider, type: :string, desc: "AI provider (OpenAI, Claude, or Gemini)", aliases: :p
|
10
10
|
class_option :model, type: :string, desc: "AI model name to use (e.g. gpt-4o, claude-3-haiku-20240307, gemini-1.5-flash-latest)", aliases: :m
|
11
11
|
|
12
|
+
def self.banner
|
13
|
+
"sublayer generate:agent"
|
14
|
+
end
|
15
|
+
|
12
16
|
def confirm_usage_of_ai_api
|
13
17
|
puts "You are about to generate a new agent that uses an AI API to generate content."
|
14
18
|
puts "Please ensure you have the necessary API keys and that you are aware of the costs associated with using the API."
|
@@ -0,0 +1,79 @@
|
|
1
|
+
module Sublayer
|
2
|
+
module Commands
|
3
|
+
class CLIProject < Thor::Group
|
4
|
+
include Thor::Actions
|
5
|
+
|
6
|
+
argument :project_name
|
7
|
+
|
8
|
+
class_option :provider, type: :string, desc: "AI provider (OpenAI, Claude, or Gemini)", aliases: :p
|
9
|
+
class_option :model, type: :string, desc: "AI model name to use (e.g. gpt-4o, claude-3-haiku-20240307, gemini-1.5-flash-latest)", aliases: :m
|
10
|
+
|
11
|
+
def self.source_root
|
12
|
+
File.dirname(__FILE__)
|
13
|
+
end
|
14
|
+
|
15
|
+
def sublayer_version
|
16
|
+
Sublayer::VERSION
|
17
|
+
end
|
18
|
+
|
19
|
+
def ask_for_project_details
|
20
|
+
@ai_provider = options[:provider] || ask("Select an AI provider:", default: "OpenAI", limited_to: %w[OpenAI Claude Gemini])
|
21
|
+
@ai_model = options[:model] || select_ai_model
|
22
|
+
end
|
23
|
+
|
24
|
+
def create_project_directory
|
25
|
+
say "Creating project directory", :green
|
26
|
+
|
27
|
+
empty_directory project_name
|
28
|
+
end
|
29
|
+
|
30
|
+
def copy_template_files
|
31
|
+
say "Copying template files", :green
|
32
|
+
|
33
|
+
directory "../templates/cli", project_name
|
34
|
+
end
|
35
|
+
|
36
|
+
def generate_configuration
|
37
|
+
say "Generating configuration", :green
|
38
|
+
|
39
|
+
config = {
|
40
|
+
project_name: @project_name,
|
41
|
+
project_template: "CLI",
|
42
|
+
ai_provider: @provider,
|
43
|
+
ai_model: @model
|
44
|
+
}
|
45
|
+
|
46
|
+
create_file File.join(project_name, "lib", project_name, "config", "sublayer.yml"), YAML.dump(config)
|
47
|
+
end
|
48
|
+
|
49
|
+
def finalize_project
|
50
|
+
say "Finalizing project", :green
|
51
|
+
|
52
|
+
inside(project_name) do
|
53
|
+
chmod("bin/#{project_name}", "+x")
|
54
|
+
run("git init") if yes?("Initialize a git repository?")
|
55
|
+
run("bundle install") if yes?("Install gems?")
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def print_next_steps
|
60
|
+
say "\nSublayer project '#{project_name}' created successfully!", :green
|
61
|
+
say "To get started, run:"
|
62
|
+
say " cd #{project_name}"
|
63
|
+
say " ./bin/#{project_name}"
|
64
|
+
end
|
65
|
+
|
66
|
+
private
|
67
|
+
def select_ai_model
|
68
|
+
case @ai_provider
|
69
|
+
when "OpenAI"
|
70
|
+
ask("Which OpenAI model would you like to use?", default: "gpt-4o", limited_to: %w[gpt-4o gpt-4o-mini gpt-4-turbo gpt-3.5-turbo])
|
71
|
+
when "Claude"
|
72
|
+
ask("Which Anthropic model would you like to use?", default: "claude-3-5-sonnet-20240620", limited_to: %w[claude-3-5-sonnet-20240620 claude-3-opus-20240620 claude-3-haiku-20240307])
|
73
|
+
when "Gemini"
|
74
|
+
ask("Which Google model would you like to use?", default: "gemini-1.5-flash-latest", limited_to: %w[gemini-1.5-flash-latest gemini-1.5-pro-latest])
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require_relative "generators/sublayer_generator_generator"
|
2
|
+
require_relative "generators/sublayer_command_generator"
|
2
3
|
|
3
4
|
module Sublayer
|
4
5
|
module Commands
|
@@ -8,6 +9,15 @@ module Sublayer
|
|
8
9
|
class_option :description, type: :string, desc: "Description of the generator you want to generate", aliases: :d
|
9
10
|
class_option :provider, type: :string, desc: "AI provider (OpenAI, Claude, or Gemini)", aliases: :p
|
10
11
|
class_option :model, type: :string, desc: "AI model name to use (e.g. gpt-4o, claude-3-haiku-20240307, gemini-1.5-flash-latest)", aliases: :m
|
12
|
+
class_option :generate_command, type: :boolean, desc: "Generate a command for the new generator", aliases: :c
|
13
|
+
|
14
|
+
def self.banner
|
15
|
+
"sublayer generate:generator"
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.source_root
|
19
|
+
File.expand_path("../../templates", __FILE__)
|
20
|
+
end
|
11
21
|
|
12
22
|
def confirm_usage_of_ai_api
|
13
23
|
puts "You are about to generate a new generator that uses an AI API to generate content."
|
@@ -27,6 +37,10 @@ module Sublayer
|
|
27
37
|
@description = options[:description] || ask("Enter a description for the Sublayer Generator you'd like to create:")
|
28
38
|
@ai_provider = options[:provider] || ask("Select an AI provider:", default: "OpenAI", limited_to: @available_providers)
|
29
39
|
@ai_model = options[:model] || select_ai_model
|
40
|
+
|
41
|
+
if is_cli_project? && options[:generate_command].nil?
|
42
|
+
@generate_command = yes?("Would you like to create a corresponding CLI command for this generator?")
|
43
|
+
end
|
30
44
|
end
|
31
45
|
|
32
46
|
def generate_generator
|
@@ -52,7 +66,46 @@ module Sublayer
|
|
52
66
|
create_file File.join(@destination_folder, @results.filename), @results.code
|
53
67
|
end
|
54
68
|
|
69
|
+
def generate_command_if_requested
|
70
|
+
return unless @generate_command
|
71
|
+
|
72
|
+
say "Generating command..."
|
73
|
+
|
74
|
+
generator_code = File.read(File.join(@destination_folder, @results.filename))
|
75
|
+
command_results = SublayerCommandGenerator.new(generator_code: generator_code).generate
|
76
|
+
@command_class_name = command_results.class_name
|
77
|
+
@command_description = command_results.description
|
78
|
+
@command_execute_body = command_results.execute_body
|
79
|
+
@command_filename = command_results.filename
|
80
|
+
|
81
|
+
commands_folder = File.join("lib", @project_name, "commands")
|
82
|
+
|
83
|
+
destination_path = File.join(commands_folder, @command_filename)
|
84
|
+
template("utilities/cli/command.rb.tt", destination_path)
|
85
|
+
end
|
86
|
+
|
55
87
|
private
|
88
|
+
def is_cli_project?
|
89
|
+
config_path = find_config_file
|
90
|
+
return false unless config_path
|
91
|
+
|
92
|
+
config = YAML.load_file(config_path)
|
93
|
+
@project_name = config[:project_name]
|
94
|
+
config[:project_template] == 'CLI'
|
95
|
+
rescue StandardError => e
|
96
|
+
say "Error reading project configuration: #{e.message}", :red
|
97
|
+
false
|
98
|
+
end
|
99
|
+
|
100
|
+
def find_config_file
|
101
|
+
possible_paths = [
|
102
|
+
File.join(Dir.pwd, 'config', 'sublayer.yml'),
|
103
|
+
File.join(Dir.pwd, 'lib', '*', 'config', 'sublayer.yml' )
|
104
|
+
]
|
105
|
+
|
106
|
+
Dir.glob(possible_paths).first
|
107
|
+
end
|
108
|
+
|
56
109
|
def select_ai_model
|
57
110
|
case @ai_provider
|
58
111
|
when "OpenAI"
|
@@ -0,0 +1,55 @@
|
|
1
|
+
class SublayerCommandGenerator < Sublayer::Generators::Base
|
2
|
+
llm_output_adapter type: :named_strings,
|
3
|
+
name: "sublayer_command",
|
4
|
+
description: "The new command code based on the generator",
|
5
|
+
attributes: [
|
6
|
+
{ name: "class_name", description: "The class name of the command" },
|
7
|
+
{ name: "description", description: "The description of the command" },
|
8
|
+
{ name: "execute_body", description: "The code inside the execute method" },
|
9
|
+
{ name: "filename", description: "The filename of the command, snake_cased with a .rb extension" }
|
10
|
+
]
|
11
|
+
|
12
|
+
def initialize(generator_code:)
|
13
|
+
@generator_code = generator_code
|
14
|
+
end
|
15
|
+
|
16
|
+
def generate
|
17
|
+
super
|
18
|
+
end
|
19
|
+
|
20
|
+
def prompt
|
21
|
+
<<-PROMPT
|
22
|
+
You are an expert Ruby developer.
|
23
|
+
|
24
|
+
Given the following Sublayer generator code:
|
25
|
+
|
26
|
+
#{@generator_code}
|
27
|
+
|
28
|
+
Please generate a Thor command class that interacts with this generator. The command should:
|
29
|
+
|
30
|
+
- Be a subclass of `BaseCommand`.
|
31
|
+
- Include a descriptive class name.
|
32
|
+
- Provide a description for the command.
|
33
|
+
- Implement an `execute` method that accepts appropriate arguments and invokes the generator.
|
34
|
+
|
35
|
+
Provide the class name, description, execute method body, and filename for the command.
|
36
|
+
|
37
|
+
These parameters will be used in a template to create the command file. The template is:
|
38
|
+
module <%= project_name.camelize %>
|
39
|
+
module Commands
|
40
|
+
class <%= command_class_name %> < BaseCommand
|
41
|
+
def self.description
|
42
|
+
"<%= command_description %>"
|
43
|
+
end
|
44
|
+
|
45
|
+
def execute(*args)
|
46
|
+
<%= command_execute_body %>
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
Take into account any parameters the generator requires and map them to command-line arguments.
|
53
|
+
PROMPT
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
module Sublayer
|
2
|
+
module Commands
|
3
|
+
class GithubActionProject < Thor::Group
|
4
|
+
attr_reader :ai_provider_key
|
5
|
+
|
6
|
+
include Thor::Actions
|
7
|
+
|
8
|
+
argument :project_name
|
9
|
+
|
10
|
+
class_option :provider, type: :string, desc: "AI provider (OpenAI, Claude, or Gemini)", aliases: :p
|
11
|
+
class_option :model, type: :string, desc: "AI model name to use (e.g. gpt-4o, claude-3-haiku-20240307, gemini-1.5-flash-latest)", aliases: :m
|
12
|
+
|
13
|
+
def self.source_root
|
14
|
+
File.dirname(__FILE__)
|
15
|
+
end
|
16
|
+
|
17
|
+
def sublayer_version
|
18
|
+
Sublayer::VERSION
|
19
|
+
end
|
20
|
+
|
21
|
+
def ask_for_project_details
|
22
|
+
@ai_provider = options[:provider] || ask("Select an AI provider:", default: "OpenAI", limited_to: %w[OpenAI Claude Gemini])
|
23
|
+
@ai_model = options[:model] || select_ai_model
|
24
|
+
end
|
25
|
+
|
26
|
+
def create_project_directory
|
27
|
+
say "Creating project directory", :green
|
28
|
+
|
29
|
+
empty_directory ".github/workflows"
|
30
|
+
end
|
31
|
+
|
32
|
+
def copy_template_files
|
33
|
+
say "Copying template files", :green
|
34
|
+
|
35
|
+
directory "../templates/github_action", ".github/workflows"
|
36
|
+
end
|
37
|
+
|
38
|
+
|
39
|
+
def generate_configuration
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
def finalize_project
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
def print_next_steps
|
48
|
+
say "\nSublayer Github Action Project '#{project_name}' created successfully!", :green
|
49
|
+
say "To get started: "
|
50
|
+
say "Create some Sublayer Actions and Sublayer generators within '.github/workflows/#{project_name}/{actions/,generators/}'"
|
51
|
+
say "And edit the file at '.github/workflows/#{project_name}.yml' to set up what you want the action triggered by"
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
def select_ai_model
|
56
|
+
case @ai_provider
|
57
|
+
when "OpenAI"
|
58
|
+
@ai_provider_key = "OPENAI_API_KEY"
|
59
|
+
ask("Which OpenAI model would you like to use?", default: "gpt-4o", limited_to: %w[gpt-4o gpt-4o-mini gpt-4-turbo gpt-3.5-turbo])
|
60
|
+
when "Claude"
|
61
|
+
@ai_provider_key = "ANTHROPIC_API_KEY"
|
62
|
+
ask("Which Anthropic model would you like to use?", default: "claude-3-5-sonnet-20240620", limited_to: %w[claude-3-5-sonnet-20240620 claude-3-opus-20240620 claude-3-haiku-20240307])
|
63
|
+
when "Gemini"
|
64
|
+
@ai_provider_key = "GEMINI_API_KEY"
|
65
|
+
ask("Which Google model would you like to use?", default: "gemini-1.5-flash-latest", limited_to: %w[gemini-1.5-flash-latest gemini-1.5-pro-latest])
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -5,7 +5,7 @@ module Sublayer
|
|
5
5
|
|
6
6
|
argument :project_name, type: :string, desc: "The name of your project"
|
7
7
|
|
8
|
-
class_option :template, type: :string, desc: "Type of project (CLI
|
8
|
+
class_option :template, type: :string, desc: "Type of project (CLI, GithubAction, QuickScript)", aliases: :t
|
9
9
|
class_option :provider, type: :string, desc: "AI provider (OpenAI, Claude, or Gemini)", aliases: :p
|
10
10
|
class_option :model, type: :string, desc: "AI model name to use (e.g. gpt-4o, claude-3-haiku-20240307, gemini-1.5-flash-latest)", aliases: :m
|
11
11
|
|
@@ -17,98 +17,23 @@ module Sublayer
|
|
17
17
|
File.dirname(__FILE__)
|
18
18
|
end
|
19
19
|
|
20
|
-
def
|
21
|
-
|
22
|
-
@project_template = options[:template] || ask("Select a project template:", default: "CLI", limited_to: %w[CLI QuickScript])
|
23
|
-
@ai_provider = options[:provider] || ask("Select an AI provider:", default: "OpenAI", limited_to: %w[OpenAI Claude Gemini])
|
24
|
-
@ai_model = options[:model] || select_ai_model
|
20
|
+
def self.banner
|
21
|
+
"sublayer new PROJECT_NAME"
|
25
22
|
end
|
26
23
|
|
27
|
-
def
|
28
|
-
|
29
|
-
empty_directory project_name
|
30
|
-
end
|
31
|
-
|
32
|
-
def copy_template_files
|
33
|
-
say "Copying template files", :green
|
34
|
-
template_dir = @project_template == "CLI" ? "cli" : "quick_script"
|
35
|
-
directory "../templates/#{template_dir}", project_name
|
36
|
-
empty_directory File.join(project_name, "log") if @project_template =="CLI"
|
37
|
-
end
|
24
|
+
def create_project
|
25
|
+
@project_template = options[:template] || ask("Select a project template:", default: "CLI", limited_to: %w[CLI GithubAction QuickScript])
|
38
26
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
ai_model: @ai_model
|
47
|
-
}
|
48
|
-
|
49
|
-
if @project_template == "CLI"
|
50
|
-
create_file File.join(project_name, "lib", project_name, "config", "sublayer.yml"), YAML.dump(config)
|
27
|
+
case @project_template.downcase
|
28
|
+
when 'cli'
|
29
|
+
invoke Commands::CLIProject, [project_name], options
|
30
|
+
when 'githubaction', 'github_action'
|
31
|
+
invoke Commands::GithubActionProject, [project_name], options
|
32
|
+
when 'quickscript', 'quick_script'
|
33
|
+
invoke Commands::QuickScriptProject, [project_name], options
|
51
34
|
else
|
52
|
-
|
53
|
-
|
54
|
-
Sublayer.configuration.ai_provider = Sublayer::Providers::#{config[:ai_provider]}
|
55
|
-
Sublayer.configuration.ai_model = "#{config[:ai_model]}"
|
56
|
-
CONFIG
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
def finalize_project
|
62
|
-
say "Finalizing project", :green
|
63
|
-
inside(project_name) do
|
64
|
-
if @project_template == "CLI"
|
65
|
-
chmod("bin/#{project_name}", "+x")
|
66
|
-
run("bundle install") if yes?("Install gems?")
|
67
|
-
else
|
68
|
-
append_to_file "#{project_name}.rb" do
|
69
|
-
<<~INSTRUCTIONS
|
70
|
-
puts "Welcome to your quick Sublayer script!"
|
71
|
-
puts "To get started, create some generators, actions, or agents in their respective directories and call them here"
|
72
|
-
puts "For more information, visit https://docs.sublayer.com"
|
73
|
-
INSTRUCTIONS
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
run("git init") if yes?("Initialize a git repository?")
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
def print_next_steps
|
82
|
-
say "\nSublayer project '#{project_name}' created successfully!", :green
|
83
|
-
say "To get started, run:"
|
84
|
-
say " cd #{project_name}"
|
85
|
-
if @project_template == "CLI"
|
86
|
-
say " ./bin/#{project_name}"
|
87
|
-
else
|
88
|
-
say " ruby #{project_name}.rb"
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
private
|
93
|
-
|
94
|
-
def select_ai_model
|
95
|
-
case @ai_provider
|
96
|
-
when "OpenAI"
|
97
|
-
ask("Which OpenAI model would you like to use?", default: "gpt-4o", limited_to: %w[gpt-4o gpt-4o-mini gpt-4-turbo gpt-3.5-turbo])
|
98
|
-
when "Claude"
|
99
|
-
ask("Which Anthropic model would you like to use?", default: "claude-3-5-sonnet-20240620", limited_to: %w[claude-3-5-sonnet-20240620 claude-3-opus-20240620 claude-3-haiku-20240307])
|
100
|
-
when "Gemini"
|
101
|
-
ask("Which Google model would you like to use?", default: "gemini-1.5-flash-latest", limited_to: %w[gemini-1.5-flash-latest gemini-1.5-pro-latest])
|
102
|
-
end
|
103
|
-
end
|
104
|
-
|
105
|
-
def rename_project_name_directory
|
106
|
-
old_path = File.join(project_name, "lib", "PROJECT_NAME")
|
107
|
-
new_path = File.join(project_name, "lib", project_name.gsub("-", "_").downcase)
|
108
|
-
|
109
|
-
if File.directory?(old_path)
|
110
|
-
say "Renaming project directory", :green
|
111
|
-
FileUtils.mv(old_path, new_path)
|
35
|
+
say "Unknown project template: #{@project_template}", :red
|
36
|
+
exit 1
|
112
37
|
end
|
113
38
|
end
|
114
39
|
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
module Sublayer
|
2
|
+
module Commands
|
3
|
+
class QuickScriptProject < Thor::Group
|
4
|
+
include Thor::Actions
|
5
|
+
|
6
|
+
argument :project_name
|
7
|
+
|
8
|
+
class_option :provider, type: :string, desc: "AI provider (OpenAI, Claude, or Gemini)", aliases: :p
|
9
|
+
class_option :model, type: :string, desc: "AI model name to use (e.g. gpt-4o, claude-3-haiku-20240307, gemini-1.5-flash-latest)", aliases: :m
|
10
|
+
|
11
|
+
def self.source_root
|
12
|
+
File.dirname(__FILE__)
|
13
|
+
end
|
14
|
+
|
15
|
+
def sublayer_version
|
16
|
+
Sublayer::VERSION
|
17
|
+
end
|
18
|
+
|
19
|
+
def ask_for_project_details
|
20
|
+
@ai_provider = options[:provider] || ask("Select an AI provider:", default: "OpenAI", limited_to: %w[OpenAI Claude Gemini])
|
21
|
+
@ai_model = options[:model] || select_ai_model
|
22
|
+
end
|
23
|
+
|
24
|
+
def create_project_directory
|
25
|
+
say "Creating project directory", :green
|
26
|
+
|
27
|
+
empty_directory project_name
|
28
|
+
end
|
29
|
+
|
30
|
+
def copy_template_files
|
31
|
+
say "Copying template files", :green
|
32
|
+
|
33
|
+
directory "../templates/quick_script", project_name
|
34
|
+
end
|
35
|
+
|
36
|
+
def generate_configuration
|
37
|
+
append_to_file File.join(project_name, "#{project_name}.rb") do
|
38
|
+
<<~CONFIG
|
39
|
+
Sublayer.configuration.ai_provider = Sublayer::Providers::#{@ai_provider}
|
40
|
+
Sublayer.configuration.ai_model = "#{@ai_model}"
|
41
|
+
CONFIG
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def finalize_project
|
46
|
+
inside(project_name) do
|
47
|
+
append_to_file "#{project_name}.rb" do
|
48
|
+
<<~INSTRUCTIONS
|
49
|
+
puts "Welcome to your quick Sublayer script!"
|
50
|
+
puts "To get started, create some generators, actions, or agents in their respective directories and call them here"
|
51
|
+
puts "For more information, visit https://docs.sublayer.com"
|
52
|
+
INSTRUCTIONS
|
53
|
+
end
|
54
|
+
|
55
|
+
run("git init") if yes?("Initialize a git repository?")
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def print_next_steps
|
60
|
+
say "\nSublayer project '#{project_name}' created successfully!", :green
|
61
|
+
say "To get started, run:"
|
62
|
+
say " cd #{project_name}"
|
63
|
+
say " ruby #{project_name}.rb"
|
64
|
+
end
|
65
|
+
|
66
|
+
private
|
67
|
+
def select_ai_model
|
68
|
+
case @ai_provider
|
69
|
+
when "OpenAI"
|
70
|
+
ask("Which OpenAI model would you like to use?", default: "gpt-4o", limited_to: %w[gpt-4o gpt-4o-mini gpt-4-turbo gpt-3.5-turbo])
|
71
|
+
when "Claude"
|
72
|
+
ask("Which Anthropic model would you like to use?", default: "claude-3-5-sonnet-20240620", limited_to: %w[claude-3-5-sonnet-20240620 claude-3-opus-20240620 claude-3-haiku-20240307])
|
73
|
+
when "Gemini"
|
74
|
+
ask("Which Google model would you like to use?", default: "gemini-1.5-flash-latest", limited_to: %w[gemini-1.5-flash-latest gemini-1.5-pro-latest])
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
File without changes
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require "base64"
|
2
|
+
|
3
|
+
require "sublayer"
|
4
|
+
require "octokit"
|
5
|
+
|
6
|
+
# Load all Sublayer Actions, Generators, and Agents
|
7
|
+
Dir[File.join(__dir__, "actions", "*.rb")].each { |file| require file }
|
8
|
+
Dir[File.join(__dir__, "generators", "*.rb")].each { |file| require file }
|
9
|
+
Dir[File.join(__dir__, "agents", "*.rb")].each { |file| require file }
|
10
|
+
|
11
|
+
Sublayer.configuration.ai_provider = Sublayer::Providers::<%= @ai_provider %>
|
12
|
+
Sublayer.configuration.ai_model = "<%= @ai_model %>"
|
13
|
+
|
14
|
+
# Add custom Github Action code below:
|
15
|
+
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,30 @@
|
|
1
|
+
name: <%= project_name %>
|
2
|
+
|
3
|
+
|
4
|
+
# Add a definition of when you want this workflow to trigger here
|
5
|
+
#
|
6
|
+
# For example, for it to run on every pull request that contains changes to .rb files, use:
|
7
|
+
#
|
8
|
+
# on:
|
9
|
+
# pull_request:
|
10
|
+
# paths:
|
11
|
+
# - "**/*.rb"
|
12
|
+
|
13
|
+
jobs:
|
14
|
+
<%= project_name.gsub("-", "_") %>:
|
15
|
+
runs-on: ubuntu-latest
|
16
|
+
steps:
|
17
|
+
- uses: actions/checkout@v4.2.0
|
18
|
+
- name: Set up Ruby
|
19
|
+
uses: ruby/setup-ruby@v1
|
20
|
+
with:
|
21
|
+
ruby-version: 3.2
|
22
|
+
- name: Install dependencies
|
23
|
+
run: |
|
24
|
+
gem install sublayer octokit
|
25
|
+
- name: Run <%= project_name.gsub("-", "_") %>
|
26
|
+
env:
|
27
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
28
|
+
<%= ai_provider_key %>: ${{ secrets.<%= ai_provider_key %> }}
|
29
|
+
|
30
|
+
run: ruby .github/workflows/<%= project_name %>/<%= project_name %>.rb
|
data/lib/sublayer/cli.rb
CHANGED
@@ -11,6 +11,9 @@ require_relative "cli/commands/new_project"
|
|
11
11
|
require_relative "cli/commands/generator"
|
12
12
|
require_relative "cli/commands/agent"
|
13
13
|
require_relative "cli/commands/action"
|
14
|
+
require_relative "cli/commands/cli_project"
|
15
|
+
require_relative "cli/commands/github_action_project"
|
16
|
+
require_relative "cli/commands/quick_script_project"
|
14
17
|
|
15
18
|
module Sublayer
|
16
19
|
class CLI < Thor
|
data/lib/sublayer/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sublayer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Scott Werner
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-08
|
11
|
+
date: 2024-10-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ruby-openai
|
@@ -159,6 +159,7 @@ executables:
|
|
159
159
|
extensions: []
|
160
160
|
extra_rdoc_files: []
|
161
161
|
files:
|
162
|
+
- ".contextignore"
|
162
163
|
- LICENSE
|
163
164
|
- README.md
|
164
165
|
- Rakefile
|
@@ -169,6 +170,7 @@ files:
|
|
169
170
|
- lib/sublayer/cli.rb
|
170
171
|
- lib/sublayer/cli/commands/action.rb
|
171
172
|
- lib/sublayer/cli/commands/agent.rb
|
173
|
+
- lib/sublayer/cli/commands/cli_project.rb
|
172
174
|
- lib/sublayer/cli/commands/generator.rb
|
173
175
|
- lib/sublayer/cli/commands/generators/example_action_api_call.rb
|
174
176
|
- lib/sublayer/cli/commands/generators/example_action_file_manipulation.rb
|
@@ -176,11 +178,14 @@ files:
|
|
176
178
|
- lib/sublayer/cli/commands/generators/example_generator.rb
|
177
179
|
- lib/sublayer/cli/commands/generators/sublayer_action_generator.rb
|
178
180
|
- lib/sublayer/cli/commands/generators/sublayer_agent_generator.rb
|
181
|
+
- lib/sublayer/cli/commands/generators/sublayer_command_generator.rb
|
179
182
|
- lib/sublayer/cli/commands/generators/sublayer_generator_generator.rb
|
183
|
+
- lib/sublayer/cli/commands/github_action_project.rb
|
180
184
|
- lib/sublayer/cli/commands/new_project.rb
|
185
|
+
- lib/sublayer/cli/commands/quick_script_project.rb
|
181
186
|
- lib/sublayer/cli/commands/subcommand_base.rb
|
182
187
|
- lib/sublayer/cli/templates/cli/%project_name%.gemspec.tt
|
183
|
-
- lib/sublayer/cli/templates/cli/.gitignore
|
188
|
+
- lib/sublayer/cli/templates/cli/.gitignore.tt
|
184
189
|
- lib/sublayer/cli/templates/cli/Gemfile
|
185
190
|
- lib/sublayer/cli/templates/cli/README.md.tt
|
186
191
|
- lib/sublayer/cli/templates/cli/bin/%project_name%.tt
|
@@ -194,12 +199,19 @@ files:
|
|
194
199
|
- lib/sublayer/cli/templates/cli/lib/%project_name%/config/.keep
|
195
200
|
- lib/sublayer/cli/templates/cli/lib/%project_name%/generators/example_generator.rb.tt
|
196
201
|
- lib/sublayer/cli/templates/cli/lib/%project_name%/version.rb.tt
|
202
|
+
- lib/sublayer/cli/templates/cli/log/.keep
|
197
203
|
- lib/sublayer/cli/templates/cli/spec/.keep
|
204
|
+
- lib/sublayer/cli/templates/github_action/%project_name%.yml.tt
|
205
|
+
- lib/sublayer/cli/templates/github_action/%project_name%/%project_name%.rb.tt
|
206
|
+
- lib/sublayer/cli/templates/github_action/%project_name%/actions/.keep
|
207
|
+
- lib/sublayer/cli/templates/github_action/%project_name%/agents/.keep
|
208
|
+
- lib/sublayer/cli/templates/github_action/%project_name%/generators/.keep
|
198
209
|
- lib/sublayer/cli/templates/quick_script/%project_name%.rb
|
199
210
|
- lib/sublayer/cli/templates/quick_script/README.md.tt
|
200
211
|
- lib/sublayer/cli/templates/quick_script/actions/example_action.rb
|
201
212
|
- lib/sublayer/cli/templates/quick_script/agents/example_agent.rb
|
202
213
|
- lib/sublayer/cli/templates/quick_script/generators/example_generator.rb
|
214
|
+
- lib/sublayer/cli/templates/utilities/cli/command.rb.tt
|
203
215
|
- lib/sublayer/components/output_adapters.rb
|
204
216
|
- lib/sublayer/components/output_adapters/formattable.rb
|
205
217
|
- lib/sublayer/components/output_adapters/list_of_named_strings.rb
|
File without changes
|