strata-cli 0.1.8 → 0.1.10

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.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +29 -0
  3. data/README.md +26 -2
  4. data/lib/strata/cli/agent_mode.rb +26 -0
  5. data/lib/strata/cli/agent_output.rb +21 -0
  6. data/lib/strata/cli/ai/services/table_generator.rb +35 -20
  7. data/lib/strata/cli/api/client.rb +23 -63
  8. data/lib/strata/cli/api/response_error_handler.rb +115 -0
  9. data/lib/strata/cli/error_reporter.rb +4 -1
  10. data/lib/strata/cli/generators/datasource.rb +4 -3
  11. data/lib/strata/cli/generators/group.rb +37 -0
  12. data/lib/strata/cli/generators/migration.rb +2 -1
  13. data/lib/strata/cli/generators/project.rb +18 -11
  14. data/lib/strata/cli/generators/relation.rb +2 -1
  15. data/lib/strata/cli/generators/table.rb +5 -8
  16. data/lib/strata/cli/generators/templates/AGENTS.md +457 -88
  17. data/lib/strata/cli/generators/templates/table.table_name.yml +8 -3
  18. data/lib/strata/cli/generators/test.rb +2 -1
  19. data/lib/strata/cli/guard.rb +4 -1
  20. data/lib/strata/cli/helpers/command_context.rb +8 -9
  21. data/lib/strata/cli/helpers/datasource_helper.rb +27 -1
  22. data/lib/strata/cli/helpers/description_helper.rb +2 -1
  23. data/lib/strata/cli/main.rb +12 -3
  24. data/lib/strata/cli/output.rb +103 -0
  25. data/lib/strata/cli/sub_commands/audit.rb +136 -16
  26. data/lib/strata/cli/sub_commands/branch.rb +165 -0
  27. data/lib/strata/cli/sub_commands/create.rb +13 -2
  28. data/lib/strata/cli/sub_commands/datasource.rb +21 -3
  29. data/lib/strata/cli/sub_commands/deploy.rb +16 -13
  30. data/lib/strata/cli/sub_commands/project.rb +6 -3
  31. data/lib/strata/cli/sub_commands/table.rb +11 -8
  32. data/lib/strata/cli/terminal.rb +7 -4
  33. data/lib/strata/cli/ui/field_editor.rb +21 -27
  34. data/lib/strata/cli/utils/deployment_monitor.rb +15 -34
  35. data/lib/strata/cli/utils/git.rb +78 -0
  36. data/lib/strata/cli/utils/import_manager.rb +4 -1
  37. data/lib/strata/cli/utils/test_reporter.rb +4 -32
  38. data/lib/strata/cli/utils/version_checker.rb +4 -8
  39. data/lib/strata/cli/utils.rb +3 -1
  40. data/lib/strata/cli/version.rb +1 -1
  41. data/lib/strata/cli.rb +4 -3
  42. metadata +6 -2
  43. data/lib/strata/cli/helpers/color_helper.rb +0 -103
@@ -4,6 +4,8 @@ require_relative "group"
4
4
  require_relative "datasource"
5
5
  require_relative "../helpers/project_helper"
6
6
  require_relative "../api/connection_error_handler"
7
+ require_relative "../api/response_error_handler"
8
+ require_relative "../output"
7
9
  require "faraday"
8
10
  require "json"
9
11
  require "uri"
@@ -13,6 +15,7 @@ module Strata
13
15
  module Generators
14
16
  class Project < Group
15
17
  include API::ConnectionErrorHandler
18
+ include API::ResponseErrorHandler
16
19
 
17
20
  BASE_SERVER_URL = "http://localhost:3000"
18
21
 
@@ -20,6 +23,7 @@ module Strata
20
23
  class_option :datasource, type: :string, repeatable: true
21
24
  class_option :source, type: :string
22
25
  class_option :api_key, type: :string
26
+ class_option :verbose, type: :boolean, default: false, desc: "Show detailed init output (file-by-file actions)."
23
27
 
24
28
  desc "Generates a new Strata project."
25
29
 
@@ -111,8 +115,8 @@ module Strata
111
115
  return if cloned_from_git?
112
116
  return if options.key?(:datasource) # Already specified via CLI option
113
117
 
114
- say "\n", :white
115
- say_status :setup, "Let's configure your first datasource", :cyan
118
+ print_status(:setup, "Let's configure your first datasource", type: :info)
119
+ print_info("\n")
116
120
 
117
121
  # Change into the project directory and run the existing add command
118
122
  inside(uid) do
@@ -122,12 +126,12 @@ module Strata
122
126
  end
123
127
 
124
128
  def completion_message
125
- say "\n✔ Strata project '#{uid}' is ready!", :green
126
- say "\nNext steps:", :yellow
127
- say " 1. cd #{uid}", :cyan
128
- say " 2. strata datasource add # To add more datasources", :cyan
129
- say " 3. strata create table # Start adding tables", :cyan
130
- say "\n"
129
+ Output.print_success("\n✔ Strata project '#{uid}' is ready!", context: self)
130
+ Output.print_warning("\nNext steps:", context: self)
131
+ Output.print_info(" 1. cd #{uid}", context: self)
132
+ Output.print_info(" 2. strata datasource add # To add more datasources", context: self)
133
+ Output.print_info(" 3. strata create table # Start adding tables", context: self)
134
+ Output.print_info("\n", context: self)
131
135
  end
132
136
 
133
137
  private
@@ -148,19 +152,22 @@ module Strata
148
152
 
149
153
  unless response.success?
150
154
  raise Strata::CommandError,
151
- "Failed to fetch project info from #{options[:source]}. Status: #{response.status}"
155
+ response_error_message(
156
+ response,
157
+ default_message: "Failed to fetch project info from #{options[:source]}. Status: #{response.status}."
158
+ )
152
159
  end
153
160
 
154
161
  response.body
155
162
  end
156
163
 
157
164
  def clone_project(git_url)
158
- say_status :clone, "Cloning project from #{git_url}", :green
165
+ Output.print_status(:clone, "Cloning project from #{git_url}", type: :success, context: self)
159
166
  run "git clone #{git_url} #{uid}", verbose: false, capture: true
160
167
 
161
168
  raise Strata::CommandError, "Failed to clone repository from #{git_url}" unless File.directory?(uid)
162
169
 
163
- say_status :success, "Project cloned successfully", :green
170
+ Output.print_status(:success, "Project cloned successfully", type: :success, context: self)
164
171
  end
165
172
 
166
173
  def persist_project_id_to_project_yml
@@ -3,6 +3,7 @@
3
3
  require_relative "group"
4
4
  require "yaml"
5
5
  require "fileutils"
6
+ require_relative "../output"
6
7
 
7
8
  module Strata
8
9
  module CLI
@@ -26,7 +27,7 @@ module Strata
26
27
  # Write the updated template
27
28
  create_file output_path, updated_content
28
29
 
29
- say_status :created, output_path, :green
30
+ Output.print_status(:created, output_path, type: :success, context: self)
30
31
  end
31
32
 
32
33
  private
@@ -2,6 +2,7 @@
2
2
 
3
3
  require_relative "group"
4
4
  require "yaml"
5
+ require_relative "../output"
5
6
 
6
7
  module Strata
7
8
  module CLI
@@ -43,7 +44,7 @@ module Strata
43
44
  # Write the updated template
44
45
  create_file output_path, updated_content
45
46
 
46
- say_status :created, output_path, :green
47
+ Output.print_status(:created, output_path, type: :success, context: self)
47
48
  end
48
49
 
49
50
  private
@@ -101,8 +102,9 @@ module Strata
101
102
  # Normalize hash keys to symbols for consistent access
102
103
  normalized = normalize_field_hash(field)
103
104
 
105
+ field_type = normalized[:schema_type] || "dimension"
104
106
  field_hash = {
105
- "type" => normalized[:schema_type] || "dimension",
107
+ "type" => field_type,
106
108
  "name" => normalized[:name],
107
109
  "description" => normalized[:description],
108
110
  "data_type" => normalized[:data_type]
@@ -112,12 +114,7 @@ module Strata
112
114
  field_hash["synonyms"] = synonyms if synonyms.is_a?(Array) && !synonyms.empty?
113
115
 
114
116
  # Build expression with proper nested format
115
- expr = normalized[:expression]
116
- field_hash["expression"] = {
117
- "lookup" => true,
118
- "sql" => expr
119
- }
120
-
117
+ field_hash["expression"] = {"sql" => normalized[:expression], "lookup" => field_type.to_s.casecmp("dimension").zero?}
121
118
  field_hash
122
119
  end
123
120