hokipoki 0.1.1 → 0.1.2
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/hokipoki/version.rb +1 -1
- metadata +18 -77
- data/LICENSE +0 -26
- data/lib/generators/hive_mind/install_generator.rb +0 -761
- data/lib/hokipoki/claude/auto_loader.rb +0 -162
- data/lib/hokipoki/claude/connection_manager.rb +0 -382
- data/lib/hokipoki/claude/parasite.rb +0 -333
- data/lib/hokipoki/configuration.rb +0 -187
- data/lib/hokipoki/engine.rb +0 -122
- data/lib/hokipoki/feedback/ascii_banners.rb +0 -108
- data/lib/hokipoki/feedback/display_manager.rb +0 -436
- data/lib/hokipoki/intelligence/smart_retrieval_engine.rb +0 -401
- data/lib/hokipoki/intelligence/unified_orchestrator.rb +0 -395
- data/lib/hokipoki/license_validator.rb +0 -296
- data/lib/hokipoki/parasites/universal_generator.rb +0 -662
- data/lib/hokipoki/railtie.rb +0 -34
- data/lib/hokipoki.rb +0 -176
|
@@ -1,761 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'rails/generators'
|
|
4
|
-
require 'rails/generators/active_record'
|
|
5
|
-
require 'tty-prompt'
|
|
6
|
-
require 'pastel'
|
|
7
|
-
|
|
8
|
-
module HiveMind
|
|
9
|
-
class InstallGenerator < Rails::Generators::Base
|
|
10
|
-
include ActiveRecord::Generators::Migration
|
|
11
|
-
|
|
12
|
-
source_root File.expand_path('templates', __dir__)
|
|
13
|
-
|
|
14
|
-
class_option :minimal, type: :boolean, default: false, desc: 'Install minimal HiveMind setup'
|
|
15
|
-
class_option :full, type: :boolean, default: false, desc: 'Install complete revolutionary stack'
|
|
16
|
-
class_option :claude, type: :boolean, default: false, desc: 'Install HiveMind + Claude integration'
|
|
17
|
-
class_option :parasites, type: :boolean, default: nil, desc: 'Enable parasites system'
|
|
18
|
-
class_option :forge, type: :boolean, default: nil, desc: 'Enable forge components'
|
|
19
|
-
class_option :security, type: :boolean, default: nil, desc: 'Enable security features'
|
|
20
|
-
class_option :skip_migrations, type: :boolean, default: false, desc: 'Skip database migrations'
|
|
21
|
-
class_option :skip_config, type: :boolean, default: false, desc: 'Skip configuration files'
|
|
22
|
-
|
|
23
|
-
def initialize(*args)
|
|
24
|
-
super
|
|
25
|
-
@prompt = TTY::Prompt.new
|
|
26
|
-
@pastel = Pastel.new
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
def welcome_message
|
|
30
|
-
say "\n#{@pastel.cyan.bold('🚀 Welcome to HokiPoki - Revolutionary AI Intelligence Platform')}"
|
|
31
|
-
say @pastel.green("Transform your Rails app with vector intelligence, universal parasites, and template-as-data architecture!")
|
|
32
|
-
say "\n#{@pastel.yellow('Installation Options:')}"
|
|
33
|
-
say " #{@pastel.blue('--minimal')} : Core vector DB + smart retrieval (minimal)"
|
|
34
|
-
say " #{@pastel.blue('--claude')} : HiveMind + Claude integration (recommended for Claude users)"
|
|
35
|
-
say " #{@pastel.blue('--full')} : Everything - HiveMind + Parasites + Forge + Security (maximum power)"
|
|
36
|
-
say " #{@pastel.blue('Interactive')}: Choose components (recommended)\n"
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
def gather_installation_preferences
|
|
40
|
-
return setup_minimal_installation if options[:minimal]
|
|
41
|
-
return setup_claude_installation if options[:claude]
|
|
42
|
-
return setup_full_installation if options[:full]
|
|
43
|
-
|
|
44
|
-
setup_interactive_installation
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
def validate_requirements
|
|
48
|
-
check_ruby_version
|
|
49
|
-
check_rails_version
|
|
50
|
-
check_database_support
|
|
51
|
-
check_redis_availability if @config[:redis_required]
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
def create_configuration_files
|
|
55
|
-
return if options[:skip_config]
|
|
56
|
-
|
|
57
|
-
say "\n#{@pastel.cyan('📝 Creating configuration files...')}"
|
|
58
|
-
|
|
59
|
-
template 'initializers/hokipoki.rb.tt', 'config/initializers/hokipoki.rb'
|
|
60
|
-
|
|
61
|
-
if @config[:lm_studio_integration]
|
|
62
|
-
template 'initializers/lm_studio.rb.tt', 'config/initializers/lm_studio.rb'
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
create_configuration_yml
|
|
66
|
-
create_brain_configurations if @config[:enable_brains]
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
def setup_database_migrations
|
|
70
|
-
return if options[:skip_migrations]
|
|
71
|
-
|
|
72
|
-
say "\n#{@pastel.cyan('🗄️ Setting up database migrations...')}"
|
|
73
|
-
|
|
74
|
-
# Core tables
|
|
75
|
-
migration_template 'migrations/enable_pgvector.rb.tt', 'db/migrate/enable_pgvector.rb'
|
|
76
|
-
migration_template 'migrations/create_documents.rb.tt', 'db/migrate/create_documents.rb'
|
|
77
|
-
migration_template 'migrations/create_intelligence_templates.rb.tt', 'db/migrate/create_intelligence_templates.rb'
|
|
78
|
-
|
|
79
|
-
# Parasite tables
|
|
80
|
-
if @config[:enable_parasites]
|
|
81
|
-
migration_template 'migrations/create_custom_parasites.rb.tt', 'db/migrate/create_custom_parasites.rb'
|
|
82
|
-
migration_template 'migrations/create_llm_behavioral_patterns.rb.tt', 'db/migrate/create_llm_behavioral_patterns.rb'
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
# Brain management tables
|
|
86
|
-
if @config[:enable_brains]
|
|
87
|
-
migration_template 'migrations/create_brain_configurations.rb.tt', 'db/migrate/create_brain_configurations.rb'
|
|
88
|
-
end
|
|
89
|
-
|
|
90
|
-
# Security tables
|
|
91
|
-
if @config[:enable_security]
|
|
92
|
-
migration_template 'migrations/create_security_audit_logs.rb.tt', 'db/migrate/create_security_audit_logs.rb'
|
|
93
|
-
end
|
|
94
|
-
end
|
|
95
|
-
|
|
96
|
-
def create_application_components
|
|
97
|
-
say "\n#{@pastel.cyan('🏗️ Creating application components...')}"
|
|
98
|
-
|
|
99
|
-
# Create models
|
|
100
|
-
template 'app/models/hokipoki/document.rb.tt', 'app/models/hokipoki/document.rb'
|
|
101
|
-
template 'app/models/hokipoki/intelligence_template.rb.tt', 'app/models/hokipoki/intelligence_template.rb'
|
|
102
|
-
|
|
103
|
-
if @config[:enable_parasites]
|
|
104
|
-
template 'app/models/hokipoki/custom_parasite.rb.tt', 'app/models/hokipoki/custom_parasite.rb'
|
|
105
|
-
end
|
|
106
|
-
|
|
107
|
-
# Create controllers
|
|
108
|
-
template 'app/controllers/hokipoki/api/documents_controller.rb.tt', 'app/controllers/hokipoki/api/documents_controller.rb'
|
|
109
|
-
template 'app/controllers/hokipoki/api/vector_search_controller.rb.tt', 'app/controllers/hokipoki/api/vector_search_controller.rb'
|
|
110
|
-
|
|
111
|
-
if @config[:enable_parasites]
|
|
112
|
-
template 'app/controllers/hokipoki/api/parasites_controller.rb.tt', 'app/controllers/hokipoki/api/parasites_controller.rb'
|
|
113
|
-
end
|
|
114
|
-
|
|
115
|
-
# Create services
|
|
116
|
-
create_service_components
|
|
117
|
-
|
|
118
|
-
# Create jobs
|
|
119
|
-
if @config[:background_processing]
|
|
120
|
-
template 'app/jobs/hokipoki/document_processor_job.rb.tt', 'app/jobs/hokipoki/document_processor_job.rb'
|
|
121
|
-
|
|
122
|
-
if @config[:enable_parasites]
|
|
123
|
-
template 'app/jobs/hokipoki/parasite_optimization_job.rb.tt', 'app/jobs/hokipoki/parasite_optimization_job.rb'
|
|
124
|
-
end
|
|
125
|
-
end
|
|
126
|
-
end
|
|
127
|
-
|
|
128
|
-
def setup_routing
|
|
129
|
-
say "\n#{@pastel.cyan('🛣️ Setting up routes...')}"
|
|
130
|
-
|
|
131
|
-
route_content = generate_route_content
|
|
132
|
-
inject_into_file 'config/routes.rb', after: "Rails.application.routes.draw do\n" do
|
|
133
|
-
route_content
|
|
134
|
-
end
|
|
135
|
-
end
|
|
136
|
-
|
|
137
|
-
def create_cli_tools
|
|
138
|
-
if @config[:enable_cli_tools]
|
|
139
|
-
say "\n#{@pastel.cyan('🔧 Creating CLI tools...')}"
|
|
140
|
-
|
|
141
|
-
template 'bin/hive_mind_claude.tt', 'bin/hive_mind_claude'
|
|
142
|
-
chmod 'bin/hive_mind_claude', 0755
|
|
143
|
-
|
|
144
|
-
if @config[:enable_security]
|
|
145
|
-
template 'bin/hive_mind_secure.tt', 'bin/hive_mind_secure'
|
|
146
|
-
chmod 'bin/hive_mind_secure', 0755
|
|
147
|
-
end
|
|
148
|
-
end
|
|
149
|
-
end
|
|
150
|
-
|
|
151
|
-
def create_sample_data
|
|
152
|
-
if @config[:create_samples]
|
|
153
|
-
say "\n#{@pastel.cyan('📚 Creating sample data and templates...')}"
|
|
154
|
-
|
|
155
|
-
create_sample_templates
|
|
156
|
-
create_sample_brains if @config[:enable_brains]
|
|
157
|
-
create_sample_parasites if @config[:enable_parasites]
|
|
158
|
-
end
|
|
159
|
-
end
|
|
160
|
-
|
|
161
|
-
def run_post_install_tasks
|
|
162
|
-
say "\n#{@pastel.cyan('⚙️ Running post-installation tasks...')}"
|
|
163
|
-
|
|
164
|
-
# Run migrations
|
|
165
|
-
unless options[:skip_migrations]
|
|
166
|
-
run 'rails db:create' unless database_exists?
|
|
167
|
-
run 'rails db:migrate'
|
|
168
|
-
end
|
|
169
|
-
|
|
170
|
-
# Display HIVE_MIND banner after database setup
|
|
171
|
-
display_hive_mind_installation
|
|
172
|
-
|
|
173
|
-
# Install dependencies
|
|
174
|
-
if @config[:auto_install_dependencies]
|
|
175
|
-
run 'bundle install'
|
|
176
|
-
run 'yarn install' if @config[:frontend_assets] && File.exist?('package.json')
|
|
177
|
-
end
|
|
178
|
-
|
|
179
|
-
# Display component banners as they're installed
|
|
180
|
-
display_component_installations
|
|
181
|
-
|
|
182
|
-
# Seed initial data
|
|
183
|
-
if @config[:seed_initial_data]
|
|
184
|
-
run 'rails hokipoki:seed_templates'
|
|
185
|
-
run 'rails hokipoki:seed_brains' if @config[:enable_brains]
|
|
186
|
-
end
|
|
187
|
-
|
|
188
|
-
# Claude-specific setup
|
|
189
|
-
if @config[:enable_claude_integration]
|
|
190
|
-
setup_claude_integration
|
|
191
|
-
end
|
|
192
|
-
|
|
193
|
-
# Auto-activate Claude script
|
|
194
|
-
if @config[:auto_activate_claude_script]
|
|
195
|
-
run_claude_activation_script
|
|
196
|
-
end
|
|
197
|
-
end
|
|
198
|
-
|
|
199
|
-
def display_completion_message
|
|
200
|
-
say "\n#{@pastel.green.bold('✅ HokiPoki installation completed successfully!')}"
|
|
201
|
-
say "\n#{@pastel.cyan.bold('🎯 Quick Start Guide:')}"
|
|
202
|
-
|
|
203
|
-
if @config[:enable_parasites]
|
|
204
|
-
say " #{@pastel.yellow('Generate a parasite:')}"
|
|
205
|
-
say " rails g hive_mind:parasite claude_cli claude --optimize"
|
|
206
|
-
end
|
|
207
|
-
|
|
208
|
-
if @config[:enable_brains]
|
|
209
|
-
say " #{@pastel.yellow('Create a brain:')}"
|
|
210
|
-
say " rails g hive_mind:brain training_js --domain=javascript"
|
|
211
|
-
end
|
|
212
|
-
|
|
213
|
-
say " #{@pastel.yellow('Use in your code:')}"
|
|
214
|
-
say " facts = Hokipoki.retrieve_facts('how to implement authentication')"
|
|
215
|
-
|
|
216
|
-
if @config[:enable_parasites]
|
|
217
|
-
say " parasite = Hokipoki.generate_parasite(tool: 'claude_cli', model: 'claude')"
|
|
218
|
-
end
|
|
219
|
-
|
|
220
|
-
say "\n#{@pastel.blue.bold('📖 Documentation:')}"
|
|
221
|
-
say " - Configuration: config/initializers/hokipoki.rb"
|
|
222
|
-
say " - API Endpoints: /hokipoki/api/"
|
|
223
|
-
say " - Admin Dashboard: /hokipoki/admin/ (if enabled)"
|
|
224
|
-
|
|
225
|
-
if @config[:enable_security]
|
|
226
|
-
say "\n#{@pastel.red.bold('🔒 Security:')}"
|
|
227
|
-
say " - API authentication enabled"
|
|
228
|
-
say " - Audit logging configured"
|
|
229
|
-
say " - Check config/initializers/hokipoki.rb for security settings"
|
|
230
|
-
end
|
|
231
|
-
|
|
232
|
-
# Claude-specific completion message
|
|
233
|
-
if @config[:enable_claude_integration]
|
|
234
|
-
display_claude_completion_message
|
|
235
|
-
end
|
|
236
|
-
|
|
237
|
-
display_next_steps
|
|
238
|
-
end
|
|
239
|
-
|
|
240
|
-
private
|
|
241
|
-
|
|
242
|
-
def display_hive_mind_installation
|
|
243
|
-
require 'hokipoki/feedback/display_manager'
|
|
244
|
-
|
|
245
|
-
feedback = Hokipoki::Feedback::DisplayManager.instance
|
|
246
|
-
document_count = get_document_count
|
|
247
|
-
feedback.hive_mind_installed(document_count)
|
|
248
|
-
end
|
|
249
|
-
|
|
250
|
-
def display_component_installations
|
|
251
|
-
require 'hokipoki/feedback/display_manager'
|
|
252
|
-
|
|
253
|
-
feedback = Hokipoki::Feedback::DisplayManager.instance
|
|
254
|
-
|
|
255
|
-
# Display banners for enabled components
|
|
256
|
-
if @config[:enable_parasites]
|
|
257
|
-
feedback.parasite_installed
|
|
258
|
-
end
|
|
259
|
-
|
|
260
|
-
if @config[:enable_forge]
|
|
261
|
-
feedback.forge_installed
|
|
262
|
-
end
|
|
263
|
-
|
|
264
|
-
# Final installation complete banner
|
|
265
|
-
installed_components = []
|
|
266
|
-
installed_components << 'hive_mind'
|
|
267
|
-
installed_components << 'parasite' if @config[:enable_parasites]
|
|
268
|
-
installed_components << 'forge' if @config[:enable_forge]
|
|
269
|
-
installed_components << 'security' if @config[:enable_security]
|
|
270
|
-
installed_components << 'claude' if @config[:enable_claude_integration]
|
|
271
|
-
|
|
272
|
-
feedback.installation_complete(installed_components)
|
|
273
|
-
end
|
|
274
|
-
|
|
275
|
-
def get_document_count
|
|
276
|
-
return 0 unless File.exist?('app/models/document.rb')
|
|
277
|
-
|
|
278
|
-
begin
|
|
279
|
-
# Try to get document count if database is accessible
|
|
280
|
-
require Rails.root.join('config/environment') if defined?(Rails.root)
|
|
281
|
-
Document.count if defined?(Document)
|
|
282
|
-
rescue
|
|
283
|
-
0
|
|
284
|
-
end
|
|
285
|
-
end
|
|
286
|
-
|
|
287
|
-
def setup_claude_integration
|
|
288
|
-
say "\n#{@pastel.cyan('🧠 Setting up Claude integration...')}"
|
|
289
|
-
|
|
290
|
-
# Generate Claude-specific parasite
|
|
291
|
-
say " 📝 Generating Claude parasite..."
|
|
292
|
-
invoke 'hive_mind:parasite', ['claude_cli', 'claude'], {
|
|
293
|
-
optimize: true,
|
|
294
|
-
behavioral_analysis: true,
|
|
295
|
-
auto_activate: true
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
# Create Claude auto-loader initializer
|
|
299
|
-
create_claude_auto_loader_initializer
|
|
300
|
-
|
|
301
|
-
# Create Claude connection status command
|
|
302
|
-
create_claude_status_command
|
|
303
|
-
|
|
304
|
-
say " ✓ Claude integration configured"
|
|
305
|
-
end
|
|
306
|
-
|
|
307
|
-
def run_claude_activation_script
|
|
308
|
-
say "\n#{@pastel.cyan('🚀 Running Claude activation script...')}"
|
|
309
|
-
|
|
310
|
-
script_paths = [
|
|
311
|
-
Rails.root.join('ACTIVATE_10X_CLAUDE.sh'),
|
|
312
|
-
Rails.root.join('bin', 'ACTIVATE_10X_CLAUDE.sh')
|
|
313
|
-
]
|
|
314
|
-
|
|
315
|
-
script_path = script_paths.find { |path| File.exist?(path) }
|
|
316
|
-
|
|
317
|
-
if script_path
|
|
318
|
-
say " 🔧 Executing #{File.basename(script_path)}..."
|
|
319
|
-
|
|
320
|
-
# Make executable
|
|
321
|
-
File.chmod(0755, script_path)
|
|
322
|
-
|
|
323
|
-
# Run script
|
|
324
|
-
success = system("cd #{Rails.root} && #{script_path}")
|
|
325
|
-
|
|
326
|
-
if success
|
|
327
|
-
say " #{@pastel.green('✓ Activation script completed successfully')}"
|
|
328
|
-
else
|
|
329
|
-
say " #{@pastel.yellow('⚠ Activation script completed with warnings')}"
|
|
330
|
-
end
|
|
331
|
-
else
|
|
332
|
-
say " #{@pastel.yellow('⚠ ACTIVATE_10X_CLAUDE.sh not found')}"
|
|
333
|
-
say " #{@pastel.dim(' You can copy it from your existing HiveMind installation')}"
|
|
334
|
-
end
|
|
335
|
-
end
|
|
336
|
-
|
|
337
|
-
def create_claude_auto_loader_initializer
|
|
338
|
-
initializer_content = <<~RUBY
|
|
339
|
-
# Claude Auto-Loader Initializer
|
|
340
|
-
# Automatically detects Claude CLI and loads HiveMind integration
|
|
341
|
-
|
|
342
|
-
if defined?(Hokipoki) && Rails.env.development?
|
|
343
|
-
# Load Claude integration modules
|
|
344
|
-
require 'hokipoki/claude/auto_loader'
|
|
345
|
-
require 'hokipoki/claude/connection_manager'
|
|
346
|
-
require 'hokipoki/claude/parasite'
|
|
347
|
-
|
|
348
|
-
# Auto-detect and load Claude integration
|
|
349
|
-
Rails.application.config.after_initialize do
|
|
350
|
-
if Hokipoki::Claude::AutoLoader.claude_cli_detected?
|
|
351
|
-
Rails.logger.info "🔍 Claude CLI detected - Auto-loading HiveMind integration"
|
|
352
|
-
Hokipoki::Claude::AutoLoader.force_load!
|
|
353
|
-
end
|
|
354
|
-
end
|
|
355
|
-
end
|
|
356
|
-
RUBY
|
|
357
|
-
|
|
358
|
-
create_file 'config/initializers/claude_auto_loader.rb', initializer_content
|
|
359
|
-
end
|
|
360
|
-
|
|
361
|
-
def create_claude_status_command
|
|
362
|
-
command_content = <<~RUBY
|
|
363
|
-
#!/usr/bin/env ruby
|
|
364
|
-
|
|
365
|
-
# Claude HiveMind Status Command
|
|
366
|
-
# Usage: ./bin/claude_status
|
|
367
|
-
|
|
368
|
-
require_relative '../config/environment'
|
|
369
|
-
|
|
370
|
-
if defined?(Hokipoki::Claude::ConnectionManager)
|
|
371
|
-
connection_manager = Hokipoki::Claude::ConnectionManager.instance
|
|
372
|
-
parasite = Hokipoki::Claude::Parasite.instance
|
|
373
|
-
|
|
374
|
-
puts "\\n🧠 Claude ↔ HiveMind Status"
|
|
375
|
-
puts "=" * 40
|
|
376
|
-
|
|
377
|
-
connection_manager.display_connection_info
|
|
378
|
-
parasite.display_status
|
|
379
|
-
|
|
380
|
-
# Test vector retrieval
|
|
381
|
-
puts "\\n🧪 Testing vector retrieval..."
|
|
382
|
-
if connection_manager.test_vector_retrieval("test query")
|
|
383
|
-
puts "✅ All systems operational!"
|
|
384
|
-
else
|
|
385
|
-
puts "❌ Issues detected - check configuration"
|
|
386
|
-
end
|
|
387
|
-
else
|
|
388
|
-
puts "❌ Claude integration not installed"
|
|
389
|
-
puts "Run: rails g hive_mind:install --claude"
|
|
390
|
-
end
|
|
391
|
-
RUBY
|
|
392
|
-
|
|
393
|
-
create_file 'bin/claude_status', command_content
|
|
394
|
-
chmod 'bin/claude_status', 0755
|
|
395
|
-
end
|
|
396
|
-
|
|
397
|
-
def display_claude_completion_message
|
|
398
|
-
say "\n#{@pastel.cyan.bold('🧠 Claude Integration Ready!')}"
|
|
399
|
-
say "#{@pastel.green('✓ Claude parasite installed and activated')}"
|
|
400
|
-
say "#{@pastel.green('✓ Auto-loader configured for Claude CLI detection')}"
|
|
401
|
-
say "#{@pastel.green('✓ Vector database connection established')}"
|
|
402
|
-
|
|
403
|
-
if File.exist?(Rails.root.join('ACTIVATE_10X_CLAUDE.sh'))
|
|
404
|
-
say "#{@pastel.green('✓ ACTIVATE_10X_CLAUDE.sh executed successfully')}"
|
|
405
|
-
end
|
|
406
|
-
|
|
407
|
-
say "\n#{@pastel.yellow.bold('🎯 Claude Quick Commands:')}"
|
|
408
|
-
say "#{@pastel.dim(' Check status: ./bin/claude_status')}"
|
|
409
|
-
say "#{@pastel.dim(' Test retrieval: Hokipoki.retrieve_facts(\"your query\")')}"
|
|
410
|
-
say "#{@pastel.dim(' Force connect: Hokipoki::Claude::AutoLoader.force_load!')}"
|
|
411
|
-
|
|
412
|
-
say "\n#{@pastel.magenta('🚀 Your Claude CLI now has AI superpowers!')}"
|
|
413
|
-
say "#{@pastel.dim('Every query will be enhanced with project-specific context.')}"
|
|
414
|
-
end
|
|
415
|
-
|
|
416
|
-
def display_next_steps
|
|
417
|
-
say "\n#{@pastel.blue.bold('🎯 Next Steps:')}"
|
|
418
|
-
|
|
419
|
-
if @config[:enable_claude_integration]
|
|
420
|
-
say " 1. #{@pastel.cyan('Start Claude CLI')} - HiveMind will auto-connect"
|
|
421
|
-
say " 2. #{@pastel.cyan('Check status:')} ./bin/claude_status"
|
|
422
|
-
say " 3. #{@pastel.cyan('Test integration:')} Ask Claude any coding question"
|
|
423
|
-
end
|
|
424
|
-
|
|
425
|
-
def setup_minimal_installation
|
|
426
|
-
say @pastel.cyan("\n🎯 Setting up minimal HiveMind installation...")
|
|
427
|
-
|
|
428
|
-
@config = {
|
|
429
|
-
enable_parasites: false,
|
|
430
|
-
enable_forge: false,
|
|
431
|
-
enable_security: false,
|
|
432
|
-
enable_brains: true,
|
|
433
|
-
lm_studio_integration: true,
|
|
434
|
-
background_processing: false,
|
|
435
|
-
redis_required: false,
|
|
436
|
-
enable_cli_tools: false,
|
|
437
|
-
create_samples: false,
|
|
438
|
-
auto_install_dependencies: true,
|
|
439
|
-
seed_initial_data: true,
|
|
440
|
-
frontend_assets: false
|
|
441
|
-
}
|
|
442
|
-
end
|
|
443
|
-
|
|
444
|
-
def setup_claude_installation
|
|
445
|
-
say @pastel.cyan("\n🧠 Setting up HiveMind + Claude integration...")
|
|
446
|
-
|
|
447
|
-
@config = {
|
|
448
|
-
enable_parasites: true, # Need parasites for Claude
|
|
449
|
-
enable_forge: false, # Not needed for Claude basic
|
|
450
|
-
enable_security: true, # Security always good
|
|
451
|
-
enable_brains: true, # Multi-brain support
|
|
452
|
-
enable_claude_integration: true, # Special Claude features
|
|
453
|
-
lm_studio_integration: true, # For embedding generation
|
|
454
|
-
background_processing: false, # Not needed for basic Claude
|
|
455
|
-
redis_required: true, # For caching vector results
|
|
456
|
-
enable_cli_tools: true, # Claude CLI tools
|
|
457
|
-
create_samples: true, # Sample Claude parasites
|
|
458
|
-
auto_install_dependencies: true,
|
|
459
|
-
seed_initial_data: true,
|
|
460
|
-
frontend_assets: false, # No UI needed for Claude
|
|
461
|
-
enable_workshop: false, # Not needed for basic
|
|
462
|
-
enable_behavioral_analysis: true, # For Claude optimization
|
|
463
|
-
auto_activate_claude_script: true # Auto-run ACTIVATE_10X_CLAUDE.sh
|
|
464
|
-
}
|
|
465
|
-
end
|
|
466
|
-
|
|
467
|
-
def setup_full_installation
|
|
468
|
-
say @pastel.cyan("\n🚀 Setting up complete revolutionary stack...")
|
|
469
|
-
|
|
470
|
-
@config = {
|
|
471
|
-
enable_parasites: true,
|
|
472
|
-
enable_forge: true,
|
|
473
|
-
enable_security: true,
|
|
474
|
-
enable_brains: true,
|
|
475
|
-
enable_claude_integration: true,
|
|
476
|
-
lm_studio_integration: true,
|
|
477
|
-
background_processing: true,
|
|
478
|
-
redis_required: true,
|
|
479
|
-
enable_cli_tools: true,
|
|
480
|
-
create_samples: true,
|
|
481
|
-
auto_install_dependencies: true,
|
|
482
|
-
seed_initial_data: true,
|
|
483
|
-
frontend_assets: true,
|
|
484
|
-
enable_workshop: true,
|
|
485
|
-
enable_behavioral_analysis: true,
|
|
486
|
-
auto_activate_claude_script: true
|
|
487
|
-
}
|
|
488
|
-
end
|
|
489
|
-
|
|
490
|
-
def setup_interactive_installation
|
|
491
|
-
say @pastel.cyan("\n🎮 Interactive installation - Choose your components:")
|
|
492
|
-
|
|
493
|
-
@config = {}
|
|
494
|
-
|
|
495
|
-
# Core components
|
|
496
|
-
@config[:enable_parasites] = @prompt.yes?("Enable Universal Parasites? (94% code reduction)", default: true)
|
|
497
|
-
@config[:enable_forge] = @prompt.yes?("Enable Generator Forge? (heavyweight processing)", default: false)
|
|
498
|
-
@config[:enable_security] = @prompt.yes?("Enable enterprise security features?", default: true)
|
|
499
|
-
@config[:enable_brains] = @prompt.yes?("Enable multi-brain system?", default: true)
|
|
500
|
-
|
|
501
|
-
# Integration options
|
|
502
|
-
@config[:lm_studio_integration] = @prompt.yes?("Configure LM Studio integration?", default: true)
|
|
503
|
-
@config[:background_processing] = @prompt.yes?("Enable background job processing?", default: @config[:enable_forge])
|
|
504
|
-
@config[:redis_required] = @config[:background_processing] || @prompt.yes?("Use Redis for caching?", default: true)
|
|
505
|
-
|
|
506
|
-
# Additional features
|
|
507
|
-
@config[:enable_cli_tools] = @prompt.yes?("Create CLI tools (bin/hive_mind_claude)?", default: true)
|
|
508
|
-
@config[:create_samples] = @prompt.yes?("Create sample data and templates?", default: true)
|
|
509
|
-
@config[:frontend_assets] = @config[:enable_forge] && @prompt.yes?("Include frontend workshop interface?", default: false)
|
|
510
|
-
|
|
511
|
-
# Installation preferences
|
|
512
|
-
@config[:auto_install_dependencies] = @prompt.yes?("Auto-install dependencies (bundle install)?", default: true)
|
|
513
|
-
@config[:seed_initial_data] = @prompt.yes?("Seed initial templates and data?", default: true)
|
|
514
|
-
|
|
515
|
-
# Advanced features (only if forge is enabled)
|
|
516
|
-
if @config[:enable_forge]
|
|
517
|
-
@config[:enable_workshop] = @prompt.yes?("Enable LLM refinement workshop?", default: true)
|
|
518
|
-
@config[:enable_behavioral_analysis] = @prompt.yes?("Enable LLM behavioral analysis?", default: true)
|
|
519
|
-
end
|
|
520
|
-
|
|
521
|
-
display_configuration_summary
|
|
522
|
-
end
|
|
523
|
-
|
|
524
|
-
def display_configuration_summary
|
|
525
|
-
say "\n#{@pastel.yellow.bold('📋 Installation Configuration:')}"
|
|
526
|
-
say " #{component_status('Universal Parasites', @config[:enable_parasites])}"
|
|
527
|
-
say " #{component_status('Generator Forge', @config[:enable_forge])}"
|
|
528
|
-
say " #{component_status('Security Features', @config[:enable_security])}"
|
|
529
|
-
say " #{component_status('Multi-Brain System', @config[:enable_brains])}"
|
|
530
|
-
say " #{component_status('LM Studio Integration', @config[:lm_studio_integration])}"
|
|
531
|
-
say " #{component_status('Background Processing', @config[:background_processing])}"
|
|
532
|
-
say " #{component_status('Redis Caching', @config[:redis_required])}"
|
|
533
|
-
say " #{component_status('CLI Tools', @config[:enable_cli_tools])}"
|
|
534
|
-
|
|
535
|
-
unless @prompt.yes?("\nProceed with this configuration?", default: true)
|
|
536
|
-
say @pastel.red("Installation cancelled.")
|
|
537
|
-
exit 1
|
|
538
|
-
end
|
|
539
|
-
end
|
|
540
|
-
|
|
541
|
-
def component_status(name, enabled)
|
|
542
|
-
status = enabled ? @pastel.green('✓ Enabled') : @pastel.dim('○ Disabled')
|
|
543
|
-
"#{name.ljust(25)} #{status}"
|
|
544
|
-
end
|
|
545
|
-
|
|
546
|
-
def check_ruby_version
|
|
547
|
-
required_version = Gem::Version.new('3.0.0')
|
|
548
|
-
current_version = Gem::Version.new(RUBY_VERSION)
|
|
549
|
-
|
|
550
|
-
if current_version < required_version
|
|
551
|
-
say @pastel.red("❌ Ruby #{required_version} or higher required. Current: #{current_version}")
|
|
552
|
-
exit 1
|
|
553
|
-
end
|
|
554
|
-
end
|
|
555
|
-
|
|
556
|
-
def check_rails_version
|
|
557
|
-
required_version = Gem::Version.new('7.0.0')
|
|
558
|
-
current_version = Gem::Version.new(Rails::VERSION::STRING)
|
|
559
|
-
|
|
560
|
-
if current_version < required_version
|
|
561
|
-
say @pastel.red("❌ Rails #{required_version} or higher required. Current: #{current_version}")
|
|
562
|
-
exit 1
|
|
563
|
-
end
|
|
564
|
-
end
|
|
565
|
-
|
|
566
|
-
def check_database_support
|
|
567
|
-
adapter = ActiveRecord::Base.connection.adapter_name.downcase
|
|
568
|
-
|
|
569
|
-
unless adapter.include?('postgresql')
|
|
570
|
-
say @pastel.red("❌ PostgreSQL required for vector similarity. Current adapter: #{adapter}")
|
|
571
|
-
say @pastel.yellow("Please configure PostgreSQL and install the 'pg' gem.")
|
|
572
|
-
exit 1
|
|
573
|
-
end
|
|
574
|
-
|
|
575
|
-
# Check for pgvector extension
|
|
576
|
-
unless pgvector_available?
|
|
577
|
-
say @pastel.yellow("⚠️ pgvector extension not detected. It will be installed during migration.")
|
|
578
|
-
end
|
|
579
|
-
end
|
|
580
|
-
|
|
581
|
-
def check_redis_availability
|
|
582
|
-
return unless @config[:redis_required]
|
|
583
|
-
|
|
584
|
-
begin
|
|
585
|
-
require 'redis'
|
|
586
|
-
redis = Redis.new
|
|
587
|
-
redis.ping
|
|
588
|
-
say @pastel.green("✓ Redis connection successful")
|
|
589
|
-
rescue LoadError
|
|
590
|
-
say @pastel.yellow("⚠️ Redis gem not found. Add 'gem \"redis\"' to your Gemfile.")
|
|
591
|
-
rescue => e
|
|
592
|
-
say @pastel.yellow("⚠️ Redis connection failed: #{e.message}")
|
|
593
|
-
say @pastel.yellow(" Make sure Redis is running or update config/initializers/hokipoki.rb")
|
|
594
|
-
end
|
|
595
|
-
end
|
|
596
|
-
|
|
597
|
-
def pgvector_available?
|
|
598
|
-
ActiveRecord::Base.connection.execute("SELECT 1 FROM pg_extension WHERE extname = 'vector'").any?
|
|
599
|
-
rescue
|
|
600
|
-
false
|
|
601
|
-
end
|
|
602
|
-
|
|
603
|
-
def database_exists?
|
|
604
|
-
ActiveRecord::Base.connection
|
|
605
|
-
true
|
|
606
|
-
rescue ActiveRecord::NoDatabaseError
|
|
607
|
-
false
|
|
608
|
-
end
|
|
609
|
-
|
|
610
|
-
def create_configuration_yml
|
|
611
|
-
config_data = {
|
|
612
|
-
'development' => generate_config_hash('development'),
|
|
613
|
-
'test' => generate_config_hash('test'),
|
|
614
|
-
'production' => generate_config_hash('production')
|
|
615
|
-
}
|
|
616
|
-
|
|
617
|
-
create_file 'config/hokipoki.yml' do
|
|
618
|
-
YAML.dump(config_data)
|
|
619
|
-
end
|
|
620
|
-
end
|
|
621
|
-
|
|
622
|
-
def generate_config_hash(env)
|
|
623
|
-
base_config = {
|
|
624
|
-
'vector_dimensions' => 768,
|
|
625
|
-
'token_budget_default' => 1500,
|
|
626
|
-
'enable_parasites' => @config[:enable_parasites],
|
|
627
|
-
'enable_forge' => @config[:enable_forge],
|
|
628
|
-
'enable_behavioral_analysis' => @config[:enable_behavioral_analysis] || false,
|
|
629
|
-
'enable_template_optimization' => true,
|
|
630
|
-
'template_caching' => true,
|
|
631
|
-
'context_compression' => true,
|
|
632
|
-
'default_brain' => 'default_brain',
|
|
633
|
-
'auto_brain_switching' => @config[:enable_brains]
|
|
634
|
-
}
|
|
635
|
-
|
|
636
|
-
case env
|
|
637
|
-
when 'development'
|
|
638
|
-
base_config.merge({
|
|
639
|
-
'lm_studio_url' => 'http://localhost:1236',
|
|
640
|
-
'redis_url' => 'redis://localhost:6379/0',
|
|
641
|
-
'audit_logging' => false,
|
|
642
|
-
'rate_limiting' => false
|
|
643
|
-
})
|
|
644
|
-
when 'test'
|
|
645
|
-
base_config.merge({
|
|
646
|
-
'lm_studio_url' => 'http://localhost:1236',
|
|
647
|
-
'redis_url' => 'redis://localhost:6379/1',
|
|
648
|
-
'audit_logging' => false,
|
|
649
|
-
'rate_limiting' => false,
|
|
650
|
-
'template_caching' => false
|
|
651
|
-
})
|
|
652
|
-
when 'production'
|
|
653
|
-
base_config.merge({
|
|
654
|
-
'lm_studio_url' => '<%= ENV["LM_STUDIO_URL"] %>',
|
|
655
|
-
'redis_url' => '<%= ENV["REDIS_URL"] %>',
|
|
656
|
-
'audit_logging' => @config[:enable_security],
|
|
657
|
-
'rate_limiting' => @config[:enable_security],
|
|
658
|
-
'api_authentication' => @config[:enable_security]
|
|
659
|
-
})
|
|
660
|
-
end
|
|
661
|
-
end
|
|
662
|
-
|
|
663
|
-
def create_brain_configurations
|
|
664
|
-
say " 📧 Creating brain configurations..."
|
|
665
|
-
|
|
666
|
-
directory 'config/brains', 'config/brains'
|
|
667
|
-
end
|
|
668
|
-
|
|
669
|
-
def create_service_components
|
|
670
|
-
say " 🔧 Creating service components..."
|
|
671
|
-
|
|
672
|
-
template 'app/services/hokipoki/template_versioning_service.rb.tt', 'app/services/hokipoki/template_versioning_service.rb'
|
|
673
|
-
template 'app/services/hokipoki/template_performance_tracker.rb.tt', 'app/services/hokipoki/template_performance_tracker.rb'
|
|
674
|
-
|
|
675
|
-
if @config[:enable_security]
|
|
676
|
-
template 'app/services/hokipoki/security_audit_service.rb.tt', 'app/services/hokipoki/security_audit_service.rb'
|
|
677
|
-
end
|
|
678
|
-
end
|
|
679
|
-
|
|
680
|
-
def generate_route_content
|
|
681
|
-
routes = []
|
|
682
|
-
routes << "\n # HokiPoki Routes"
|
|
683
|
-
routes << " mount Hokipoki::Engine => '/hokipoki'"
|
|
684
|
-
routes << ""
|
|
685
|
-
routes << " namespace :hokipoki do"
|
|
686
|
-
routes << " namespace :api do"
|
|
687
|
-
routes << " resources :documents, only: [:index, :show, :create]"
|
|
688
|
-
routes << " resources :vector_search, only: [:create]"
|
|
689
|
-
|
|
690
|
-
if @config[:enable_parasites]
|
|
691
|
-
routes << " resources :parasites, only: [:index, :show, :create, :update]"
|
|
692
|
-
end
|
|
693
|
-
|
|
694
|
-
routes << " end"
|
|
695
|
-
|
|
696
|
-
if @config[:enable_forge] && @config[:frontend_assets]
|
|
697
|
-
routes << ""
|
|
698
|
-
routes << " namespace :admin do"
|
|
699
|
-
routes << " resources :dashboard, only: [:index]"
|
|
700
|
-
routes << " resources :templates"
|
|
701
|
-
routes << " resources :workshop, only: [:index, :show]" if @config[:enable_workshop]
|
|
702
|
-
routes << " end"
|
|
703
|
-
end
|
|
704
|
-
|
|
705
|
-
routes << " end\n"
|
|
706
|
-
|
|
707
|
-
routes.join("\n")
|
|
708
|
-
end
|
|
709
|
-
|
|
710
|
-
def create_sample_templates
|
|
711
|
-
template 'samples/templates/smart_retrieval_template.yml.tt', 'db/seeds/templates/smart_retrieval_template.yml'
|
|
712
|
-
|
|
713
|
-
if @config[:enable_parasites]
|
|
714
|
-
template 'samples/templates/claude_parasite_template.yml.tt', 'db/seeds/templates/claude_parasite_template.yml'
|
|
715
|
-
end
|
|
716
|
-
end
|
|
717
|
-
|
|
718
|
-
def create_sample_brains
|
|
719
|
-
template 'samples/brains/default_brain.yml.tt', 'db/seeds/brains/default_brain.yml'
|
|
720
|
-
template 'samples/brains/training_brain_js.yml.tt', 'db/seeds/brains/training_brain_js.yml'
|
|
721
|
-
end
|
|
722
|
-
|
|
723
|
-
def create_sample_parasites
|
|
724
|
-
template 'samples/parasites/claude_cli_parasite.rb.tt', 'db/seeds/parasites/claude_cli_parasite.rb'
|
|
725
|
-
end
|
|
726
|
-
|
|
727
|
-
def display_next_steps
|
|
728
|
-
say "\n#{@pastel.blue.bold('🎯 Next Steps:')}"
|
|
729
|
-
|
|
730
|
-
if @config[:lm_studio_integration]
|
|
731
|
-
say " 1. Start LM Studio and load your preferred model"
|
|
732
|
-
say " 2. Update LM Studio URL in config/initializers/hokipoki.rb if needed"
|
|
733
|
-
end
|
|
734
|
-
|
|
735
|
-
if @config[:redis_required]
|
|
736
|
-
say " 3. Ensure Redis is running for background processing"
|
|
737
|
-
end
|
|
738
|
-
|
|
739
|
-
if @config[:enable_parasites]
|
|
740
|
-
say " 4. Generate your first parasite: rails g hive_mind:parasite claude_cli claude"
|
|
741
|
-
end
|
|
742
|
-
|
|
743
|
-
say " 5. Start your Rails server and visit /hokipoki/api for API endpoints"
|
|
744
|
-
|
|
745
|
-
if @config[:frontend_assets]
|
|
746
|
-
say " 6. Visit /hokipoki/admin/dashboard for the management interface"
|
|
747
|
-
end
|
|
748
|
-
|
|
749
|
-
say "\n#{@pastel.magenta.bold('🌟 Advanced Features:')}"
|
|
750
|
-
say " - Template optimization: Hokipoki::IntelligenceTemplate.optimize_all!"
|
|
751
|
-
say " - Parasite generation: Hokipoki.generate_parasite(tool: 'tool', model: 'model')" if @config[:enable_parasites]
|
|
752
|
-
say " - System status: Hokipoki.system_status"
|
|
753
|
-
|
|
754
|
-
say "\n#{@pastel.green('Happy coding with HokiPoki! 🚀')}"
|
|
755
|
-
end
|
|
756
|
-
|
|
757
|
-
def self.next_migration_number(dirname)
|
|
758
|
-
ActiveRecord::Generators::Base.next_migration_number(dirname)
|
|
759
|
-
end
|
|
760
|
-
end
|
|
761
|
-
end
|