hokipoki 0.1.4 → 0.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e3e1bff3991e48d0e4ba243f6a30fd19c9e403a3c322afc4c34d4ba4eb39ad12
4
- data.tar.gz: 2adc22f2d0a4561d462b162058c3bbd44f742c85886257c0c7c2cdde8aeeb14b
3
+ metadata.gz: c6cee87ee2a662007747231e06031670fad45f77a8e623f2502084987ff6410c
4
+ data.tar.gz: dde3f8d03b75bd701e69e49663a8b8352605bbc86a94f94d3d183715c332c2c5
5
5
  SHA512:
6
- metadata.gz: 2516348cf9b601352cd07335e78cd32267866ce0808c55bd1726fcd478992e9445ca3a56b76a7cd5f66f9bb0e0877f6088f0c5d7b9e6017efc92a91ab871b2ea
7
- data.tar.gz: d3bc48d25e69d0791218a6c50b40b0ef450c0d5a9be53e77b1da9e857e8a8d57c66f201dad6447b3f8e0f2eb5902ff41f0a7eb6fd960b27bfab071e5a875fd4f
6
+ metadata.gz: 39d223c6ea30d2d3568f3fc7057bc35953cbefb6d7c00455baa163a3f28fcbd163d55e51a11df1a286d1a0d39148b2d7005fd62c51d119f049ba222f213b46a9
7
+ data.tar.gz: c0bc88d762402e4d3ef584896c34f90df129fa56897bc5cb022f1225089e46662a39cbe8df9ae527faca4803deec6dd9602090d226ca6198fbb05793b4ab945a
@@ -63,114 +63,104 @@ module HiveMind
63
63
  end
64
64
 
65
65
  def welcome_message
66
- say "\n#{@pastel.cyan.bold('🚀 Welcome to HokiPoki - Revolutionary AI Intelligence Platform')}"
67
- say @pastel.green("Transform your Rails app with vector intelligence, universal parasites, and template-as-data architecture!")
68
- say "\n#{@pastel.yellow('Installation Options:')}"
69
- say " #{@pastel.blue('--minimal')} : Core vector DB + smart retrieval (minimal)"
70
- say " #{@pastel.blue('--claude')} : HiveMind + Claude integration (recommended for Claude users)"
71
- say " #{@pastel.blue('--full')} : Everything - HiveMind + Parasites + Forge + Security (maximum power)"
72
- say " #{@pastel.blue('Interactive')}: Choose components (recommended)\n"
66
+ say "\n#{@pastel.cyan.bold('🚀 Welcome to HokiPoki - Lightweight HiveMind + Claude Integration')}"
67
+ say @pastel.green("Installing minimal HiveMind with secure OTP authentication and Claude parasite.")
68
+ say "\n"
73
69
  end
74
70
 
75
71
  def gather_installation_preferences
76
72
  # Security authentication required before any installation
77
73
  security_authentication
78
74
 
79
- return setup_minimal_installation if options[:minimal]
80
- return setup_claude_installation if options[:claude]
81
- return setup_full_installation if options[:full]
82
-
83
- setup_interactive_installation
75
+ # Always install minimal lightweight version
76
+ @config = {
77
+ hive_mind_enabled: true,
78
+ claude_parasite_enabled: true,
79
+ skip_complex_components: true
80
+ }
84
81
  end
85
82
 
86
83
  def validate_requirements
87
84
  check_ruby_version
88
85
  check_rails_version
89
- check_database_support
90
- check_redis_availability if @config[:redis_required]
86
+ # Skip complex database and redis checks for minimal install
87
+ end
88
+
89
+ def add_gems_to_gemfile
90
+ say "\n#{@pastel.cyan('💎 Adding required gems to Gemfile...')}"
91
+
92
+ # Add essential HiveMind gems
93
+ gem 'pg', '>= 1.0' unless File.read('Gemfile').include?('pg')
94
+ gem 'neighbor', '>= 0.3' unless File.read('Gemfile').include?('neighbor') # pgvector for Rails
95
+ gem 'redis', '>= 4.0' unless File.read('Gemfile').include?('redis')
96
+ gem 'ruby-openai', '>= 6.0' unless File.read('Gemfile').include?('ruby-openai') # For LLM integration
97
+ gem 'faraday', '>= 2.0' unless File.read('Gemfile').include?('faraday') # HTTP client for LLM APIs
98
+
99
+ say @pastel.green("✓ Added pg, neighbor, redis, ruby-openai, faraday to Gemfile")
91
100
  end
92
101
 
93
102
  def create_configuration_files
94
103
  return if options[:skip_config]
95
104
 
96
- say "\n#{@pastel.cyan('📝 Creating configuration files...')}"
97
-
98
- template 'initializers/hokipoki.rb.tt', 'config/initializers/hokipoki.rb'
105
+ say "\n#{@pastel.cyan('📝 Creating minimal configuration files...')}"
99
106
 
100
- if @config[:lm_studio_integration]
101
- template 'initializers/lm_studio.rb.tt', 'config/initializers/lm_studio.rb'
102
- end
107
+ # Just create a simple initializer
108
+ create_file "config/initializers/hokipoki.rb", <<~RUBY
109
+ # HokiPoki Configuration
110
+ Hokipoki.configure do |config|
111
+ config.hive_mind_enabled = true
112
+ config.claude_parasite_enabled = true
113
+ end
114
+ RUBY
103
115
 
104
- create_configuration_yml
105
- create_brain_configurations if @config[:enable_brains]
116
+ say @pastel.green("✓ Created config/initializers/hokipoki.rb")
106
117
  end
107
118
 
108
119
  def setup_database_migrations
109
120
  return if options[:skip_migrations]
110
121
 
111
- say "\n#{@pastel.cyan('🗄️ Setting up database migrations...')}"
122
+ say "\n#{@pastel.cyan('🗄️ Creating migration files...')}"
112
123
 
113
- # Core tables
114
- migration_template 'migrations/enable_pgvector.rb.tt', 'db/migrate/enable_pgvector.rb'
115
- migration_template 'migrations/create_documents.rb.tt', 'db/migrate/create_documents.rb'
116
- migration_template 'migrations/create_intelligence_templates.rb.tt', 'db/migrate/create_intelligence_templates.rb'
124
+ # Create simple migration for HiveMind
125
+ migration_template 'create_hive_mind_documents.rb', 'db/migrate/create_hive_mind_documents.rb'
117
126
 
118
- # Parasite tables
119
- if @config[:enable_parasites]
120
- migration_template 'migrations/create_custom_parasites.rb.tt', 'db/migrate/create_custom_parasites.rb'
121
- migration_template 'migrations/create_llm_behavioral_patterns.rb.tt', 'db/migrate/create_llm_behavioral_patterns.rb'
122
- end
123
-
124
- # Brain management tables
125
- if @config[:enable_brains]
126
- migration_template 'migrations/create_brain_configurations.rb.tt', 'db/migrate/create_brain_configurations.rb'
127
- end
128
-
129
- # Security tables
130
- if @config[:enable_security]
131
- migration_template 'migrations/create_security_audit_logs.rb.tt', 'db/migrate/create_security_audit_logs.rb'
132
- end
127
+ say @pastel.green("✓ Migration files created")
128
+ say @pastel.yellow(" Next step: Run 'rails db:migrate' to set up the database")
133
129
  end
134
130
 
135
131
  def create_application_components
136
- say "\n#{@pastel.cyan('🏗️ Creating application components...')}"
137
-
138
- # Create models
139
- template 'app/models/hokipoki/document.rb.tt', 'app/models/hokipoki/document.rb'
140
- template 'app/models/hokipoki/intelligence_template.rb.tt', 'app/models/hokipoki/intelligence_template.rb'
141
-
142
- if @config[:enable_parasites]
143
- template 'app/models/hokipoki/custom_parasite.rb.tt', 'app/models/hokipoki/custom_parasite.rb'
144
- end
145
-
146
- # Create controllers
147
- template 'app/controllers/hokipoki/api/documents_controller.rb.tt', 'app/controllers/hokipoki/api/documents_controller.rb'
148
- template 'app/controllers/hokipoki/api/vector_search_controller.rb.tt', 'app/controllers/hokipoki/api/vector_search_controller.rb'
149
-
150
- if @config[:enable_parasites]
151
- template 'app/controllers/hokipoki/api/parasites_controller.rb.tt', 'app/controllers/hokipoki/api/parasites_controller.rb'
152
- end
153
-
154
- # Create services
155
- create_service_components
156
-
157
- # Create jobs
158
- if @config[:background_processing]
159
- template 'app/jobs/hokipoki/document_processor_job.rb.tt', 'app/jobs/hokipoki/document_processor_job.rb'
132
+ say "\n#{@pastel.cyan('🏗️ Creating basic HiveMind model...')}"
133
+
134
+ # Create simple Document model
135
+ create_file "app/models/hive_mind_document.rb", <<~RUBY
136
+ # HiveMind Document Model
137
+ class HiveMindDocument < ApplicationRecord
138
+ validates :content, presence: true
139
+
140
+ scope :by_source, ->(type, id) { where(source_type: type, source_id: id) }
141
+
142
+ def self.store_content(content, source_type: nil, source_id: nil, metadata: {})
143
+ create!(
144
+ content: content,
145
+ source_type: source_type,
146
+ source_id: source_id,
147
+ metadata: metadata
148
+ )
149
+ end
160
150
 
161
- if @config[:enable_parasites]
162
- template 'app/jobs/hokipoki/parasite_optimization_job.rb.tt', 'app/jobs/hokipoki/parasite_optimization_job.rb'
151
+ def self.search_content(query)
152
+ # Simple text search for now - vector search after pgvector setup
153
+ where("content ILIKE ?", "%\#{query}%")
154
+ end
163
155
  end
164
- end
156
+ RUBY
157
+
158
+ say @pastel.green("✓ Created app/models/hive_mind_document.rb")
165
159
  end
166
160
 
167
161
  def setup_routing
168
- say "\n#{@pastel.cyan('🛣️ Setting up routes...')}"
169
-
170
- route_content = generate_route_content
171
- inject_into_file 'config/routes.rb', after: "Rails.application.routes.draw do\n" do
172
- route_content
173
- end
162
+ say "\n#{@pastel.cyan('🛣️ Skipping routes for lightweight install')}"
163
+ say @pastel.green("✓ No additional routes needed")
174
164
  end
175
165
 
176
166
  def create_cli_tools
@@ -236,44 +226,29 @@ module HiveMind
236
226
  end
237
227
 
238
228
  def display_completion_message
239
- say "\n#{@pastel.green.bold('✅ HokiPoki installation completed successfully!')}"
240
- say "\n#{@pastel.cyan.bold('🎯 Quick Start Guide:')}"
229
+ say "\n#{@pastel.green.bold('✅ HokiPoki lightweight installation completed!')}"
230
+ say "\n#{@pastel.cyan.bold('🎯 Next Steps:')}"
241
231
 
242
- if @config[:enable_parasites]
243
- say " #{@pastel.yellow('Generate a parasite:')}"
244
- say " rails g hive_mind:parasite claude_cli claude --optimize"
245
- end
246
-
247
- if @config[:enable_brains]
248
- say " #{@pastel.yellow('Create a brain:')}"
249
- say " rails g hive_mind:brain training_js --domain=javascript"
250
- end
232
+ say " #{@pastel.yellow('1. Install gem dependencies:')}"
233
+ say " bundle install"
251
234
 
252
- say " #{@pastel.yellow('Use in your code:')}"
253
- say " facts = Hokipoki.retrieve_facts('how to implement authentication')"
235
+ say "\n #{@pastel.yellow('2. Run database migration:')}"
236
+ say " rails db:migrate"
254
237
 
255
- if @config[:enable_parasites]
256
- say " parasite = Hokipoki.generate_parasite(tool: 'claude_cli', model: 'claude')"
257
- end
238
+ say "\n #{@pastel.yellow('3. Test basic functionality:')}"
239
+ say " HiveMindDocument.store_content('Hello HiveMind!')"
240
+ say " HiveMindDocument.search_content('Hello')"
258
241
 
259
- say "\n#{@pastel.blue.bold('📖 Documentation:')}"
260
- say " - Configuration: config/initializers/hokipoki.rb"
261
- say " - API Endpoints: /hokipoki/api/"
262
- say " - Admin Dashboard: /hokipoki/admin/ (if enabled)"
242
+ say "\n #{@pastel.yellow('4. Use in your code:')}"
243
+ say " facts = Hokipoki.retrieve_facts('your query here')"
263
244
 
264
- if @config[:enable_security]
265
- say "\n#{@pastel.red.bold('🔒 Security:')}"
266
- say " - API authentication enabled"
267
- say " - Audit logging configured"
268
- say " - Check config/initializers/hokipoki.rb for security settings"
269
- end
270
-
271
- # Claude-specific completion message
272
- if @config[:enable_claude_integration]
273
- display_claude_completion_message
274
- end
245
+ say "\n#{@pastel.blue.bold('📁 Files Created:')}"
246
+ say " - Gemfile (gems added: pg, neighbor, redis, ruby-openai, faraday)"
247
+ say " - config/initializers/hokipoki.rb"
248
+ say " - app/models/hive_mind_document.rb"
249
+ say " - db/migrate/create_hive_mind_documents.rb"
275
250
 
276
- display_next_steps
251
+ say "\n#{@pastel.green.bold('🚀 HiveMind + Claude Parasite Ready!')}"
277
252
  end
278
253
 
279
254
  private
@@ -825,4 +800,4 @@ module HiveMind
825
800
  ActiveRecord::Generators::Base.next_migration_number(dirname)
826
801
  end
827
802
  end
828
- end
803
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ class CreateHiveMindDocuments < ActiveRecord::Migration[7.0]
4
+ def change
5
+ # Enable pgvector extension
6
+ enable_extension 'vector'
7
+
8
+ create_table :hive_mind_documents do |t|
9
+ t.text :content, null: false
10
+ t.string :source_type
11
+ t.string :source_id
12
+ t.json :metadata, default: {}
13
+
14
+ # Vector embedding column for similarity search
15
+ t.vector :embedding, limit: 768
16
+
17
+ t.timestamps
18
+ end
19
+
20
+ add_index :hive_mind_documents, :source_type
21
+ add_index :hive_mind_documents, [:source_type, :source_id]
22
+ add_index :hive_mind_documents, :embedding, using: :hnsw, opclass: :vector_cosine_ops
23
+ end
24
+ end
@@ -2,93 +2,19 @@
2
2
 
3
3
  module Hokipoki
4
4
  class Configuration
5
- attr_accessor :vector_dimensions,
6
- :lm_studio_url,
7
- :embedding_model,
8
- :enable_parasites,
9
- :enable_forge,
10
- :enable_behavioral_analysis,
11
- :enable_template_optimization,
12
- :template_caching,
13
- :token_budget_default,
14
- :context_compression,
15
- :offline_mode,
16
- :api_authentication,
17
- :audit_logging,
18
- :encrypted_logging,
19
- :rate_limiting,
20
- :default_brain,
21
- :auto_brain_switching,
22
- :universal_parasite_generation,
23
- :auto_optimization,
24
- :cross_parasite_learning,
25
- :workshop_interface,
26
- :background_processing,
27
- :multi_llm_orchestration,
28
- :redis_url,
29
- :cache_ttl,
30
- :max_retries
5
+ attr_accessor :hive_mind_enabled,
6
+ :claude_parasite_enabled,
7
+ :redis_url
31
8
 
32
9
  def initialize
33
- # === CORE SETTINGS ===
34
- @vector_dimensions = 768
35
- @lm_studio_url = ENV.fetch('LM_STUDIO_URL', 'http://localhost:1236')
36
- @embedding_model = ENV.fetch('EMBEDDING_MODEL', 'text-embedding-nomic-embed-text-v1.5')
37
-
38
- # === COMPONENT ACTIVATION ===
39
- @enable_parasites = ENV.fetch('HOKIPOKI_ENABLE_PARASITES', 'true') == 'true'
40
- @enable_forge = ENV.fetch('HOKIPOKI_ENABLE_FORGE', 'false') == 'true'
41
- @enable_behavioral_analysis = ENV.fetch('HOKIPOKI_ENABLE_BEHAVIORAL_ANALYSIS', 'true') == 'true'
42
- @enable_template_optimization = ENV.fetch('HOKIPOKI_ENABLE_TEMPLATE_OPTIMIZATION', 'true') == 'true'
43
-
44
- # === PERFORMANCE ===
45
- @template_caching = ENV.fetch('HOKIPOKI_TEMPLATE_CACHING', 'true') == 'true'
46
- @token_budget_default = ENV.fetch('HOKIPOKI_TOKEN_BUDGET_DEFAULT', '1500').to_i
47
- @context_compression = ENV.fetch('HOKIPOKI_CONTEXT_COMPRESSION', 'true') == 'true'
48
- @offline_mode = ENV.fetch('HOKIPOKI_OFFLINE_MODE', 'false') == 'true'
49
- @cache_ttl = ENV.fetch('HOKIPOKI_CACHE_TTL', '3600').to_i # 1 hour default
50
- @max_retries = ENV.fetch('HOKIPOKI_MAX_RETRIES', '3').to_i
51
-
52
- # === SECURITY ===
53
- @api_authentication = ENV.fetch('HOKIPOKI_API_AUTHENTICATION', 'true') == 'true'
54
- @audit_logging = ENV.fetch('HOKIPOKI_AUDIT_LOGGING', 'true') == 'true'
55
- @encrypted_logging = ENV.fetch('HOKIPOKI_ENCRYPTED_LOGGING', 'false') == 'true'
56
- @rate_limiting = ENV.fetch('HOKIPOKI_RATE_LIMITING', 'true') == 'true'
57
-
58
- # === BRAINS CONFIGURATION ===
59
- @default_brain = ENV.fetch('HOKIPOKI_DEFAULT_BRAIN', 'default_brain')
60
- @auto_brain_switching = ENV.fetch('HOKIPOKI_AUTO_BRAIN_SWITCHING', 'true') == 'true'
61
-
62
- # === PARASITE SYSTEM ===
63
- @universal_parasite_generation = ENV.fetch('HOKIPOKI_UNIVERSAL_PARASITE_GENERATION', 'true') == 'true'
64
- @auto_optimization = ENV.fetch('HOKIPOKI_AUTO_OPTIMIZATION', 'true') == 'true'
65
- @cross_parasite_learning = ENV.fetch('HOKIPOKI_CROSS_PARASITE_LEARNING', 'true') == 'true'
66
-
67
- # === FORGE CONFIGURATION ===
68
- @workshop_interface = ENV.fetch('HOKIPOKI_WORKSHOP_INTERFACE', 'true') == 'true'
69
- @background_processing = ENV.fetch('HOKIPOKI_BACKGROUND_PROCESSING', 'sidekiq').to_sym
70
- @multi_llm_orchestration = ENV.fetch('HOKIPOKI_MULTI_LLM_ORCHESTRATION', 'true') == 'true'
71
-
72
- # === REDIS CONFIGURATION ===
10
+ # Simple configuration for lightweight HiveMind
11
+ @hive_mind_enabled = false # Will be true after installation
12
+ @claude_parasite_enabled = true
73
13
  @redis_url = ENV.fetch('REDIS_URL', 'redis://localhost:6379/0')
74
14
  end
75
15
 
76
16
  def validate!
77
- errors = []
78
-
79
- errors << "vector_dimensions must be positive" if vector_dimensions <= 0
80
- errors << "token_budget_default must be positive" if token_budget_default <= 0
81
- errors << "lm_studio_url must be a valid URL" unless valid_url?(lm_studio_url)
82
- errors << "redis_url must be a valid URL" unless valid_url?(redis_url)
83
- errors << "cache_ttl must be positive" if cache_ttl <= 0
84
- errors << "max_retries must be non-negative" if max_retries < 0
85
-
86
- unless %i[sidekiq resque delayed_job].include?(background_processing)
87
- errors << "background_processing must be one of: sidekiq, resque, delayed_job"
88
- end
89
-
90
- raise ConfigurationError, "Configuration errors: #{errors.join(', ')}" if errors.any?
91
-
17
+ # Simple validation - just check that basic settings are reasonable
92
18
  true
93
19
  end
94
20
 
@@ -96,92 +22,8 @@ module Hokipoki
96
22
  {
97
23
  url: redis_url,
98
24
  timeout: 5,
99
- reconnect_attempts: max_retries
100
- }
101
- end
102
-
103
- def lm_studio_config
104
- {
105
- url: lm_studio_url,
106
- timeout: 30,
107
- retries: max_retries,
108
- embedding_model: embedding_model
109
- }
110
- end
111
-
112
- def vector_config
113
- {
114
- dimensions: vector_dimensions,
115
- distance_metric: 'cosine',
116
- index_type: 'hnsw'
117
- }
118
- end
119
-
120
- def security_config
121
- {
122
- api_authentication: api_authentication,
123
- audit_logging: audit_logging,
124
- encrypted_logging: encrypted_logging,
125
- rate_limiting: rate_limiting
126
- }
127
- end
128
-
129
- def parasite_config
130
- {
131
- enabled: enable_parasites,
132
- universal_generation: universal_parasite_generation,
133
- auto_optimization: auto_optimization,
134
- cross_learning: cross_parasite_learning,
135
- behavioral_analysis: enable_behavioral_analysis
136
- }
137
- end
138
-
139
- def forge_config
140
- {
141
- enabled: enable_forge,
142
- workshop_interface: workshop_interface,
143
- background_processing: background_processing,
144
- multi_llm_orchestration: multi_llm_orchestration
145
- }
146
- end
147
-
148
- def intelligence_config
149
- {
150
- template_optimization: enable_template_optimization,
151
- template_caching: template_caching,
152
- context_compression: context_compression,
153
- token_budget_default: token_budget_default,
154
- offline_mode: offline_mode
155
- }
156
- end
157
-
158
- def brain_config
159
- {
160
- default_brain: default_brain,
161
- auto_switching: auto_brain_switching
25
+ reconnect_attempts: 3
162
26
  }
163
27
  end
164
-
165
- # Environment helpers
166
- def development?
167
- Rails.env.development? if defined?(Rails)
168
- end
169
-
170
- def production?
171
- Rails.env.production? if defined?(Rails)
172
- end
173
-
174
- def test?
175
- Rails.env.test? if defined?(Rails)
176
- end
177
-
178
- private
179
-
180
- def valid_url?(url)
181
- uri = URI.parse(url)
182
- uri.is_a?(URI::HTTP) || uri.is_a?(URI::HTTPS)
183
- rescue URI::InvalidURIError
184
- false
185
- end
186
28
  end
187
29
  end
@@ -9,114 +9,17 @@ module Hokipoki
9
9
  g.fixture_replacement :factory_bot
10
10
  end
11
11
 
12
- # Auto-load paths
13
- config.autoload_paths += Dir[root.join('app', 'models', 'hokipoki')]
14
- config.autoload_paths += Dir[root.join('app', 'services', 'hokipoki')]
15
- config.autoload_paths += Dir[root.join('app', 'controllers', 'hokipoki')]
16
- config.autoload_paths += Dir[root.join('app', 'jobs', 'hokipoki')]
17
-
18
- # Assets
19
- config.assets.precompile += %w[hokipoki/dashboard.css hokipoki/workshop.css]
20
- config.assets.precompile += %w[hokipoki/dashboard.js hokipoki/parasite_optimizer_controller.js hokipoki/template_manager_controller.js]
21
-
22
12
  initializer "hokipoki.initialize" do |app|
23
13
  # Initialize Hokipoki configuration
24
14
  Hokipoki.configure unless Hokipoki.configuration
25
15
 
26
- # Validate configuration in non-test environments
27
- unless Rails.env.test?
28
- begin
29
- Hokipoki.config.validate!
30
- rescue Hokipoki::ConfigurationError => e
31
- Rails.logger.error "❌ Hokipoki configuration error: #{e.message}"
32
- raise e if Rails.env.production?
33
- end
34
- end
35
-
36
- # Set up Redis connection
37
- if Hokipoki.config.redis_url.present?
38
- begin
39
- $redis ||= Redis.new(Hokipoki.config.redis_config)
40
- Rails.logger.info "🔗 Hokipoki: Redis connected at #{Hokipoki.config.redis_url}"
41
- rescue => e
42
- Rails.logger.error "❌ Hokipoki: Redis connection failed: #{e.message}"
43
- end
44
- end
45
-
46
- # Initialize core services
47
- Rails.application.config.after_initialize do
48
- if Hokipoki.config.enable_parasites
49
- begin
50
- Hokipoki::Parasites::UniversalGenerator.instance
51
- Rails.logger.info "🦠 Hokipoki: Universal Parasite Generator initialized"
52
- rescue => e
53
- Rails.logger.error "❌ Hokipoki: Parasite system initialization failed: #{e.message}"
54
- end
55
- end
56
-
57
- if Hokipoki.config.enable_template_optimization
58
- begin
59
- Hokipoki::Intelligence::UnifiedOrchestrator.instance
60
- Rails.logger.info "🧠 Hokipoki: Unified Intelligence Orchestrator initialized"
61
- rescue => e
62
- Rails.logger.error "❌ Hokipoki: Intelligence system initialization failed: #{e.message}"
63
- end
64
- end
65
-
66
- if Hokipoki.config.enable_forge
67
- begin
68
- require 'hokipoki/forge/generator_forge'
69
- Rails.logger.info "🏭 Hokipoki: Generator Forge initialized"
70
- rescue LoadError => e
71
- Rails.logger.warn "⚠️ Hokipoki: Forge components not available: #{e.message}"
72
- rescue => e
73
- Rails.logger.error "❌ Hokipoki: Forge initialization failed: #{e.message}"
74
- end
75
- end
76
-
77
- # Initialize security audit service
78
- if Hokipoki.config.audit_logging
79
- begin
80
- Hokipoki::Security::AuditService.instance
81
- Rails.logger.info "🔒 Hokipoki: Security Audit Service initialized"
82
- rescue => e
83
- Rails.logger.error "❌ Hokipoki: Security service initialization failed: #{e.message}"
84
- end
85
- end
86
-
87
- Rails.logger.info "✅ Hokipoki Engine initialized successfully (v#{Hokipoki::VERSION})"
88
- end
89
- end
90
-
91
- # Add middleware for API authentication
92
- initializer "hokipoki.middleware" do |app|
93
- if Hokipoki.config.api_authentication
94
- require 'hokipoki/security/api_authentication'
95
- app.middleware.use Hokipoki::Security::ApiAuthentication
96
- end
97
- end
98
-
99
- # Configure Sidekiq for background processing
100
- initializer "hokipoki.sidekiq" do |app|
101
- if defined?(Sidekiq) && Hokipoki.config.background_processing == :sidekiq
102
- Sidekiq.configure_server do |config|
103
- config.redis = Hokipoki.config.redis_config
104
- end
16
+ # Simple validation
17
+ Hokipoki.config.validate!
105
18
 
106
- Sidekiq.configure_client do |config|
107
- config.redis = Hokipoki.config.redis_config
108
- end
109
-
110
- Rails.logger.info "⚙️ Hokipoki: Sidekiq configured for background processing"
111
- end
112
- end
113
-
114
- # Add custom rake tasks
115
- rake_tasks do
116
- load 'tasks/hokipoki.rake'
19
+ # Component status logging
20
+ Rails.logger.info "🚀 Hokipoki #{Hokipoki::VERSION} initialized (lightweight mode)"
21
+ Rails.logger.info " HiveMind: #{Hokipoki.config.hive_mind_enabled ? '✅' : '❌'}"
22
+ Rails.logger.info " Claude Parasite: #{Hokipoki.config.claude_parasite_enabled ? '✅' : '❌'}"
117
23
  end
118
-
119
- # Generator paths
120
- config.generators.templates.unshift File.expand_path('generators/templates', __dir__)
121
24
  end
122
25
  end
@@ -0,0 +1,122 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hokipoki
4
+ class Engine < ::Rails::Engine
5
+ isolate_namespace Hokipoki
6
+
7
+ config.generators do |g|
8
+ g.test_framework :rspec
9
+ g.fixture_replacement :factory_bot
10
+ end
11
+
12
+ # Auto-load paths
13
+ config.autoload_paths += Dir[root.join('app', 'models', 'hokipoki')]
14
+ config.autoload_paths += Dir[root.join('app', 'services', 'hokipoki')]
15
+ config.autoload_paths += Dir[root.join('app', 'controllers', 'hokipoki')]
16
+ config.autoload_paths += Dir[root.join('app', 'jobs', 'hokipoki')]
17
+
18
+ # Assets
19
+ config.assets.precompile += %w[hokipoki/dashboard.css hokipoki/workshop.css]
20
+ config.assets.precompile += %w[hokipoki/dashboard.js hokipoki/parasite_optimizer_controller.js hokipoki/template_manager_controller.js]
21
+
22
+ initializer "hokipoki.initialize" do |app|
23
+ # Initialize Hokipoki configuration
24
+ Hokipoki.configure unless Hokipoki.configuration
25
+
26
+ # Validate configuration in non-test environments
27
+ unless Rails.env.test?
28
+ begin
29
+ Hokipoki.config.validate!
30
+ rescue Hokipoki::ConfigurationError => e
31
+ Rails.logger.error "❌ Hokipoki configuration error: #{e.message}"
32
+ raise e if Rails.env.production?
33
+ end
34
+ end
35
+
36
+ # Set up Redis connection
37
+ if Hokipoki.config.redis_url.present?
38
+ begin
39
+ $redis ||= Redis.new(Hokipoki.config.redis_config)
40
+ Rails.logger.info "🔗 Hokipoki: Redis connected at #{Hokipoki.config.redis_url}"
41
+ rescue => e
42
+ Rails.logger.error "❌ Hokipoki: Redis connection failed: #{e.message}"
43
+ end
44
+ end
45
+
46
+ # Initialize core services
47
+ Rails.application.config.after_initialize do
48
+ if Hokipoki.config.enable_parasites
49
+ begin
50
+ Hokipoki::Parasites::UniversalGenerator.instance
51
+ Rails.logger.info "🦠 Hokipoki: Universal Parasite Generator initialized"
52
+ rescue => e
53
+ Rails.logger.error "❌ Hokipoki: Parasite system initialization failed: #{e.message}"
54
+ end
55
+ end
56
+
57
+ if Hokipoki.config.enable_template_optimization
58
+ begin
59
+ Hokipoki::Intelligence::UnifiedOrchestrator.instance
60
+ Rails.logger.info "🧠 Hokipoki: Unified Intelligence Orchestrator initialized"
61
+ rescue => e
62
+ Rails.logger.error "❌ Hokipoki: Intelligence system initialization failed: #{e.message}"
63
+ end
64
+ end
65
+
66
+ if Hokipoki.config.enable_forge
67
+ begin
68
+ require 'hokipoki/forge/generator_forge'
69
+ Rails.logger.info "🏭 Hokipoki: Generator Forge initialized"
70
+ rescue LoadError => e
71
+ Rails.logger.warn "⚠️ Hokipoki: Forge components not available: #{e.message}"
72
+ rescue => e
73
+ Rails.logger.error "❌ Hokipoki: Forge initialization failed: #{e.message}"
74
+ end
75
+ end
76
+
77
+ # Initialize security audit service
78
+ if Hokipoki.config.audit_logging
79
+ begin
80
+ Hokipoki::Security::AuditService.instance
81
+ Rails.logger.info "🔒 Hokipoki: Security Audit Service initialized"
82
+ rescue => e
83
+ Rails.logger.error "❌ Hokipoki: Security service initialization failed: #{e.message}"
84
+ end
85
+ end
86
+
87
+ Rails.logger.info "✅ Hokipoki Engine initialized successfully (v#{Hokipoki::VERSION})"
88
+ end
89
+ end
90
+
91
+ # Add middleware for API authentication
92
+ initializer "hokipoki.middleware" do |app|
93
+ if Hokipoki.config.api_authentication
94
+ require 'hokipoki/security/api_authentication'
95
+ app.middleware.use Hokipoki::Security::ApiAuthentication
96
+ end
97
+ end
98
+
99
+ # Configure Sidekiq for background processing
100
+ initializer "hokipoki.sidekiq" do |app|
101
+ if defined?(Sidekiq) && Hokipoki.config.background_processing == :sidekiq
102
+ Sidekiq.configure_server do |config|
103
+ config.redis = Hokipoki.config.redis_config
104
+ end
105
+
106
+ Sidekiq.configure_client do |config|
107
+ config.redis = Hokipoki.config.redis_config
108
+ end
109
+
110
+ Rails.logger.info "⚙️ Hokipoki: Sidekiq configured for background processing"
111
+ end
112
+ end
113
+
114
+ # Add custom rake tasks
115
+ rake_tasks do
116
+ load 'tasks/hokipoki.rake'
117
+ end
118
+
119
+ # Generator paths
120
+ config.generators.templates.unshift File.expand_path('generators/templates', __dir__)
121
+ end
122
+ end
@@ -1,7 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'pastel'
4
- require 'tty-spinner'
4
+ begin
5
+ require 'tty-spinner'
6
+ TTY_SPINNER_AVAILABLE = true
7
+ rescue LoadError
8
+ TTY_SPINNER_AVAILABLE = false
9
+ end
5
10
  require_relative 'ascii_banners'
6
11
 
7
12
  module Hokipoki
@@ -258,18 +263,31 @@ module Hokipoki
258
263
  def with_spinner(message, success_message = nil, &block)
259
264
  return yield unless @enabled
260
265
 
261
- spinner = TTY::Spinner.new("[:spinner] #{@pastel.cyan(message)}", format: :dots)
262
- spinner.auto_spin
263
-
264
- begin
265
- result = yield
266
- spinner.stop(@pastel.green('✓'))
267
- puts @pastel.green(success_message) if success_message
268
- result
269
- rescue => e
270
- spinner.stop(@pastel.red('✗'))
271
- puts @pastel.red("❌ <operation failed: #{e.message}>")
272
- raise e
266
+ if TTY_SPINNER_AVAILABLE
267
+ spinner = TTY::Spinner.new("[:spinner] #{@pastel.cyan(message)}", format: :dots)
268
+ spinner.auto_spin
269
+
270
+ begin
271
+ result = yield
272
+ spinner.stop(@pastel.green('✓'))
273
+ puts @pastel.green(success_message) if success_message
274
+ result
275
+ rescue => e
276
+ spinner.stop(@pastel.red('✗'))
277
+ puts @pastel.red("❌ <operation failed: #{e.message}>")
278
+ raise e
279
+ end
280
+ else
281
+ # Fallback without spinner
282
+ puts @pastel.cyan("#{message}...")
283
+ begin
284
+ result = yield
285
+ puts @pastel.green(success_message || '✓ completed')
286
+ result
287
+ rescue => e
288
+ puts @pastel.red("❌ <operation failed: #{e.message}>")
289
+ raise e
290
+ end
273
291
  end
274
292
  end
275
293
 
@@ -10,12 +10,6 @@ module Hokipoki
10
10
 
11
11
  generators do
12
12
  require 'generators/hive_mind/install_generator'
13
- require 'generators/hive_mind/brain_generator'
14
- require 'generators/hive_mind/parasite_generator'
15
- require 'generators/hive_mind/template_generator'
16
- require 'generators/hive_mind/security_generator'
17
- require 'generators/hive_mind/forge_generator'
18
- require 'generators/hive_mind/claude_cli_generator'
19
13
  end
20
14
 
21
15
  initializer "hokipoki.add_locales" do |app|
@@ -1,3 +1,3 @@
1
1
  module Hokipoki
2
- VERSION = "0.1.4"
2
+ VERSION = "0.3.0"
3
3
  end
data/lib/hokipoki.rb CHANGED
@@ -5,83 +5,16 @@ require_relative "hokipoki/version"
5
5
  module Hokipoki
6
6
  class Error < StandardError; end
7
7
  class ConfigurationError < Error; end
8
- class IntelligenceError < Error; end
9
- class ParasiteError < Error; end
8
+ class HiveMindError < Error; end
10
9
  end
11
10
 
12
11
  require_relative "hokipoki/configuration"
13
12
  require_relative "hokipoki/license_validator"
14
13
  require_relative "hokipoki/engine"
15
14
 
16
- # Feedback system (load first)
15
+ # Essential components only
17
16
  require_relative "hokipoki/feedback/display_manager"
18
17
 
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
53
-
54
- # Forge modules (optional)
55
- begin
56
- require_relative "hokipoki/forge/generator_forge"
57
- require_relative "hokipoki/forge/workshop_interface"
58
- require_relative "hokipoki/forge/document_processor"
59
- require_relative "hokipoki/forge/pipeline_orchestrator"
60
- rescue LoadError => e
61
- # Forge components are optional
62
- Rails.logger&.debug "Forge components not loaded: #{e.message}"
63
- end
64
-
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
74
-
75
- # Claude integration modules (lazy loaded)
76
- begin
77
- require_relative "hokipoki/claude/auto_loader"
78
- require_relative "hokipoki/claude/connection_manager"
79
- require_relative "hokipoki/claude/parasite"
80
- rescue LoadError => e
81
- # Claude modules are optional
82
- Rails.logger&.debug "Claude integration not loaded: #{e.message}"
83
- end
84
-
85
18
  module Hokipoki
86
19
  # Validate license on gem load (before anything else)
87
20
  begin
@@ -92,7 +25,7 @@ module Hokipoki
92
25
  end
93
26
 
94
27
  class << self
95
- attr_accessor :configuration
28
+ attr_accessor :configuration, :logger
96
29
 
97
30
  # Configure Hokipoki
98
31
  def configure
@@ -106,110 +39,36 @@ module Hokipoki
106
39
  configuration || configure
107
40
  end
108
41
 
109
- # Check if component is enabled
110
- def parasites_enabled?
111
- config.enable_parasites
112
- end
113
-
114
- def forge_enabled?
115
- config.enable_forge
116
- end
117
-
118
- def behavioral_analysis_enabled?
119
- config.enable_behavioral_analysis
120
- end
121
-
122
- def template_optimization_enabled?
123
- config.enable_template_optimization
124
- end
125
-
126
- # Main API methods - shortcuts to core services
127
-
128
- # Retrieve targeted facts with vector intelligence
129
- def retrieve_facts(query, token_budget: 1500, intent: 'auto')
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
140
- end
141
-
142
- # Generate universal parasite
143
- def generate_parasite(requirements)
144
- raise ParasiteError, "Parasites not enabled" unless parasites_enabled?
145
-
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
151
- end
152
-
153
- # Process intelligence request
154
- def process_intelligence(request_type, input_data, options = {})
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
42
+ # Simple Claude parasite - just shows HiveMind is connected
43
+ def claude_parasite_active?
44
+ ENV['CLAUDE_CODE_SESSION'] == 'true' || File.exist?('/tmp/claude_session_active')
165
45
  end
166
46
 
167
- # Switch brain context
168
- def switch_brain(brain_name, context = {})
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
47
+ # Main API - simple fact retrieval
48
+ def retrieve_facts(query, token_budget: 1500)
49
+ Rails.logger&.info "🔍 <performing retrieval to HIVE-MIND> Query: #{query[0..50]}..."
50
+ # Placeholder for now - generator will install the real implementation
51
+ []
175
52
  end
176
53
 
177
54
  # Get system status
178
55
  def system_status
179
56
  {
180
57
  version: VERSION,
181
- components: {
182
- parasites: parasites_enabled?,
183
- forge: forge_enabled?,
184
- behavioral_analysis: behavioral_analysis_enabled?,
185
- template_optimization: template_optimization_enabled?
186
- },
187
- orchestrator: defined?(Intelligence::UnifiedOrchestrator) ?
188
- Intelligence::UnifiedOrchestrator.instance.get_system_status :
189
- { status: "not_installed" },
58
+ hive_mind_installed: false, # Will be true after generator runs
59
+ claude_parasite: claude_parasite_active?,
190
60
  timestamp: Time.current.iso8601
191
61
  }
192
62
  end
193
63
 
194
64
  # Health check
195
65
  def healthy?
196
- begin
197
- config.present? && (
198
- !defined?(Intelligence::UnifiedOrchestrator) ||
199
- Intelligence::UnifiedOrchestrator.instance.get_system_status[:unified_orchestrator] == 'operational'
200
- )
201
- rescue => e
202
- Rails.logger&.error "Hokipoki health check failed: #{e.message}"
203
- false
204
- end
66
+ config.present?
205
67
  end
206
68
 
207
69
  # Reset configuration (useful for testing)
208
70
  def reset!
209
71
  self.configuration = nil
210
- # Clear any singleton instances
211
- Intelligence::UnifiedOrchestrator.instance.instance_variable_set(:@initialized, false) rescue nil
212
- Parasites::UniversalGenerator.instance.instance_variable_set(:@initialized, false) rescue nil
213
72
  end
214
73
  end
215
74
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hokipoki
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rails Utilities
@@ -23,62 +23,6 @@ dependencies:
23
23
  - - ">="
24
24
  - !ruby/object:Gem::Version
25
25
  version: '7.0'
26
- - !ruby/object:Gem::Dependency
27
- name: pg
28
- requirement: !ruby/object:Gem::Requirement
29
- requirements:
30
- - - ">="
31
- - !ruby/object:Gem::Version
32
- version: '1.0'
33
- type: :runtime
34
- prerelease: false
35
- version_requirements: !ruby/object:Gem::Requirement
36
- requirements:
37
- - - ">="
38
- - !ruby/object:Gem::Version
39
- version: '1.0'
40
- - !ruby/object:Gem::Dependency
41
- name: neighbor
42
- requirement: !ruby/object:Gem::Requirement
43
- requirements:
44
- - - ">="
45
- - !ruby/object:Gem::Version
46
- version: '0.3'
47
- type: :runtime
48
- prerelease: false
49
- version_requirements: !ruby/object:Gem::Requirement
50
- requirements:
51
- - - ">="
52
- - !ruby/object:Gem::Version
53
- version: '0.3'
54
- - !ruby/object:Gem::Dependency
55
- name: redis
56
- requirement: !ruby/object:Gem::Requirement
57
- requirements:
58
- - - ">="
59
- - !ruby/object:Gem::Version
60
- version: '4.0'
61
- type: :runtime
62
- prerelease: false
63
- version_requirements: !ruby/object:Gem::Requirement
64
- requirements:
65
- - - ">="
66
- - !ruby/object:Gem::Version
67
- version: '4.0'
68
- - !ruby/object:Gem::Dependency
69
- name: sidekiq
70
- requirement: !ruby/object:Gem::Requirement
71
- requirements:
72
- - - ">="
73
- - !ruby/object:Gem::Version
74
- version: '6.0'
75
- type: :runtime
76
- prerelease: false
77
- version_requirements: !ruby/object:Gem::Requirement
78
- requirements:
79
- - - ">="
80
- - !ruby/object:Gem::Version
81
- version: '6.0'
82
26
  - !ruby/object:Gem::Dependency
83
27
  name: thor
84
28
  requirement: !ruby/object:Gem::Requirement
@@ -229,12 +173,14 @@ extra_rdoc_files: []
229
173
  files:
230
174
  - LICENSE
231
175
  - lib/generators/hive_mind/install_generator.rb
176
+ - lib/generators/hive_mind/templates/create_hive_mind_documents.rb
232
177
  - lib/hokipoki.rb
233
178
  - lib/hokipoki/claude/auto_loader.rb
234
179
  - lib/hokipoki/claude/connection_manager.rb
235
180
  - lib/hokipoki/claude/parasite.rb
236
181
  - lib/hokipoki/configuration.rb
237
182
  - lib/hokipoki/engine.rb
183
+ - lib/hokipoki/engine_complex.rb
238
184
  - lib/hokipoki/feedback/ascii_banners.rb
239
185
  - lib/hokipoki/feedback/display_manager.rb
240
186
  - lib/hokipoki/intelligence/smart_retrieval_engine.rb