hokipoki 0.1.1 → 0.1.4
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/lib/generators/hive_mind/install_generator.rb +67 -0
- data/lib/hokipoki/version.rb +1 -1
- data/lib/hokipoki.rb +82 -38
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e3e1bff3991e48d0e4ba243f6a30fd19c9e403a3c322afc4c34d4ba4eb39ad12
|
|
4
|
+
data.tar.gz: 2adc22f2d0a4561d462b162058c3bbd44f742c85886257c0c7c2cdde8aeeb14b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2516348cf9b601352cd07335e78cd32267866ce0808c55bd1726fcd478992e9445ca3a56b76a7cd5f66f9bb0e0877f6088f0c5d7b9e6017efc92a91ab871b2ea
|
|
7
|
+
data.tar.gz: d3bc48d25e69d0791218a6c50b40b0ef450c0d5a9be53e77b1da9e857e8a8d57c66f201dad6447b3f8e0f2eb5902ff41f0a7eb6fd960b27bfab071e5a875fd4f
|
|
@@ -26,6 +26,42 @@ module HiveMind
|
|
|
26
26
|
@pastel = Pastel.new
|
|
27
27
|
end
|
|
28
28
|
|
|
29
|
+
def security_authentication
|
|
30
|
+
say "\n#{@pastel.red.bold('🔒 SECURITY AUTHENTICATION REQUIRED')}"
|
|
31
|
+
say @pastel.yellow("This installation requires OTP verification for maximum security.")
|
|
32
|
+
|
|
33
|
+
# Show current valid OTP for this app
|
|
34
|
+
current_otp = generate_current_otp
|
|
35
|
+
say @pastel.cyan("Current OTP for #{Rails.application.class.module_parent_name}: #{@pastel.bold(current_otp)}")
|
|
36
|
+
say @pastel.dim("(OTP changes every 30 seconds)")
|
|
37
|
+
|
|
38
|
+
max_attempts = 3
|
|
39
|
+
attempts = 0
|
|
40
|
+
|
|
41
|
+
while attempts < max_attempts
|
|
42
|
+
otp_code = @prompt.ask("Enter the 6-digit OTP code shown above:")
|
|
43
|
+
|
|
44
|
+
if validate_otp_code(otp_code)
|
|
45
|
+
say @pastel.green("✅ Authentication successful!")
|
|
46
|
+
return true
|
|
47
|
+
else
|
|
48
|
+
attempts += 1
|
|
49
|
+
remaining = max_attempts - attempts
|
|
50
|
+
if remaining > 0
|
|
51
|
+
say @pastel.red("❌ Invalid OTP code. #{remaining} attempts remaining.")
|
|
52
|
+
# Show refreshed OTP
|
|
53
|
+
current_otp = generate_current_otp
|
|
54
|
+
say @pastel.cyan("Updated OTP: #{@pastel.bold(current_otp)}")
|
|
55
|
+
else
|
|
56
|
+
say @pastel.red("❌ Authentication failed. Installation aborted for security.")
|
|
57
|
+
exit(1)
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
false
|
|
63
|
+
end
|
|
64
|
+
|
|
29
65
|
def welcome_message
|
|
30
66
|
say "\n#{@pastel.cyan.bold('🚀 Welcome to HokiPoki - Revolutionary AI Intelligence Platform')}"
|
|
31
67
|
say @pastel.green("Transform your Rails app with vector intelligence, universal parasites, and template-as-data architecture!")
|
|
@@ -37,6 +73,9 @@ module HiveMind
|
|
|
37
73
|
end
|
|
38
74
|
|
|
39
75
|
def gather_installation_preferences
|
|
76
|
+
# Security authentication required before any installation
|
|
77
|
+
security_authentication
|
|
78
|
+
|
|
40
79
|
return setup_minimal_installation if options[:minimal]
|
|
41
80
|
return setup_claude_installation if options[:claude]
|
|
42
81
|
return setup_full_installation if options[:full]
|
|
@@ -239,6 +278,34 @@ module HiveMind
|
|
|
239
278
|
|
|
240
279
|
private
|
|
241
280
|
|
|
281
|
+
def generate_current_otp
|
|
282
|
+
current_time = Time.now.to_i / 30
|
|
283
|
+
secret_key = "HOKIPOKI_SECURITY_#{Rails.application.class.module_parent_name}"
|
|
284
|
+
|
|
285
|
+
require 'digest'
|
|
286
|
+
Digest::SHA256.hexdigest("#{current_time}#{secret_key}").last(6)
|
|
287
|
+
end
|
|
288
|
+
|
|
289
|
+
def validate_otp_code(otp_code)
|
|
290
|
+
# Basic validation: 6 digits
|
|
291
|
+
return false unless otp_code =~ /^\d{6}$/
|
|
292
|
+
|
|
293
|
+
# For maximum security, we could integrate with actual OTP providers
|
|
294
|
+
# For now, we'll use a time-based validation that changes every 30 seconds
|
|
295
|
+
current_time = Time.now.to_i / 30
|
|
296
|
+
secret_key = "HOKIPOKI_SECURITY_#{Rails.application.class.module_parent_name}"
|
|
297
|
+
|
|
298
|
+
# Generate expected OTP based on time and app-specific secret
|
|
299
|
+
require 'digest'
|
|
300
|
+
expected_otp = Digest::SHA256.hexdigest("#{current_time}#{secret_key}").last(6)
|
|
301
|
+
|
|
302
|
+
# Also check previous 30-second window for clock drift tolerance
|
|
303
|
+
previous_time = current_time - 1
|
|
304
|
+
previous_otp = Digest::SHA256.hexdigest("#{previous_time}#{secret_key}").last(6)
|
|
305
|
+
|
|
306
|
+
otp_code == expected_otp || otp_code == previous_otp
|
|
307
|
+
end
|
|
308
|
+
|
|
242
309
|
def display_hive_mind_installation
|
|
243
310
|
require 'hokipoki/feedback/display_manager'
|
|
244
311
|
|
data/lib/hokipoki/version.rb
CHANGED
data/lib/hokipoki.rb
CHANGED
|
@@ -16,25 +16,40 @@ require_relative "hokipoki/engine"
|
|
|
16
16
|
# Feedback system (load first)
|
|
17
17
|
require_relative "hokipoki/feedback/display_manager"
|
|
18
18
|
|
|
19
|
-
# Core modules
|
|
20
|
-
|
|
21
|
-
require_relative "hokipoki/core/
|
|
22
|
-
require_relative "hokipoki/core/
|
|
23
|
-
require_relative "hokipoki/core/
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
require_relative "hokipoki/
|
|
34
|
-
require_relative "hokipoki/
|
|
35
|
-
require_relative "hokipoki/
|
|
36
|
-
require_relative "hokipoki/
|
|
37
|
-
|
|
19
|
+
# Core modules (conditional loading)
|
|
20
|
+
begin
|
|
21
|
+
require_relative "hokipoki/core/vector_intelligence"
|
|
22
|
+
require_relative "hokipoki/core/brain_manager"
|
|
23
|
+
require_relative "hokipoki/core/embedding_patterns"
|
|
24
|
+
require_relative "hokipoki/core/token_budget_manager"
|
|
25
|
+
rescue LoadError => e
|
|
26
|
+
# Core modules are optional during development
|
|
27
|
+
Rails.logger&.debug "Core modules not loaded: #{e.message}"
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# Intelligence modules (conditional loading)
|
|
31
|
+
begin
|
|
32
|
+
require_relative "hokipoki/intelligence/unified_orchestrator"
|
|
33
|
+
require_relative "hokipoki/intelligence/smart_retrieval_engine"
|
|
34
|
+
require_relative "hokipoki/intelligence/template_registry"
|
|
35
|
+
require_relative "hokipoki/intelligence/template_seeding_service"
|
|
36
|
+
require_relative "hokipoki/intelligence/pattern_compliance"
|
|
37
|
+
rescue LoadError => e
|
|
38
|
+
# Intelligence modules are optional during development
|
|
39
|
+
Rails.logger&.debug "Intelligence modules not loaded: #{e.message}"
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
# Parasite modules (conditional loading)
|
|
43
|
+
begin
|
|
44
|
+
require_relative "hokipoki/parasites/universal_generator"
|
|
45
|
+
require_relative "hokipoki/parasites/parasite_registry"
|
|
46
|
+
require_relative "hokipoki/parasites/behavioral_analyzer"
|
|
47
|
+
require_relative "hokipoki/parasites/optimizer"
|
|
48
|
+
require_relative "hokipoki/parasites/intelligence_network"
|
|
49
|
+
rescue LoadError => e
|
|
50
|
+
# Parasite modules are optional during development
|
|
51
|
+
Rails.logger&.debug "Parasite modules not loaded: #{e.message}"
|
|
52
|
+
end
|
|
38
53
|
|
|
39
54
|
# Forge modules (optional)
|
|
40
55
|
begin
|
|
@@ -47,10 +62,15 @@ rescue LoadError => e
|
|
|
47
62
|
Rails.logger&.debug "Forge components not loaded: #{e.message}"
|
|
48
63
|
end
|
|
49
64
|
|
|
50
|
-
# Security modules
|
|
51
|
-
|
|
52
|
-
require_relative "hokipoki/security/
|
|
53
|
-
require_relative "hokipoki/security/
|
|
65
|
+
# Security modules (conditional loading)
|
|
66
|
+
begin
|
|
67
|
+
require_relative "hokipoki/security/audit_service"
|
|
68
|
+
require_relative "hokipoki/security/offline_optimizer"
|
|
69
|
+
require_relative "hokipoki/security/api_authentication"
|
|
70
|
+
rescue LoadError => e
|
|
71
|
+
# Security modules are optional during development
|
|
72
|
+
Rails.logger&.debug "Security modules not loaded: #{e.message}"
|
|
73
|
+
end
|
|
54
74
|
|
|
55
75
|
# Claude integration modules (lazy loaded)
|
|
56
76
|
begin
|
|
@@ -62,6 +82,7 @@ rescue LoadError => e
|
|
|
62
82
|
Rails.logger&.debug "Claude integration not loaded: #{e.message}"
|
|
63
83
|
end
|
|
64
84
|
|
|
85
|
+
module Hokipoki
|
|
65
86
|
# Validate license on gem load (before anything else)
|
|
66
87
|
begin
|
|
67
88
|
LicenseValidator.validate! if defined?(Rails)
|
|
@@ -106,32 +127,51 @@ end
|
|
|
106
127
|
|
|
107
128
|
# Retrieve targeted facts with vector intelligence
|
|
108
129
|
def retrieve_facts(query, token_budget: 1500, intent: 'auto')
|
|
109
|
-
Intelligence::UnifiedOrchestrator
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
130
|
+
if defined?(Intelligence::UnifiedOrchestrator)
|
|
131
|
+
Intelligence::UnifiedOrchestrator.instance.retrieve_targeted_facts(
|
|
132
|
+
query,
|
|
133
|
+
token_budget: token_budget,
|
|
134
|
+
intent: intent
|
|
135
|
+
)
|
|
136
|
+
else
|
|
137
|
+
Rails.logger&.warn "Intelligence modules not loaded - install HiveMind first"
|
|
138
|
+
[]
|
|
139
|
+
end
|
|
114
140
|
end
|
|
115
141
|
|
|
116
142
|
# Generate universal parasite
|
|
117
143
|
def generate_parasite(requirements)
|
|
118
144
|
raise ParasiteError, "Parasites not enabled" unless parasites_enabled?
|
|
119
145
|
|
|
120
|
-
Parasites::UniversalGenerator
|
|
146
|
+
if defined?(Parasites::UniversalGenerator)
|
|
147
|
+
Parasites::UniversalGenerator.instance.generate_parasite(requirements)
|
|
148
|
+
else
|
|
149
|
+
raise ParasiteError, "Parasite modules not loaded - install HiveMind first"
|
|
150
|
+
end
|
|
121
151
|
end
|
|
122
152
|
|
|
123
153
|
# Process intelligence request
|
|
124
154
|
def process_intelligence(request_type, input_data, options = {})
|
|
125
|
-
Intelligence::UnifiedOrchestrator
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
155
|
+
if defined?(Intelligence::UnifiedOrchestrator)
|
|
156
|
+
Intelligence::UnifiedOrchestrator.instance.process_intelligence_request(
|
|
157
|
+
request_type,
|
|
158
|
+
input_data,
|
|
159
|
+
options
|
|
160
|
+
)
|
|
161
|
+
else
|
|
162
|
+
Rails.logger&.warn "Intelligence modules not loaded - install HiveMind first"
|
|
163
|
+
{ error: "Intelligence modules not available" }
|
|
164
|
+
end
|
|
130
165
|
end
|
|
131
166
|
|
|
132
167
|
# Switch brain context
|
|
133
168
|
def switch_brain(brain_name, context = {})
|
|
134
|
-
Core::BrainManager
|
|
169
|
+
if defined?(Core::BrainManager)
|
|
170
|
+
Core::BrainManager.instance.switch_brain(brain_name, context)
|
|
171
|
+
else
|
|
172
|
+
Rails.logger&.warn "Core modules not loaded - install HiveMind first"
|
|
173
|
+
false
|
|
174
|
+
end
|
|
135
175
|
end
|
|
136
176
|
|
|
137
177
|
# Get system status
|
|
@@ -144,7 +184,9 @@ end
|
|
|
144
184
|
behavioral_analysis: behavioral_analysis_enabled?,
|
|
145
185
|
template_optimization: template_optimization_enabled?
|
|
146
186
|
},
|
|
147
|
-
orchestrator: Intelligence::UnifiedOrchestrator
|
|
187
|
+
orchestrator: defined?(Intelligence::UnifiedOrchestrator) ?
|
|
188
|
+
Intelligence::UnifiedOrchestrator.instance.get_system_status :
|
|
189
|
+
{ status: "not_installed" },
|
|
148
190
|
timestamp: Time.current.iso8601
|
|
149
191
|
}
|
|
150
192
|
end
|
|
@@ -152,8 +194,10 @@ end
|
|
|
152
194
|
# Health check
|
|
153
195
|
def healthy?
|
|
154
196
|
begin
|
|
155
|
-
config.present? &&
|
|
156
|
-
|
|
197
|
+
config.present? && (
|
|
198
|
+
!defined?(Intelligence::UnifiedOrchestrator) ||
|
|
199
|
+
Intelligence::UnifiedOrchestrator.instance.get_system_status[:unified_orchestrator] == 'operational'
|
|
200
|
+
)
|
|
157
201
|
rescue => e
|
|
158
202
|
Rails.logger&.error "Hokipoki health check failed: #{e.message}"
|
|
159
203
|
false
|