sxn 0.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 +7 -0
- data/.gem_rbs_collection/addressable/2.8/.rbs_meta.yaml +9 -0
- data/.gem_rbs_collection/addressable/2.8/addressable.rbs +62 -0
- data/.gem_rbs_collection/async/2.12/.rbs_meta.yaml +9 -0
- data/.gem_rbs_collection/async/2.12/async.rbs +119 -0
- data/.gem_rbs_collection/async/2.12/kernel.rbs +5 -0
- data/.gem_rbs_collection/async/2.12/manifest.yaml +7 -0
- data/.gem_rbs_collection/bcrypt/3.1/.rbs_meta.yaml +9 -0
- data/.gem_rbs_collection/bcrypt/3.1/bcrypt.rbs +47 -0
- data/.gem_rbs_collection/bcrypt/3.1/manifest.yaml +2 -0
- data/.gem_rbs_collection/bigdecimal/3.1/.rbs_meta.yaml +9 -0
- data/.gem_rbs_collection/bigdecimal/3.1/bigdecimal-math.rbs +119 -0
- data/.gem_rbs_collection/bigdecimal/3.1/bigdecimal.rbs +1630 -0
- data/.gem_rbs_collection/concurrent-ruby/1.1/.rbs_meta.yaml +9 -0
- data/.gem_rbs_collection/concurrent-ruby/1.1/array.rbs +4 -0
- data/.gem_rbs_collection/concurrent-ruby/1.1/executor.rbs +26 -0
- data/.gem_rbs_collection/concurrent-ruby/1.1/hash.rbs +4 -0
- data/.gem_rbs_collection/concurrent-ruby/1.1/map.rbs +65 -0
- data/.gem_rbs_collection/concurrent-ruby/1.1/promises.rbs +249 -0
- data/.gem_rbs_collection/concurrent-ruby/1.1/utility/processor_counter.rbs +5 -0
- data/.gem_rbs_collection/diff-lcs/1.5/.rbs_meta.yaml +9 -0
- data/.gem_rbs_collection/diff-lcs/1.5/diff-lcs.rbs +11 -0
- data/.gem_rbs_collection/listen/3.9/.rbs_meta.yaml +9 -0
- data/.gem_rbs_collection/listen/3.9/listen.rbs +25 -0
- data/.gem_rbs_collection/listen/3.9/listener.rbs +24 -0
- data/.gem_rbs_collection/mini_mime/0.1/.rbs_meta.yaml +9 -0
- data/.gem_rbs_collection/mini_mime/0.1/mini_mime.rbs +14 -0
- data/.gem_rbs_collection/parallel/1.20/.rbs_meta.yaml +9 -0
- data/.gem_rbs_collection/parallel/1.20/parallel.rbs +86 -0
- data/.gem_rbs_collection/rake/13.0/.rbs_meta.yaml +9 -0
- data/.gem_rbs_collection/rake/13.0/manifest.yaml +2 -0
- data/.gem_rbs_collection/rake/13.0/rake.rbs +39 -0
- data/.gem_rbs_collection/rubocop-ast/1.46/.rbs_meta.yaml +9 -0
- data/.gem_rbs_collection/rubocop-ast/1.46/rubocop-ast.rbs +822 -0
- data/.gem_rbs_collection/sqlite3/2.0/.rbs_meta.yaml +9 -0
- data/.gem_rbs_collection/sqlite3/2.0/database.rbs +20 -0
- data/.gem_rbs_collection/sqlite3/2.0/pragmas.rbs +5 -0
- data/.rspec +4 -0
- data/.rubocop.yml +121 -0
- data/.simplecov +51 -0
- data/CHANGELOG.md +49 -0
- data/Gemfile +24 -0
- data/Gemfile.lock +329 -0
- data/LICENSE.txt +21 -0
- data/README.md +225 -0
- data/Rakefile +54 -0
- data/Steepfile +50 -0
- data/bin/sxn +6 -0
- data/lib/sxn/CLI.rb +275 -0
- data/lib/sxn/commands/init.rb +137 -0
- data/lib/sxn/commands/projects.rb +350 -0
- data/lib/sxn/commands/rules.rb +435 -0
- data/lib/sxn/commands/sessions.rb +300 -0
- data/lib/sxn/commands/worktrees.rb +416 -0
- data/lib/sxn/commands.rb +13 -0
- data/lib/sxn/config/config_cache.rb +295 -0
- data/lib/sxn/config/config_discovery.rb +242 -0
- data/lib/sxn/config/config_validator.rb +562 -0
- data/lib/sxn/config.rb +259 -0
- data/lib/sxn/core/config_manager.rb +290 -0
- data/lib/sxn/core/project_manager.rb +307 -0
- data/lib/sxn/core/rules_manager.rb +306 -0
- data/lib/sxn/core/session_manager.rb +336 -0
- data/lib/sxn/core/worktree_manager.rb +281 -0
- data/lib/sxn/core.rb +13 -0
- data/lib/sxn/database/errors.rb +29 -0
- data/lib/sxn/database/session_database.rb +691 -0
- data/lib/sxn/database.rb +24 -0
- data/lib/sxn/errors.rb +76 -0
- data/lib/sxn/rules/base_rule.rb +367 -0
- data/lib/sxn/rules/copy_files_rule.rb +346 -0
- data/lib/sxn/rules/errors.rb +28 -0
- data/lib/sxn/rules/project_detector.rb +871 -0
- data/lib/sxn/rules/rules_engine.rb +485 -0
- data/lib/sxn/rules/setup_commands_rule.rb +307 -0
- data/lib/sxn/rules/template_rule.rb +262 -0
- data/lib/sxn/rules.rb +148 -0
- data/lib/sxn/runtime_validations.rb +96 -0
- data/lib/sxn/security/secure_command_executor.rb +364 -0
- data/lib/sxn/security/secure_file_copier.rb +478 -0
- data/lib/sxn/security/secure_path_validator.rb +258 -0
- data/lib/sxn/security.rb +15 -0
- data/lib/sxn/templates/common/gitignore.liquid +99 -0
- data/lib/sxn/templates/common/session-info.md.liquid +58 -0
- data/lib/sxn/templates/errors.rb +36 -0
- data/lib/sxn/templates/javascript/README.md.liquid +59 -0
- data/lib/sxn/templates/javascript/session-info.md.liquid +206 -0
- data/lib/sxn/templates/rails/CLAUDE.md.liquid +78 -0
- data/lib/sxn/templates/rails/database.yml.liquid +31 -0
- data/lib/sxn/templates/rails/session-info.md.liquid +144 -0
- data/lib/sxn/templates/template_engine.rb +346 -0
- data/lib/sxn/templates/template_processor.rb +279 -0
- data/lib/sxn/templates/template_security.rb +410 -0
- data/lib/sxn/templates/template_variables.rb +713 -0
- data/lib/sxn/templates.rb +28 -0
- data/lib/sxn/ui/output.rb +103 -0
- data/lib/sxn/ui/progress_bar.rb +91 -0
- data/lib/sxn/ui/prompt.rb +116 -0
- data/lib/sxn/ui/table.rb +183 -0
- data/lib/sxn/ui.rb +12 -0
- data/lib/sxn/version.rb +5 -0
- data/lib/sxn.rb +63 -0
- data/rbs_collection.lock.yaml +180 -0
- data/rbs_collection.yaml +39 -0
- data/scripts/test.sh +31 -0
- data/sig/external/liquid.rbs +116 -0
- data/sig/external/thor.rbs +99 -0
- data/sig/external/tty.rbs +71 -0
- data/sig/sxn/cli.rbs +46 -0
- data/sig/sxn/commands/init.rbs +38 -0
- data/sig/sxn/commands/projects.rbs +72 -0
- data/sig/sxn/commands/rules.rbs +95 -0
- data/sig/sxn/commands/sessions.rbs +62 -0
- data/sig/sxn/commands/worktrees.rbs +82 -0
- data/sig/sxn/commands.rbs +6 -0
- data/sig/sxn/config/config_cache.rbs +67 -0
- data/sig/sxn/config/config_discovery.rbs +64 -0
- data/sig/sxn/config/config_validator.rbs +64 -0
- data/sig/sxn/config.rbs +74 -0
- data/sig/sxn/core/config_manager.rbs +67 -0
- data/sig/sxn/core/project_manager.rbs +52 -0
- data/sig/sxn/core/rules_manager.rbs +54 -0
- data/sig/sxn/core/session_manager.rbs +59 -0
- data/sig/sxn/core/worktree_manager.rbs +50 -0
- data/sig/sxn/core.rbs +87 -0
- data/sig/sxn/database/errors.rbs +37 -0
- data/sig/sxn/database/session_database.rbs +151 -0
- data/sig/sxn/database.rbs +83 -0
- data/sig/sxn/errors.rbs +89 -0
- data/sig/sxn/rules/base_rule.rbs +137 -0
- data/sig/sxn/rules/copy_files_rule.rbs +65 -0
- data/sig/sxn/rules/errors.rbs +33 -0
- data/sig/sxn/rules/project_detector.rbs +115 -0
- data/sig/sxn/rules/rules_engine.rbs +118 -0
- data/sig/sxn/rules/setup_commands_rule.rbs +60 -0
- data/sig/sxn/rules/template_rule.rbs +44 -0
- data/sig/sxn/rules.rbs +287 -0
- data/sig/sxn/runtime_validations.rbs +16 -0
- data/sig/sxn/security/secure_command_executor.rbs +63 -0
- data/sig/sxn/security/secure_file_copier.rbs +79 -0
- data/sig/sxn/security/secure_path_validator.rbs +30 -0
- data/sig/sxn/security.rbs +128 -0
- data/sig/sxn/templates/errors.rbs +43 -0
- data/sig/sxn/templates/template_engine.rbs +50 -0
- data/sig/sxn/templates/template_processor.rbs +44 -0
- data/sig/sxn/templates/template_security.rbs +62 -0
- data/sig/sxn/templates/template_variables.rbs +103 -0
- data/sig/sxn/templates.rbs +104 -0
- data/sig/sxn/ui/output.rbs +50 -0
- data/sig/sxn/ui/progress_bar.rbs +39 -0
- data/sig/sxn/ui/prompt.rbs +38 -0
- data/sig/sxn/ui/table.rbs +43 -0
- data/sig/sxn/ui.rbs +63 -0
- data/sig/sxn/version.rbs +5 -0
- data/sig/sxn.rbs +29 -0
- metadata +635 -0
data/sig/sxn/rules.rbs
ADDED
@@ -0,0 +1,287 @@
|
|
1
|
+
module Sxn
|
2
|
+
module Rules
|
3
|
+
# Abstract base class for all sxn rules with state machine and validation
|
4
|
+
class BaseRule
|
5
|
+
# Rule state constants
|
6
|
+
CREATED: String
|
7
|
+
VALIDATED: String
|
8
|
+
APPLYING: String
|
9
|
+
APPLIED: String
|
10
|
+
FAILED: String
|
11
|
+
SKIPPED: String
|
12
|
+
|
13
|
+
# Valid state transitions
|
14
|
+
VALID_TRANSITIONS: Hash[String, Array[String]]
|
15
|
+
|
16
|
+
type rule_config = Hash[String, untyped]
|
17
|
+
type change_record = Hash[Symbol, untyped]
|
18
|
+
type error_array = Array[StandardError]
|
19
|
+
type dependencies_array = Array[BaseRule]
|
20
|
+
type metadata_hash = Hash[Symbol, untyped]
|
21
|
+
|
22
|
+
attr_reader name: String
|
23
|
+
attr_reader state: String
|
24
|
+
attr_reader errors: error_array
|
25
|
+
attr_reader changes: Array[change_record]
|
26
|
+
attr_reader dependencies: dependencies_array
|
27
|
+
attr_reader metadata: metadata_hash
|
28
|
+
attr_reader created_at: Time
|
29
|
+
attr_reader updated_at: Time
|
30
|
+
attr_reader config: rule_config
|
31
|
+
attr_reader session_path: String
|
32
|
+
attr_reader project_path: String
|
33
|
+
|
34
|
+
def initialize: (String?, ?rule_config?, String?, String?, ?dependencies: dependencies_array) -> void
|
35
|
+
|
36
|
+
# State management methods
|
37
|
+
def state?: (String query_state) -> bool
|
38
|
+
def can_transition_to?: (String new_state) -> bool
|
39
|
+
def created?: () -> bool
|
40
|
+
def validated?: () -> bool
|
41
|
+
def applying?: () -> bool
|
42
|
+
def applied?: () -> bool
|
43
|
+
def failed?: () -> bool
|
44
|
+
def skipped?: () -> bool
|
45
|
+
|
46
|
+
# Public interface methods (abstract)
|
47
|
+
def validate: () -> void
|
48
|
+
def apply: () -> bool
|
49
|
+
def rollback: () -> void
|
50
|
+
def check: () -> bool
|
51
|
+
def preview: () -> Hash[Symbol, untyped]
|
52
|
+
def enabled?: () -> bool
|
53
|
+
def skip_if?: () -> bool
|
54
|
+
|
55
|
+
# Utility methods
|
56
|
+
def reset!: () -> void
|
57
|
+
def skip!: (?String reason) -> void
|
58
|
+
def to_h: () -> Hash[Symbol, untyped]
|
59
|
+
def summary: () -> Hash[Symbol, untyped]
|
60
|
+
def has_changes?: () -> bool
|
61
|
+
def error_messages: () -> Array[String]
|
62
|
+
def execution_duration: () -> Float?
|
63
|
+
|
64
|
+
def change_state!: (String new_state) -> void
|
65
|
+
def track_change: (Symbol action, String target, ?change_record details) -> void
|
66
|
+
def log: (Symbol level, String message, ?Hash[Symbol, untyped] context) -> void
|
67
|
+
def validate_rule_specific!: () -> void
|
68
|
+
def validate_paths!: () -> void
|
69
|
+
def validate_required_config!: (Array[String] required_keys) -> void
|
70
|
+
|
71
|
+
def initialize_with_legacy_args: (String? arg1, rule_config? arg2, String? arg3, String? arg4, dependencies: dependencies_array) -> void
|
72
|
+
def safe_pathname: (String? path) -> Pathname?
|
73
|
+
def validate_common_requirements!: () -> void
|
74
|
+
def record_execution_time: () -> void
|
75
|
+
end
|
76
|
+
|
77
|
+
# CopyFilesRule handles secure file copying operations
|
78
|
+
class CopyFilesRule < BaseRule
|
79
|
+
type file_config = Hash[String, untyped]
|
80
|
+
type permission_mode = Integer
|
81
|
+
type copy_operation_result = Hash[Symbol, untyped]
|
82
|
+
|
83
|
+
def initialize: (String?, ?Hash[String, untyped]?, String?, String?, ?dependencies: Array[BaseRule]) -> void
|
84
|
+
def validate: () -> void
|
85
|
+
def apply: () -> bool
|
86
|
+
def validate_rule_specific!: () -> void
|
87
|
+
def validate_file_config!: (file_config config, Integer index) -> void
|
88
|
+
def apply_file_operation: (file_config file_config, Integer index) -> copy_operation_result
|
89
|
+
def create_destination_directory: (String destination_path) -> void
|
90
|
+
def determine_file_permissions: (String source_path, file_config config) -> permission_mode
|
91
|
+
def copy_file_securely: (String source_path, String destination_path, permission_mode permissions, file_config config) -> copy_operation_result
|
92
|
+
def detect_sensitive_file?: (String file_path) -> bool
|
93
|
+
def backup_existing_file: (String file_path) -> String?
|
94
|
+
def validate_file_operation: (String source, String destination) -> void
|
95
|
+
end
|
96
|
+
|
97
|
+
# SetupCommandsRule executes shell commands during session setup with security controls
|
98
|
+
class SetupCommandsRule < BaseRule
|
99
|
+
type command_config = Hash[String, untyped]
|
100
|
+
type command_result = Hash[Symbol, untyped]
|
101
|
+
type environment_vars = Hash[String, String]
|
102
|
+
|
103
|
+
attr_reader command_executor: Sxn::Security::SecureCommandExecutor
|
104
|
+
|
105
|
+
def initialize: (String?, ?Hash[String, untyped]?, String?, String?, ?dependencies: Array[BaseRule]) -> void
|
106
|
+
def validate: () -> void
|
107
|
+
def apply: () -> bool
|
108
|
+
def preview: () -> Hash[Symbol, untyped]
|
109
|
+
def rollback: () -> void
|
110
|
+
def validate_rule_specific!: () -> void
|
111
|
+
def validate_command_config!: (command_config config, Integer index) -> void
|
112
|
+
def execute_command: (command_config config, Integer index) -> command_result
|
113
|
+
def build_command_array: (String | Array[String] command) -> Array[String]
|
114
|
+
def build_environment: (environment_vars? env_config) -> environment_vars
|
115
|
+
def should_ignore_failure?: (command_config config, command_result result) -> bool
|
116
|
+
def validate_command_security: (Array[String] command) -> void
|
117
|
+
def extract_command_info: (command_config config) -> Hash[Symbol, untyped]
|
118
|
+
end
|
119
|
+
|
120
|
+
# TemplateRule processes and applies template files using the secure template processor
|
121
|
+
class TemplateRule < BaseRule
|
122
|
+
type template_config = Hash[String, untyped]
|
123
|
+
type template_variables = Hash[Symbol, untyped]
|
124
|
+
|
125
|
+
attr_reader template_processor: Sxn::Templates::TemplateProcessor
|
126
|
+
attr_reader template_variables: Sxn::Templates::TemplateVariables
|
127
|
+
|
128
|
+
def initialize: (String?, ?Hash[String, untyped]?, String?, String?, ?dependencies: Array[BaseRule]) -> void
|
129
|
+
def validate: () -> void
|
130
|
+
def apply: () -> bool
|
131
|
+
def validate_rule_specific!: () -> void
|
132
|
+
def validate_template_config!: (template_config config, Integer index) -> void
|
133
|
+
def apply_template: (template_config config, Integer index) -> void
|
134
|
+
def build_template_variables: (template_config config) -> template_variables
|
135
|
+
def deep_merge: (Hash[untyped, untyped] hash1, Hash[untyped, untyped] hash2) -> Hash[untyped, untyped]
|
136
|
+
def extract_used_variables: (String template_content) -> Array[String]
|
137
|
+
end
|
138
|
+
|
139
|
+
# RulesEngine orchestrates rule execution with dependency resolution and parallel processing
|
140
|
+
class RulesEngine
|
141
|
+
type rule_instance = BaseRule
|
142
|
+
type execution_result = Hash[Symbol, untyped]
|
143
|
+
type rule_config = Hash[String, untyped]
|
144
|
+
type execution_stats = Hash[Symbol, untyped]
|
145
|
+
type dependency_graph = Hash[rule_instance, Array[rule_instance]]
|
146
|
+
|
147
|
+
attr_reader rules: Array[rule_instance]
|
148
|
+
attr_reader session_path: String
|
149
|
+
attr_reader project_path: String
|
150
|
+
attr_reader config: rule_config
|
151
|
+
attr_reader execution_history: Array[execution_result]
|
152
|
+
attr_reader stats: execution_stats
|
153
|
+
|
154
|
+
def initialize: (String session_path, String project_path, ?rule_config config) -> void
|
155
|
+
|
156
|
+
# Rule management
|
157
|
+
def add_rule: (rule_instance rule) -> void
|
158
|
+
def remove_rule: (String name) -> bool
|
159
|
+
def find_rule: (String name) -> rule_instance?
|
160
|
+
def clear_rules: () -> void
|
161
|
+
def rule_count: () -> Integer
|
162
|
+
def enabled_rules: () -> Array[rule_instance]
|
163
|
+
|
164
|
+
# Rule creation factory methods
|
165
|
+
def create_copy_files_rule: (String name, rule_config config) -> CopyFilesRule
|
166
|
+
def create_setup_commands_rule: (String name, rule_config config) -> SetupCommandsRule
|
167
|
+
def create_template_rule: (String name, rule_config config) -> TemplateRule
|
168
|
+
|
169
|
+
# Execution methods
|
170
|
+
def execute_all: (?validate_first: bool, ?parallel: bool, ?continue_on_error: bool) -> execution_result
|
171
|
+
def execute_rule: (String name) -> execution_result
|
172
|
+
def validate_all: () -> execution_result
|
173
|
+
def validate_rule: (String name) -> execution_result
|
174
|
+
def preview_changes: () -> Hash[String, untyped]
|
175
|
+
def rollback_all: () -> execution_result
|
176
|
+
def rollback_rule: (String name) -> execution_result
|
177
|
+
|
178
|
+
# Dependency management
|
179
|
+
def resolve_dependencies: () -> Array[rule_instance]
|
180
|
+
def build_dependency_graph: () -> dependency_graph
|
181
|
+
def detect_circular_dependencies: () -> Array[Array[rule_instance]]?
|
182
|
+
def topological_sort: () -> Array[rule_instance]
|
183
|
+
|
184
|
+
# State and status methods
|
185
|
+
def all_valid?: () -> bool
|
186
|
+
def any_failed?: () -> bool
|
187
|
+
def execution_summary: () -> execution_stats
|
188
|
+
def failed_rules: () -> Array[rule_instance]
|
189
|
+
def successful_rules: () -> Array[rule_instance]
|
190
|
+
def reset_all!: () -> void
|
191
|
+
|
192
|
+
# Configuration and discovery
|
193
|
+
def load_rules_from_config: (String config_path) -> Integer
|
194
|
+
def auto_discover_rules: () -> Integer
|
195
|
+
def suggest_rules: () -> Array[Hash[Symbol, untyped]]
|
196
|
+
def save_rules_config: (String config_path) -> bool
|
197
|
+
|
198
|
+
# Utility methods
|
199
|
+
def to_h: () -> Hash[Symbol, untyped]
|
200
|
+
def rule_names: () -> Array[String]
|
201
|
+
def rule_types: () -> Array[String]
|
202
|
+
def filter_rules: (String type) -> Array[rule_instance]
|
203
|
+
|
204
|
+
def execute_rules_sequentially: (Array[rule_instance] rules, bool validate_first, bool continue_on_error) -> execution_result
|
205
|
+
def execute_rules_in_parallel: (Array[rule_instance] rules, bool validate_first, bool continue_on_error) -> execution_result
|
206
|
+
def execute_single_rule: (rule_instance rule, bool validate_first) -> execution_result
|
207
|
+
def handle_rule_error: (rule_instance rule, StandardError error) -> execution_result
|
208
|
+
def update_stats: (rule_instance rule, execution_result result) -> void
|
209
|
+
def create_rule_instance: (String type, String name, rule_config config) -> rule_instance
|
210
|
+
def validate_rule_config: (String type, rule_config config) -> void
|
211
|
+
def log_execution: (Symbol level, String message, ?Hash[Symbol, untyped] context) -> void
|
212
|
+
def detect_project_type: () -> String
|
213
|
+
def suggest_rails_rules: () -> Array[Hash[Symbol, untyped]]
|
214
|
+
def suggest_js_rules: () -> Array[Hash[Symbol, untyped]]
|
215
|
+
def suggest_generic_rules: () -> Array[Hash[Symbol, untyped]]
|
216
|
+
def find_template_files: () -> Array[String]
|
217
|
+
def find_config_files: () -> Array[String]
|
218
|
+
end
|
219
|
+
|
220
|
+
# ProjectDetector analyzes directories to identify project types and configurations
|
221
|
+
class ProjectDetector
|
222
|
+
# Project type detection patterns
|
223
|
+
PROJECT_PATTERNS: Hash[String, Array[Hash[Symbol, untyped]]]
|
224
|
+
|
225
|
+
# Framework-specific detection
|
226
|
+
FRAMEWORK_PATTERNS: Hash[String, Hash[Symbol, untyped]]
|
227
|
+
|
228
|
+
# Language version detection
|
229
|
+
VERSION_PATTERNS: Hash[String, Array[Hash[Symbol, untyped]]]
|
230
|
+
|
231
|
+
type detection_result = Hash[Symbol, untyped]
|
232
|
+
type project_info = Hash[Symbol, untyped]
|
233
|
+
|
234
|
+
attr_reader path: Pathname
|
235
|
+
attr_reader cache: Hash[String, untyped]
|
236
|
+
|
237
|
+
def initialize: (String | Pathname path) -> void
|
238
|
+
|
239
|
+
def detect: () -> detection_result
|
240
|
+
def detect_project_type: () -> String
|
241
|
+
def detect_framework: () -> String?
|
242
|
+
def detect_language_version: () -> String?
|
243
|
+
def detect_build_tools: () -> Array[String]
|
244
|
+
def detect_dependencies: () -> Hash[String, Array[String]]
|
245
|
+
def confidence_score: () -> Float
|
246
|
+
def suggested_rules: () -> Array[String]
|
247
|
+
|
248
|
+
def self.detect_projects: (String | Pathname base_path, ?recursive: bool, ?max_depth: Integer) -> Array[project_info]
|
249
|
+
def self.quick_detect: (String | Pathname path) -> String
|
250
|
+
|
251
|
+
def analyze_file_patterns: () -> Hash[String, Integer]
|
252
|
+
def check_configuration_files: () -> Hash[String, untyped]
|
253
|
+
def analyze_package_managers: () -> Array[String]
|
254
|
+
def detect_rails_project: () -> Hash[Symbol, untyped]?
|
255
|
+
def detect_node_project: () -> Hash[Symbol, untyped]?
|
256
|
+
def detect_ruby_gem: () -> Hash[Symbol, untyped]?
|
257
|
+
def detect_python_project: () -> Hash[Symbol, untyped]?
|
258
|
+
def detect_go_project: () -> Hash[Symbol, untyped]?
|
259
|
+
def detect_rust_project: () -> Hash[Symbol, untyped]?
|
260
|
+
def parse_package_json: () -> Hash[String, untyped]?
|
261
|
+
def parse_gemspec: () -> Hash[String, untyped]?
|
262
|
+
def parse_cargo_toml: () -> Hash[String, untyped]?
|
263
|
+
def calculate_confidence: (Hash[String, Integer] scores) -> Float
|
264
|
+
def find_files: (String pattern, ?max_depth: Integer) -> Array[Pathname]
|
265
|
+
def file_exists?: (String relative_path) -> bool
|
266
|
+
end
|
267
|
+
|
268
|
+
# Rules errors (base class only - specific errors defined in sig/sxn/rules/errors.rbs)
|
269
|
+
class RuleError < Sxn::Error
|
270
|
+
end
|
271
|
+
|
272
|
+
class InvalidStateTransitionError < RuleError
|
273
|
+
end
|
274
|
+
|
275
|
+
class ConfigurationError < RuleError
|
276
|
+
end
|
277
|
+
|
278
|
+
class ExecutionTimeoutError < RuleError
|
279
|
+
end
|
280
|
+
|
281
|
+
class RollbackNotSupportedError < RuleError
|
282
|
+
end
|
283
|
+
|
284
|
+
class ExecutionCancelledError < RuleError
|
285
|
+
end
|
286
|
+
end
|
287
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Sxn
|
4
|
+
# Runtime validation helpers for Thor commands and type safety
|
5
|
+
module RuntimeValidations
|
6
|
+
def self.validate_thor_arguments: (String command_name, Array[untyped] args, Hash[Symbol, untyped] options, Hash[Symbol, untyped] validations) -> true
|
7
|
+
|
8
|
+
def self.validate_and_coerce_type: (untyped value, Class target_type, ?String? context) -> untyped
|
9
|
+
|
10
|
+
def self.validate_template_variables: (Hash[Symbol, untyped] variables) -> Hash[Symbol, Hash[Symbol, untyped]]
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def self.validate_option_type: (String command_name, Symbol key, untyped value, Symbol expected_type) -> void
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
# TypeProf 0.21.3
|
2
|
+
|
3
|
+
module Sxn
|
4
|
+
module Security
|
5
|
+
class SecureCommandExecutor
|
6
|
+
# Command execution result
|
7
|
+
class CommandResult
|
8
|
+
attr_reader exit_status: Integer
|
9
|
+
attr_reader stdout: String
|
10
|
+
attr_reader stderr: String
|
11
|
+
attr_reader command: Array[String]
|
12
|
+
attr_reader duration: Float
|
13
|
+
|
14
|
+
def initialize: (Integer exit_status, String? stdout, String? stderr, Array[String] command, Float duration) -> void
|
15
|
+
|
16
|
+
def success?: () -> bool
|
17
|
+
|
18
|
+
def failure?: () -> bool
|
19
|
+
|
20
|
+
def to_h: () -> Hash[Symbol, untyped]
|
21
|
+
end
|
22
|
+
|
23
|
+
# Whitelist of allowed commands with their expected paths
|
24
|
+
ALLOWED_COMMANDS: Hash[String, String | Array[String] | Symbol]
|
25
|
+
|
26
|
+
# Environment variables that are safe to preserve
|
27
|
+
SAFE_ENV_VARS: Array[String]
|
28
|
+
|
29
|
+
# Maximum command execution timeout (in seconds)
|
30
|
+
MAX_TIMEOUT: Integer
|
31
|
+
|
32
|
+
@project_root: String
|
33
|
+
@logger: untyped
|
34
|
+
@command_whitelist: Hash[String, String]
|
35
|
+
|
36
|
+
def initialize: (String project_root, ?logger: untyped) -> void
|
37
|
+
|
38
|
+
def execute: (Array[String] command, ?env: Hash[String | Symbol, String], ?timeout: Integer, ?chdir: String?) -> CommandResult
|
39
|
+
|
40
|
+
def command_allowed?: (Array[String] command) -> bool
|
41
|
+
|
42
|
+
def allowed_commands: () -> Array[String]
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
def validate_and_resolve_command: (Array[String] command) -> Array[String]
|
47
|
+
|
48
|
+
def build_command_whitelist: () -> Hash[String, String]
|
49
|
+
|
50
|
+
def resolve_rails_command: () -> String?
|
51
|
+
|
52
|
+
def resolve_project_executable: (String cmd_name) -> String?
|
53
|
+
|
54
|
+
def build_safe_environment: (Hash[String | Symbol, String] user_env) -> Hash[String, String]
|
55
|
+
|
56
|
+
def validate_work_directory: (String chdir) -> String
|
57
|
+
|
58
|
+
def execute_with_timeout: (Array[String] command, Hash[String, String] env, String chdir, Integer timeout) -> untyped
|
59
|
+
|
60
|
+
def audit_log: (String event, Array[String] command, String chdir, ?Hash[untyped, untyped] details) -> void
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
# TypeProf 0.21.3
|
2
|
+
|
3
|
+
module Sxn
|
4
|
+
module Security
|
5
|
+
class SecureFileCopier
|
6
|
+
# File operation result
|
7
|
+
class CopyResult
|
8
|
+
attr_reader source_path: String
|
9
|
+
attr_reader destination_path: String
|
10
|
+
attr_reader operation: Symbol
|
11
|
+
attr_reader encrypted: bool
|
12
|
+
attr_reader checksum: String?
|
13
|
+
attr_reader duration: Float
|
14
|
+
|
15
|
+
def initialize: (String source_path, String destination_path, Symbol operation, ?encrypted: bool, ?checksum: String?, ?duration: Float) -> void
|
16
|
+
|
17
|
+
def to_h: () -> Hash[Symbol, untyped]
|
18
|
+
end
|
19
|
+
|
20
|
+
# Patterns that identify sensitive files requiring special handling
|
21
|
+
SENSITIVE_FILE_PATTERNS: Array[Regexp]
|
22
|
+
|
23
|
+
# Default secure permissions for different file types
|
24
|
+
DEFAULT_PERMISSIONS: Hash[Symbol, Integer]
|
25
|
+
|
26
|
+
# Maximum file size for operations (100MB)
|
27
|
+
MAX_FILE_SIZE: Integer
|
28
|
+
|
29
|
+
@project_root: String
|
30
|
+
@path_validator: SecurePathValidator
|
31
|
+
@logger: untyped
|
32
|
+
@encryption_key: String?
|
33
|
+
|
34
|
+
def initialize: (String project_root, ?logger: untyped) -> void
|
35
|
+
|
36
|
+
def copy_file: (String source, String destination, ?permissions: Integer?, ?encrypt: bool, ?preserve_permissions: bool, ?create_directories: bool) -> CopyResult
|
37
|
+
|
38
|
+
def create_symlink: (String source, String destination, ?force: bool) -> CopyResult
|
39
|
+
|
40
|
+
def encrypt_file: (String file_path, ?key: String?) -> String
|
41
|
+
|
42
|
+
def decrypt_file: (String file_path, String key) -> bool
|
43
|
+
|
44
|
+
def sensitive_file?: (String file_path) -> bool
|
45
|
+
|
46
|
+
def secure_permissions?: (String file_path) -> bool
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
def normalize_path_for_result: (String path) -> String
|
51
|
+
|
52
|
+
def denormalize_path_for_operations: (String path) -> String
|
53
|
+
|
54
|
+
def validate_file_operation!: (String source_path, String destination_path) -> void
|
55
|
+
|
56
|
+
def determine_permissions: (String source_path, Integer? explicit_permissions, bool preserve_permissions) -> Integer
|
57
|
+
|
58
|
+
def create_destination_directory: (String destination_path) -> void
|
59
|
+
|
60
|
+
def copy_without_encryption: (String source_path, String destination_path, Integer permissions) -> void
|
61
|
+
|
62
|
+
def copy_with_encryption: (String source_path, String destination_path, Integer permissions) -> void
|
63
|
+
|
64
|
+
def encrypt_content: (String content, String key) -> String
|
65
|
+
|
66
|
+
def decrypt_content: (String encrypted_content, String key) -> String
|
67
|
+
|
68
|
+
def generate_encryption_key: () -> String
|
69
|
+
|
70
|
+
def generate_checksum: (String file_path) -> String?
|
71
|
+
|
72
|
+
def validate_file_exists!: (String file_path) -> void
|
73
|
+
|
74
|
+
def validate_file_readable!: (String file_path) -> void
|
75
|
+
|
76
|
+
def audit_log: (String event, untyped details) -> void
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# TypeProf 0.21.3
|
2
|
+
|
3
|
+
module Sxn
|
4
|
+
module Security
|
5
|
+
class SecurePathValidator
|
6
|
+
@project_root: String
|
7
|
+
@project_root_pathname: Pathname
|
8
|
+
|
9
|
+
def initialize: (String project_root) -> void
|
10
|
+
|
11
|
+
def validate_path: (String path, ?allow_creation: bool) -> String
|
12
|
+
|
13
|
+
def validate_file_operation: (String source, String destination, ?allow_creation: bool) -> [String, String]
|
14
|
+
|
15
|
+
def within_boundaries?: (String path) -> bool
|
16
|
+
|
17
|
+
attr_reader project_root: String
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def validate_path_components!: (String path) -> void
|
22
|
+
|
23
|
+
def validate_within_boundaries!: (String absolute_path) -> void
|
24
|
+
|
25
|
+
def validate_symlink_safety!: (String path) -> void
|
26
|
+
|
27
|
+
def normalize_path_manually: (String path) -> String
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,128 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Sxn
|
4
|
+
module Security
|
5
|
+
# SecureCommandExecutor provides secure command execution with strict controls
|
6
|
+
class SecureCommandExecutor
|
7
|
+
# Command execution result
|
8
|
+
class CommandResult
|
9
|
+
attr_reader exit_status: Integer
|
10
|
+
attr_reader stdout: String
|
11
|
+
attr_reader stderr: String
|
12
|
+
attr_reader command: Array[String]
|
13
|
+
attr_reader duration: Float
|
14
|
+
|
15
|
+
def initialize: (Integer exit_status, String? stdout, String? stderr, Array[String] command, Float duration) -> void
|
16
|
+
def success?: () -> bool
|
17
|
+
def failure?: () -> bool
|
18
|
+
def to_h: () -> Hash[Symbol, untyped]
|
19
|
+
end
|
20
|
+
|
21
|
+
attr_reader project_root: String
|
22
|
+
attr_reader logger: Logger?
|
23
|
+
attr_reader command_whitelist: Hash[String, String]
|
24
|
+
|
25
|
+
def initialize: (String project_root, ?logger: Logger?) -> void
|
26
|
+
|
27
|
+
def execute: (Array[String] command, ?env: Hash[String | Symbol, String], ?timeout: Integer, ?chdir: String?) -> CommandResult
|
28
|
+
def command_allowed?: (Array[String] command) -> bool
|
29
|
+
def allowed_commands: () -> Array[String]
|
30
|
+
|
31
|
+
def validate_and_resolve_command: (Array[String] command) -> Array[String]
|
32
|
+
def build_command_whitelist: () -> Hash[String, String]
|
33
|
+
def resolve_rails_command: () -> String?
|
34
|
+
def resolve_project_executable: (String cmd_name) -> String?
|
35
|
+
def build_safe_environment: (Hash[String | Symbol, String] user_env) -> Hash[String, String]
|
36
|
+
def validate_work_directory: (String chdir) -> String
|
37
|
+
def execute_with_timeout: (Array[String] command, Hash[String, String] env, String chdir, Integer timeout) -> OpenStruct
|
38
|
+
def audit_log: (String event, Array[String] command, String chdir, ?Hash[Symbol, untyped] details) -> void
|
39
|
+
end
|
40
|
+
|
41
|
+
# SecureFileCopier provides secure file copying operations with strict security controls
|
42
|
+
class SecureFileCopier
|
43
|
+
# File operation result
|
44
|
+
class CopyResult
|
45
|
+
attr_reader source_path: String
|
46
|
+
attr_reader destination_path: String
|
47
|
+
attr_reader operation: Symbol
|
48
|
+
attr_reader encrypted: bool
|
49
|
+
attr_reader checksum: String?
|
50
|
+
attr_reader duration: Float
|
51
|
+
|
52
|
+
def initialize: (String source_path, String destination_path, Symbol operation, ?encrypted: bool, ?checksum: String?, ?duration: Float) -> void
|
53
|
+
def to_h: () -> Hash[Symbol, untyped]
|
54
|
+
end
|
55
|
+
|
56
|
+
attr_reader project_root: String
|
57
|
+
attr_reader path_validator: SecurePathValidator
|
58
|
+
attr_reader logger: Logger?
|
59
|
+
attr_reader encryption_key: String?
|
60
|
+
|
61
|
+
def initialize: (String project_root, ?logger: Logger?) -> void
|
62
|
+
|
63
|
+
def copy_file: (String source, String destination, ?permissions: Integer?, ?encrypt: bool, ?preserve_permissions: bool, ?create_directories: bool) -> CopyResult
|
64
|
+
def create_symlink: (String source, String destination, ?force: bool) -> CopyResult
|
65
|
+
def encrypt_file: (String file_path, ?key: String?) -> String
|
66
|
+
def decrypt_file: (String file_path, String key) -> bool
|
67
|
+
def sensitive_file?: (String file_path) -> bool
|
68
|
+
def secure_permissions?: (String file_path) -> bool
|
69
|
+
|
70
|
+
def normalize_path_for_result: (String path) -> String
|
71
|
+
def denormalize_path_for_operations: (String path) -> String
|
72
|
+
def validate_file_operation!: (String source_path, String destination_path) -> void
|
73
|
+
def determine_permissions: (String source_path, Integer? explicit_permissions, bool preserve_permissions) -> Integer
|
74
|
+
def create_destination_directory: (String destination_path) -> void
|
75
|
+
def copy_without_encryption: (String source_path, String destination_path, Integer permissions) -> void
|
76
|
+
def copy_with_encryption: (String source_path, String destination_path, Integer permissions) -> void
|
77
|
+
def encrypt_content: (String content, String key) -> String
|
78
|
+
def decrypt_content: (String encrypted_content, String key) -> String
|
79
|
+
def generate_encryption_key: () -> String
|
80
|
+
def generate_checksum: (String file_path) -> String?
|
81
|
+
def validate_file_exists!: (String file_path) -> void
|
82
|
+
def validate_file_readable!: (String file_path) -> void
|
83
|
+
def audit_log: (String event, CopyResult | Hash[Symbol, untyped] details) -> void
|
84
|
+
end
|
85
|
+
|
86
|
+
# SecurePathValidator provides security controls for file system path operations
|
87
|
+
class SecurePathValidator
|
88
|
+
attr_reader project_root: String
|
89
|
+
attr_reader project_root_pathname: Pathname
|
90
|
+
|
91
|
+
def initialize: (String project_root) -> void
|
92
|
+
|
93
|
+
def validate_path: (String path, ?allow_creation: bool) -> String
|
94
|
+
def validate_file_operation: (String source, String destination, ?allow_creation: bool) -> [String, String]
|
95
|
+
def within_boundaries?: (String path) -> bool
|
96
|
+
|
97
|
+
def validate_path_components!: (String path) -> void
|
98
|
+
def validate_within_boundaries!: (String absolute_path) -> void
|
99
|
+
def validate_symlink_safety!: (String path) -> void
|
100
|
+
def normalize_path_manually: (String path) -> String
|
101
|
+
end
|
102
|
+
|
103
|
+
# Security error classes
|
104
|
+
class Error < Sxn::Error
|
105
|
+
end
|
106
|
+
|
107
|
+
class PathValidationError < Error
|
108
|
+
end
|
109
|
+
|
110
|
+
class CommandExecutionError < Error
|
111
|
+
end
|
112
|
+
|
113
|
+
class SecurityError < Error
|
114
|
+
end
|
115
|
+
|
116
|
+
class PathTraversalError < Error
|
117
|
+
end
|
118
|
+
|
119
|
+
class CommandInjectionError < Error
|
120
|
+
end
|
121
|
+
|
122
|
+
class FileSecurityError < Error
|
123
|
+
end
|
124
|
+
|
125
|
+
class ValidationError < Error
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# TypeProf 0.21.3
|
2
|
+
|
3
|
+
module Sxn
|
4
|
+
module Templates
|
5
|
+
module Errors
|
6
|
+
# Base class for template-related errors
|
7
|
+
class TemplateError < Sxn::Error
|
8
|
+
end
|
9
|
+
|
10
|
+
# Raised when template syntax is invalid
|
11
|
+
class TemplateSyntaxError < TemplateError
|
12
|
+
end
|
13
|
+
|
14
|
+
# Raised when template processing fails
|
15
|
+
class TemplateProcessingError < TemplateError
|
16
|
+
end
|
17
|
+
|
18
|
+
# Raised when template file is not found
|
19
|
+
class TemplateNotFoundError < TemplateError
|
20
|
+
end
|
21
|
+
|
22
|
+
# Raised when template exceeds size limits
|
23
|
+
class TemplateTooLargeError < TemplateError
|
24
|
+
end
|
25
|
+
|
26
|
+
# Raised when template processing times out
|
27
|
+
class TemplateTimeoutError < TemplateError
|
28
|
+
end
|
29
|
+
|
30
|
+
# Raised when template contains security violations
|
31
|
+
class TemplateSecurityError < TemplateError
|
32
|
+
end
|
33
|
+
|
34
|
+
# Raised when template rendering encounters errors
|
35
|
+
class TemplateRenderError < TemplateError
|
36
|
+
end
|
37
|
+
|
38
|
+
# Raised when template variable collection fails
|
39
|
+
class TemplateVariableError < TemplateError
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|