makit 0.0.139 → 0.0.141

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: 8914cc91413f619374d83e3dbd6a339d1d8b2ddd3cdf6b97ba60e679a6086791
4
- data.tar.gz: aa96a06181f3080162e6e1712f69a23d18a9dd85be0dd963fb263ac06618b397
3
+ metadata.gz: 5292d7e48fcc8060c1ad09ed8beeb9bb596c6d33fe33075e39f65553480532c2
4
+ data.tar.gz: be28ff936d5268a37689bd9f7d581144b755fee9ef310cb24e6ee2c85045517a
5
5
  SHA512:
6
- metadata.gz: '059afb37ecd17ce37de9e74c6885032d6e17bf13c39e3de14e5334603b872c325b7d6a24408a03e3eb42517096ba8c7d9251ba3543cfc9421b7a46a6a9d8698d'
7
- data.tar.gz: a068d31da5e80058570e92d9d1a5e26c9ca0f6458d0656c801dfce426935571b7dda46e9e03f0106e7f2f68c9431d8bad0019bb2a44132c1df8282d9fdfbb724
6
+ metadata.gz: ce30902a329a81775d0d023597daef878bcd78a692ee6c3de0cb85b325077422813638b28bcdd5a52b5991b677e5ca7966335a6cc8b0c1f6267dfd3ff7d86a6a
7
+ data.tar.gz: f16cb9d563051f87fd8b8693afde7415b21e75ac35d7ac98c22264c789d7065035d053d534153872d942b8add3241b34b7aab8c30f81191ff275cd76e58b152f
@@ -23,6 +23,7 @@ module Makit
23
23
  utility - System utilities and maintenance (nuget-cache, system-info)
24
24
  strategy - Manage execution strategies (show, test)
25
25
  trace - Manage trace functionality (show, enable, disable, test)
26
+ timeout - Manage timeout configuration (show, set, reset, test)
26
27
  rake - Manage rake tasks
27
28
 
28
29
  Common usage examples:
@@ -61,6 +62,7 @@ module Makit
61
62
  subcommand "utility", "System utilities and maintenance", UtilityCommand
62
63
  subcommand "strategy", "Manage execution strategies", StrategyCommands
63
64
  subcommand "trace", "Manage trace functionality", TraceCommands
65
+ subcommand "timeout", "Manage timeout configuration", TimeoutCommands
64
66
  subcommand "rake", "Manage rake tasks", Makit::Rake::CliCommand
65
67
  end
66
68
  end
@@ -1,152 +1,203 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "base"
4
-
5
- module Makit
6
- module Cli
7
- # Commands for managing execution strategies
8
- class StrategyCommands < Base
9
- desc "strategy", "Show current execution strategy information"
10
- option ["--verbose", "-v"], :flag, "Show detailed strategy information"
11
- def strategy
12
- runner = Makit::Commands::Runner.default
13
- info = runner.strategy_info
14
-
15
- puts "Current Execution Strategy:"
16
- puts " Type: #{info[:type]}"
17
- puts " Class: #{info[:class]}"
18
-
19
- if options[:verbose]
20
- puts "\nFactory Information:"
21
- factory_info = info[:factory_info]
22
- puts " Current: #{factory_info[:current]}"
23
- puts " Available: #{factory_info[:available].join(', ')}"
24
- puts " ChildProcess Available: #{factory_info[:childprocess_available]}"
25
- puts " Open3 Available: #{factory_info[:open3_available]}"
26
- end
27
-
28
- puts "\nEnvironment Variables:"
29
- puts " MAKIT_STRATEGY: #{ENV['MAKIT_STRATEGY'] || 'not set (using auto-detect)'}"
30
- end
31
-
32
- desc "strategy test", "Test both strategies and show performance comparison"
33
- option ["--timeout", "-t"], "TIMEOUT", "Timeout for test commands", default: "5"
34
- def test
35
- timeout = options[:timeout].to_i
36
-
37
- puts "Testing execution strategies..."
38
- puts "=" * 50
39
-
40
- # Test ChildProcess strategy
41
- puts "\n1. Testing ChildProcess Strategy:"
42
- childprocess_result = test_strategy('childprocess', timeout)
43
-
44
- # Test Open3 strategy
45
- puts "\n2. Testing Open3 Strategy:"
46
- open3_result = test_strategy('open3', timeout)
47
-
48
- # Show comparison
49
- puts "\n" + "=" * 50
50
- puts "Performance Comparison:"
51
- puts " ChildProcess: #{childprocess_result[:duration]}s (#{childprocess_result[:status]})"
52
- puts " Open3: #{open3_result[:duration]}s (#{open3_result[:status]})"
53
- end
54
-
55
- private
56
-
57
- # Test a specific strategy
58
- #
59
- # @param strategy_type [String] strategy type to test
60
- # @param timeout [Integer] timeout for test commands
61
- # @return [Hash] test results
62
- def test_strategy(strategy_type, timeout)
63
- start_time = Time.now
64
-
65
- begin
66
- # Create runner with specific strategy
67
- strategy = Makit::Commands::Strategies::Factory.create(strategy: strategy_type)
68
- runner = Makit::Commands::Runner.new(strategy: strategy)
69
-
70
- # Test with a simple command
71
- request = Makit::Commands::Request.new(
72
- command: "echo",
73
- arguments: ["Hello from #{strategy_type}!"],
74
- timeout: timeout
75
- )
76
-
77
- result = runner.execute(request)
78
- duration = Time.now - start_time
79
-
80
- status = result.success? ? "SUCCESS" : "FAILED"
81
- puts " Status: #{status}"
82
- puts " Duration: #{duration.round(3)}s"
83
- puts " Output: #{result.stdout.strip}"
84
-
85
- if result.failure?
86
- puts " Error: #{result.stderr}"
87
- end
88
-
89
- { duration: duration.round(3), status: status, success: result.success? }
90
-
91
- rescue => e
92
- duration = Time.now - start_time
93
- puts " Status: ERROR"
94
- puts " Duration: #{duration.round(3)}s"
95
- puts " Error: #{e.message}"
96
-
97
- { duration: duration.round(3), status: "ERROR", success: false }
98
- end
99
- end
100
- end
101
- end
102
-
103
- # Add trace commands to the main CLI
104
- module Makit
105
- module Cli
106
- # Commands for managing trace functionality
107
- class TraceCommands < Base
108
- desc "trace", "Show current trace status and configuration"
109
- option ["--verbose", "-v"], :flag, "Show detailed trace information"
110
- def trace
111
- puts "Makit Trace Status:"
112
- puts "=" * 30
113
-
114
- status = Makit::Rake.status
115
-
116
- puts "Enhanced Tracing: #{Makit::Rake.tracing_enabled? ? 'Enabled' : 'Disabled'}"
117
- puts "Rake Trace: #{status[:trace_controller][:rake_trace] || 'Not set'}"
118
- puts "Trace Flag: #{status[:trace_controller][:trace_flag] ? 'Present' : 'Not present'}"
119
- puts "Makit Trace: #{status[:trace_controller][:makit_trace] || 'Not set'}"
120
- puts "Verbose Mode: #{status[:verbose] ? 'Enabled' : 'Disabled'}"
121
-
122
- if options[:verbose]
123
- puts "\nDetailed Information:"
124
- puts " Strategy: #{status[:strategy][:type] || 'Unknown'}"
125
- puts " Class: #{status[:strategy][:class] || 'Unknown'}"
126
- puts " Factory Info: #{status[:strategy][:factory_info] || 'Not available'}"
127
- end
128
- end
129
-
130
- desc "trace enable", "Enable enhanced tracing"
131
- def enable
132
- ENV['MAKIT_TRACE'] = 'true'
133
- puts "Enhanced tracing enabled"
134
- puts "Run 'rake --trace' to see enhanced output"
135
- end
136
-
137
- desc "trace disable", "Disable enhanced tracing"
138
- def disable
139
- ENV.delete('MAKIT_TRACE')
140
- puts "Enhanced tracing disabled"
141
- end
142
-
143
- desc "trace test", "Test trace functionality with a simple rake task"
144
- def test
145
- puts "Testing trace functionality..."
146
- puts "Run: rake --trace"
147
- puts "You should see [MAKIT] prefixed trace output for makit-related tasks"
148
- end
149
- end
150
- end
151
- end
152
- end
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "base"
4
+
5
+ module Makit
6
+ module Cli
7
+ # Commands for managing execution strategies
8
+ class StrategyCommands < Base
9
+ desc "strategy", "Show current execution strategy information"
10
+ option ["--verbose", "-v"], :flag, "Show detailed strategy information"
11
+ def strategy
12
+ runner = Makit::Commands::Runner.default
13
+ info = runner.strategy_info
14
+
15
+ puts "Current Execution Strategy:"
16
+ puts " Type: #{info[:type]}"
17
+ puts " Class: #{info[:class]}"
18
+
19
+ if options[:verbose]
20
+ puts "\nFactory Information:"
21
+ factory_info = info[:factory_info]
22
+ puts " Current: #{factory_info[:current]}"
23
+ puts " Available: #{factory_info[:available].join(', ')}"
24
+ puts " ChildProcess Available: #{factory_info[:childprocess_available]}"
25
+ puts " Open3 Available: #{factory_info[:open3_available]}"
26
+ end
27
+
28
+ puts "\nEnvironment Variables:"
29
+ puts " MAKIT_STRATEGY: #{ENV['MAKIT_STRATEGY'] || 'not set (using auto-detect)'}"
30
+ end
31
+
32
+ desc "strategy test", "Test both strategies and show performance comparison"
33
+ option ["--timeout", "-t"], "TIMEOUT", "Timeout for test commands", default: "5"
34
+ def test
35
+ timeout = options[:timeout].to_i
36
+
37
+ puts "Testing execution strategies..."
38
+ puts "=" * 50
39
+
40
+ # Test ChildProcess strategy
41
+ puts "\n1. Testing ChildProcess Strategy:"
42
+ childprocess_result = test_strategy('childprocess', timeout)
43
+
44
+ # Test Open3 strategy
45
+ puts "\n2. Testing Open3 Strategy:"
46
+ open3_result = test_strategy('open3', timeout)
47
+
48
+ # Show comparison
49
+ puts "\n" + "=" * 50
50
+ puts "Performance Comparison:"
51
+ puts " ChildProcess: #{childprocess_result[:duration]}s (#{childprocess_result[:status]})"
52
+ puts " Open3: #{open3_result[:duration]}s (#{open3_result[:status]})"
53
+ end
54
+
55
+ private
56
+
57
+ # Test a specific strategy
58
+ #
59
+ # @param strategy_type [String] strategy type to test
60
+ # @param timeout [Integer] timeout for test commands
61
+ # @return [Hash] test results
62
+ def test_strategy(strategy_type, timeout)
63
+ start_time = Time.now
64
+
65
+ begin
66
+ # Create runner with specific strategy
67
+ strategy = Makit::Commands::Strategies::Factory.create(strategy: strategy_type)
68
+ runner = Makit::Commands::Runner.new(strategy: strategy)
69
+
70
+ # Test with a simple command
71
+ request = Makit::Commands::Request.new(
72
+ command: "echo",
73
+ arguments: ["Hello from #{strategy_type}!"],
74
+ timeout: timeout
75
+ )
76
+
77
+ result = runner.execute(request)
78
+ duration = Time.now - start_time
79
+
80
+ status = result.success? ? "SUCCESS" : "FAILED"
81
+ puts " Status: #{status}"
82
+ puts " Duration: #{duration.round(3)}s"
83
+ puts " Output: #{result.stdout.strip}"
84
+
85
+ if result.failure?
86
+ puts " Error: #{result.stderr}"
87
+ end
88
+
89
+ { duration: duration.round(3), status: status, success: result.success? }
90
+
91
+ rescue => e
92
+ duration = Time.now - start_time
93
+ puts " Status: ERROR"
94
+ puts " Duration: #{duration.round(3)}s"
95
+ puts " Error: #{e.message}"
96
+
97
+ { duration: duration.round(3), status: "ERROR", success: false }
98
+ end
99
+ end
100
+ end
101
+ end
102
+
103
+ # Add trace commands to the main CLI
104
+ module Makit
105
+ module Cli
106
+ # Commands for managing trace functionality
107
+ class TraceCommands < Base
108
+ desc "trace", "Show current trace status and configuration"
109
+ option ["--verbose", "-v"], :flag, "Show detailed trace information"
110
+ def trace
111
+ puts "Makit Trace Status:"
112
+ puts "=" * 30
113
+
114
+ status = Makit::Rake.status
115
+
116
+ puts "Enhanced Tracing: #{Makit::Rake.tracing_enabled? ? 'Enabled' : 'Disabled'}"
117
+ puts "Rake Trace: #{status[:trace_controller][:rake_trace] || 'Not set'}"
118
+ puts "Trace Flag: #{status[:trace_controller][:trace_flag] ? 'Present' : 'Not present'}"
119
+ puts "Makit Trace: #{status[:trace_controller][:makit_trace] || 'Not set'}"
120
+ puts "Verbose Mode: #{status[:verbose] ? 'Enabled' : 'Disabled'}"
121
+
122
+ if options[:verbose]
123
+ puts "\nDetailed Information:"
124
+ puts " Strategy: #{status[:strategy][:type] || 'Unknown'}"
125
+ puts " Class: #{status[:strategy][:class] || 'Unknown'}"
126
+ puts " Factory Info: #{status[:strategy][:factory_info] || 'Not available'}"
127
+ end
128
+ end
129
+
130
+ desc "trace enable", "Enable enhanced tracing"
131
+ def enable
132
+ ENV['MAKIT_TRACE'] = 'true'
133
+ puts "Enhanced tracing enabled"
134
+ puts "Run 'rake --trace' to see enhanced output"
135
+ end
136
+
137
+ desc "trace disable", "Disable enhanced tracing"
138
+ def disable
139
+ ENV.delete('MAKIT_TRACE')
140
+ puts "Enhanced tracing disabled"
141
+ end
142
+
143
+ desc "trace test", "Test trace functionality with a simple rake task"
144
+ def test
145
+ puts "Testing trace functionality..."
146
+ puts "Run: rake --trace"
147
+ puts "You should see [MAKIT] prefixed trace output for makit-related tasks"
148
+ end
149
+ end
150
+
151
+ # Commands for managing timeout configuration
152
+ class TimeoutCommands < Base
153
+ desc "timeout", "Show current timeout configuration"
154
+ option ["--verbose", "-v"], :flag, "Show detailed timeout information"
155
+ def timeout
156
+ puts "Makit Timeout Configuration:"
157
+ puts "=" * 35
158
+
159
+ puts "Global Default: #{Makit::Configuration::Timeout.global_default}s"
160
+ puts "Environment: #{ENV['MAKIT_DEFAULT_TIMEOUT'] || 'Not set'}"
161
+
162
+ if options[:verbose]
163
+ puts "\nOperation-Specific Timeouts:"
164
+ Makit::Configuration::Timeout.all_timeouts.each do |operation, timeout|
165
+ puts " #{operation.to_s.ljust(20)}: #{timeout}s"
166
+ end
167
+ end
168
+ end
169
+
170
+ desc "timeout set", "Set global default timeout"
171
+ option ["--timeout", "-t"], "TIMEOUT", "Timeout in seconds", required: true
172
+ def set
173
+ timeout = options[:timeout].to_i
174
+ Makit::Configuration::Timeout.validate_timeout(timeout)
175
+ ENV['MAKIT_DEFAULT_TIMEOUT'] = timeout.to_s
176
+ puts "Global timeout set to #{timeout} seconds"
177
+ end
178
+
179
+ desc "timeout reset", "Reset timeout to default value"
180
+ def reset
181
+ ENV.delete('MAKIT_DEFAULT_TIMEOUT')
182
+ puts "Timeout reset to default: #{Makit::Configuration::Timeout.global_default} seconds"
183
+ end
184
+
185
+ desc "timeout test", "Test timeout configuration with a simple command"
186
+ option ["--timeout", "-t"], "TIMEOUT", "Timeout for test command", default: "5"
187
+ def test
188
+ timeout = options[:timeout].to_i
189
+ puts "Testing timeout configuration with #{timeout}s timeout..."
190
+
191
+ # Test with a simple command
192
+ result = Makit::Commands::Runner.default.run("echo", "Timeout test", timeout: timeout)
193
+
194
+ if result.success?
195
+ puts "✓ Timeout test passed"
196
+ else
197
+ puts "✗ Timeout test failed: #{result.stderr}"
198
+ end
199
+ end
200
+ end
201
+ end
202
+ end
203
+ end
@@ -55,7 +55,7 @@ module Makit
55
55
  @arguments = validate_arguments(arguments)
56
56
  @environment = options[:environment] || {}
57
57
  @directory = options[:directory] || Dir.pwd
58
- @timeout = options[:timeout] || 30
58
+ @timeout = options[:timeout] || Makit::Configuration::Timeout.global_default
59
59
  @metadata = options[:metadata] || {}
60
60
  @exit_on_failure = options[:exit_on_failure] || true
61
61
  @show_stderr = options[:show_stderr] || true
@@ -179,6 +179,18 @@ module Makit
179
179
  }
180
180
  end
181
181
 
182
+ # Make this method public as it is used by rake hooks and CLI output
183
+ # Get information about the current strategy
184
+ #
185
+ # @return [Hash] strategy information
186
+ def strategy_info
187
+ {
188
+ class: @strategy.class.name,
189
+ type: @strategy.class.name.split('::').last.downcase,
190
+ factory_info: Strategies::Factory.strategy_info
191
+ }
192
+ end
193
+
182
194
  private
183
195
 
184
196
  # Execute request with middleware chain.
@@ -320,16 +332,7 @@ module Makit
320
332
  raise ArgumentError, "Strategy must respond to #supports?: #{@strategy.class}"
321
333
  end
322
334
 
323
- # Get information about the current strategy
324
- #
325
- # @return [Hash] strategy information
326
- def strategy_info
327
- {
328
- class: @strategy.class.name,
329
- type: @strategy.class.name.split('::').last.downcase,
330
- factory_info: Strategies::Factory.strategy_info
331
- }
332
- end
335
+
333
336
 
334
337
  # Log command execution result using the default logger.
335
338
  #