hokipoki 0.3.4 → 0.5.1
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 +18 -2
- data/lib/generators/hive_mind/start_generator.rb +582 -0
- data/lib/generators/hive_mind/templates/hokipoki_claude.rb +45 -0
- data/lib/generators/hokipoki/attach_parasite_generator.rb +355 -0
- data/lib/generators/hokipoki/install_generator.rb +515 -0
- data/lib/generators/hokipoki/scan_project_generator.rb +279 -0
- data/lib/generators/parasite/install_generator.rb +458 -0
- data/lib/hokipoki/atomic_fact_extractor.rb +524 -0
- data/lib/hokipoki/claude/parasite.rb +62 -10
- data/lib/hokipoki/claude/thought_interceptor.rb +385 -0
- data/lib/hokipoki/claude_auto_loader.rb +28 -11
- data/lib/hokipoki/template_store.rb +425 -0
- data/lib/hokipoki/vector_engine.rb +525 -0
- data/lib/hokipoki/version.rb +1 -1
- data/lib/hokipoki.rb +260 -6
- metadata +81 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 241b9f3c0f528d0f8b0500b00bf7192403a00aa57235975947624590ec7d7e3a
|
|
4
|
+
data.tar.gz: 593c1527aaab3c3a23fdd22cfd7b3cd8b46386d5a3bca4ff8c327e2818f93e31
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 367b1dbf7a3293499f84dfd33c72dd772aa3d4e9dbf705f03c0b8a2a3747672ce277e8f2d87dac0ac95353735ef96b54bd137be5c11a1673c11076fa23feb532
|
|
7
|
+
data.tar.gz: b29d3769b6888e714b8cdd24188a2651c07059e0179b82275cf9e02f6f92e5b79fccfaf8d8af69bd30902f13c3c408f1aa08d83b6e0f5afe22599a84b54f3ab0
|
|
@@ -39,12 +39,28 @@ module HiveMind
|
|
|
39
39
|
say "\n"
|
|
40
40
|
end
|
|
41
41
|
|
|
42
|
+
def check_hokipoki_installation
|
|
43
|
+
unless File.exist?('config/initializers/hokipoki.rb')
|
|
44
|
+
say @pastel.red("❌ Hokipoki not installed!")
|
|
45
|
+
say @pastel.yellow("Please run: rails g hokipoki:install first")
|
|
46
|
+
say @pastel.white("This sets up core dependencies and authentication.")
|
|
47
|
+
exit(1)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
say @pastel.green("✅ Hokipoki core detected")
|
|
51
|
+
end
|
|
52
|
+
|
|
42
53
|
def gather_installation_preferences
|
|
43
|
-
|
|
54
|
+
say @pastel.cyan("\n🧠 HiveMind Installation (Step 2/3)")
|
|
55
|
+
say @pastel.white("Core Hokipoki detected - proceeding with HiveMind setup...")
|
|
56
|
+
|
|
57
|
+
# Always install minimal lightweight version for Claude
|
|
44
58
|
@config = {
|
|
45
59
|
hive_mind_enabled: true,
|
|
46
60
|
claude_parasite_enabled: true,
|
|
47
|
-
skip_complex_components: true
|
|
61
|
+
skip_complex_components: true,
|
|
62
|
+
vector_intelligence: true,
|
|
63
|
+
template_compression: true
|
|
48
64
|
}
|
|
49
65
|
end
|
|
50
66
|
|
|
@@ -0,0 +1,582 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'rails/generators'
|
|
4
|
+
|
|
5
|
+
module HiveMind
|
|
6
|
+
module Generators
|
|
7
|
+
# HiveMind Start Generator - Orchestrates Claude + HiveMind connection
|
|
8
|
+
# Command: rails g hive_mind:start
|
|
9
|
+
class StartGenerator < Rails::Generators::Base
|
|
10
|
+
source_root File.expand_path('templates', __dir__)
|
|
11
|
+
|
|
12
|
+
class_option :port, type: :numeric, default: 3000,
|
|
13
|
+
desc: 'Port for Rails server'
|
|
14
|
+
|
|
15
|
+
class_option :claude_terminal, type: :string, default: 'auto',
|
|
16
|
+
desc: 'Claude terminal identifier (auto-detect or specify)'
|
|
17
|
+
|
|
18
|
+
class_option :background, type: :boolean, default: false,
|
|
19
|
+
desc: 'Run server in background'
|
|
20
|
+
|
|
21
|
+
def display_hive_mind_startup_banner
|
|
22
|
+
say "\n🧠 HIVE MIND STARTUP ORCHESTRATOR", :magenta
|
|
23
|
+
say "=" * 60, :magenta
|
|
24
|
+
say "Initiating connection between Claude CLI and HiveMind...", :white
|
|
25
|
+
say "This will start Rails server and establish parasitic intelligence link.", :yellow
|
|
26
|
+
say ""
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def validate_hive_mind_installation
|
|
30
|
+
say "🔍 VALIDATING HIVE MIND INSTALLATION:", :cyan
|
|
31
|
+
|
|
32
|
+
# Check core installations
|
|
33
|
+
required_files = [
|
|
34
|
+
'config/initializers/hokipoki.rb',
|
|
35
|
+
'app/models/hive_mind_document.rb',
|
|
36
|
+
'config/initializers/parasitic_intelligence.rb'
|
|
37
|
+
]
|
|
38
|
+
|
|
39
|
+
missing_files = required_files.reject { |file| File.exist?(file) }
|
|
40
|
+
|
|
41
|
+
if missing_files.any?
|
|
42
|
+
say "❌ Missing components:", :red
|
|
43
|
+
missing_files.each { |file| say " - #{file}", :white }
|
|
44
|
+
say ""
|
|
45
|
+
say "🔧 Run installation commands:", :yellow
|
|
46
|
+
say " rails g hokipoki:install", :white
|
|
47
|
+
say " rails g hive_mind:install", :white
|
|
48
|
+
say " rails g parasite:install", :white
|
|
49
|
+
exit(1)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
say " ✅ All components installed", :green
|
|
53
|
+
say ""
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def detect_claude_environment
|
|
57
|
+
say "🦠 DETECTING CLAUDE ENVIRONMENT:", :cyan
|
|
58
|
+
|
|
59
|
+
# Check various Claude CLI indicators
|
|
60
|
+
claude_indicators = []
|
|
61
|
+
claude_indicators << "ANTHROPIC_API_KEY present" if ENV['ANTHROPIC_API_KEY'].present?
|
|
62
|
+
claude_indicators << "Claude CLI process detected" if claude_process_running?
|
|
63
|
+
claude_indicators << "Claude session active" if File.exist?('/tmp/claude_session_active')
|
|
64
|
+
claude_indicators << "Terminal session: #{get_terminal_info}" if get_terminal_info
|
|
65
|
+
|
|
66
|
+
if claude_indicators.any?
|
|
67
|
+
say " ✅ Claude CLI detected:", :green
|
|
68
|
+
claude_indicators.each { |indicator| say " - #{indicator}", :white }
|
|
69
|
+
else
|
|
70
|
+
say " ⚠️ Claude CLI not clearly detected", :yellow
|
|
71
|
+
say " Proceeding anyway - will activate when Claude connects", :white
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
say ""
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def create_connection_script
|
|
78
|
+
say "🔧 CREATING CONNECTION SCRIPT:", :cyan
|
|
79
|
+
|
|
80
|
+
# Create the hive_mind connection script
|
|
81
|
+
create_file "bin/hive_mind_connect", connection_script_content
|
|
82
|
+
chmod "bin/hive_mind_connect", 0755
|
|
83
|
+
|
|
84
|
+
say " ✅ Created bin/hive_mind_connect", :green
|
|
85
|
+
|
|
86
|
+
# Create terminal communication system
|
|
87
|
+
create_terminal_communication_system
|
|
88
|
+
|
|
89
|
+
say " ✅ Terminal communication system ready", :green
|
|
90
|
+
say ""
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
def start_hive_mind_server
|
|
94
|
+
say "🚀 STARTING HIVE MIND SERVER:", :cyan
|
|
95
|
+
|
|
96
|
+
# Create server startup script with communication
|
|
97
|
+
server_script = create_server_startup_script
|
|
98
|
+
|
|
99
|
+
if options[:background]
|
|
100
|
+
say " 🔄 Starting Rails server in background (port #{options[:port]})...", :white
|
|
101
|
+
start_background_server
|
|
102
|
+
else
|
|
103
|
+
say " 🔄 Starting Rails server (port #{options[:port]})...", :white
|
|
104
|
+
say " 📡 Server will ping Claude terminal when ready", :yellow
|
|
105
|
+
say ""
|
|
106
|
+
|
|
107
|
+
# Display the command to run
|
|
108
|
+
display_startup_command
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
def display_connection_instructions
|
|
113
|
+
say "🎯 HIVE MIND CONNECTION READY!", :green
|
|
114
|
+
say "=" * 50, :green
|
|
115
|
+
say ""
|
|
116
|
+
say "📋 NEXT STEPS:", :cyan
|
|
117
|
+
say ""
|
|
118
|
+
say "1. 🖥️ In this terminal, run:", :white
|
|
119
|
+
say " bin/hive_mind_connect", :yellow
|
|
120
|
+
say ""
|
|
121
|
+
say "2. 🧠 In Claude terminal, you'll see:", :white
|
|
122
|
+
say " '🦠 HIVE MIND CONNECTION ESTABLISHED'", :yellow
|
|
123
|
+
say " ASCII art confirmation", :white
|
|
124
|
+
say " Connection status and capabilities", :white
|
|
125
|
+
say ""
|
|
126
|
+
say "3. ✨ Experience enhanced Claude:", :white
|
|
127
|
+
say " - Project-aware responses", :green
|
|
128
|
+
say " - Vector intelligence injection", :green
|
|
129
|
+
say " - Real-time context enhancement", :green
|
|
130
|
+
say ""
|
|
131
|
+
say "🔧 MANUAL START (if needed):", :cyan
|
|
132
|
+
say " rails server -p #{options[:port]}", :white
|
|
133
|
+
say ""
|
|
134
|
+
say "🆘 TROUBLESHOOTING:", :cyan
|
|
135
|
+
say " - If no connection: Check firewall/port #{options[:port]}", :white
|
|
136
|
+
say " - If no enhancement: Verify vector database", :white
|
|
137
|
+
say " - If errors: Check Rails logs", :white
|
|
138
|
+
say ""
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
private
|
|
142
|
+
|
|
143
|
+
def claude_process_running?
|
|
144
|
+
`ps aux | grep -i claude | grep -v grep`.strip.present?
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
def get_terminal_info
|
|
148
|
+
terminal_app = ENV['TERM_PROGRAM'] || ENV['TERMINAL_EMULATOR'] || 'unknown'
|
|
149
|
+
session_id = ENV['TERM_SESSION_ID'] || Process.pid.to_s
|
|
150
|
+
"#{terminal_app} (#{session_id})"
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
def connection_script_content
|
|
154
|
+
<<~BASH
|
|
155
|
+
#!/bin/bash
|
|
156
|
+
# HiveMind Connection Script
|
|
157
|
+
# Generated by: rails g hive_mind:start
|
|
158
|
+
|
|
159
|
+
set -e
|
|
160
|
+
|
|
161
|
+
# Configuration
|
|
162
|
+
PORT=#{options[:port]}
|
|
163
|
+
RAILS_ENV=${RAILS_ENV:-development}
|
|
164
|
+
HIVE_MIND_LOG="/tmp/hive_mind_connection.log"
|
|
165
|
+
CLAUDE_PING_FILE="/tmp/claude_hive_mind_ping"
|
|
166
|
+
|
|
167
|
+
# Colors for output
|
|
168
|
+
RED='\\033[0;31m'
|
|
169
|
+
GREEN='\\033[0;32m'
|
|
170
|
+
YELLOW='\\033[1;33m'
|
|
171
|
+
CYAN='\\033[0;36m'
|
|
172
|
+
MAGENTA='\\033[0;35m'
|
|
173
|
+
NC='\\033[0m' # No Color
|
|
174
|
+
|
|
175
|
+
echo -e "${MAGENTA}🧠 HIVE MIND CONNECTION INITIATOR${NC}"
|
|
176
|
+
echo -e "${MAGENTA}$(printf '=%.0s' {1..50})${NC}"
|
|
177
|
+
echo -e "${YELLOW}Starting HiveMind server and establishing Claude connection...${NC}"
|
|
178
|
+
echo ""
|
|
179
|
+
|
|
180
|
+
# Clear any existing ping files
|
|
181
|
+
rm -f "$CLAUDE_PING_FILE"
|
|
182
|
+
rm -f "$HIVE_MIND_LOG"
|
|
183
|
+
|
|
184
|
+
# Function to send ping to Claude terminal
|
|
185
|
+
ping_claude_terminal() {
|
|
186
|
+
local status="$1"
|
|
187
|
+
local message="$2"
|
|
188
|
+
|
|
189
|
+
echo "{
|
|
190
|
+
\\"timestamp\\": \\"$(date -u +%Y-%m-%dT%H:%M:%SZ)\\",
|
|
191
|
+
\\"status\\": \\"$status\\",
|
|
192
|
+
\\"message\\": \\"$message\\",
|
|
193
|
+
\\"port\\": $PORT,
|
|
194
|
+
\\"pid\\": $$
|
|
195
|
+
}" > "$CLAUDE_PING_FILE"
|
|
196
|
+
|
|
197
|
+
# Also display in this terminal
|
|
198
|
+
echo -e "${GREEN}📡 PING CLAUDE: $message${NC}"
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
# Function to display ASCII art
|
|
202
|
+
display_hive_mind_art() {
|
|
203
|
+
cat << 'EOF'
|
|
204
|
+
#{hive_mind_ascii_art}
|
|
205
|
+
EOF
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
# Start Rails server with enhanced monitoring
|
|
209
|
+
start_rails_server() {
|
|
210
|
+
echo -e "${CYAN}🔄 Starting Rails server on port $PORT...${NC}"
|
|
211
|
+
|
|
212
|
+
# Check if port is available
|
|
213
|
+
if lsof -Pi :$PORT -sTCP:LISTEN -t >/dev/null 2>&1; then
|
|
214
|
+
echo -e "${RED}❌ Port $PORT is already in use${NC}"
|
|
215
|
+
echo -e "${YELLOW}💡 Kill existing process: lsof -ti:$PORT | xargs kill -9${NC}"
|
|
216
|
+
exit 1
|
|
217
|
+
fi
|
|
218
|
+
|
|
219
|
+
# Start server in background and monitor
|
|
220
|
+
rails server -p $PORT -e $RAILS_ENV > "$HIVE_MIND_LOG" 2>&1 &
|
|
221
|
+
local server_pid=$!
|
|
222
|
+
|
|
223
|
+
echo -e "${YELLOW}⏳ Waiting for server to start (PID: $server_pid)...${NC}"
|
|
224
|
+
|
|
225
|
+
# Wait for server to be ready
|
|
226
|
+
local attempts=0
|
|
227
|
+
local max_attempts=30
|
|
228
|
+
|
|
229
|
+
while [ $attempts -lt $max_attempts ]; do
|
|
230
|
+
if curl -s "http://localhost:$PORT" >/dev/null 2>&1; then
|
|
231
|
+
echo -e "${GREEN}✅ Rails server is ready!${NC}"
|
|
232
|
+
break
|
|
233
|
+
fi
|
|
234
|
+
|
|
235
|
+
sleep 1
|
|
236
|
+
attempts=$((attempts + 1))
|
|
237
|
+
echo -e "${YELLOW} Attempt $attempts/$max_attempts...${NC}"
|
|
238
|
+
done
|
|
239
|
+
|
|
240
|
+
if [ $attempts -eq $max_attempts ]; then
|
|
241
|
+
echo -e "${RED}❌ Server failed to start within timeout${NC}"
|
|
242
|
+
echo -e "${YELLOW}📋 Check logs: tail -f $HIVE_MIND_LOG${NC}"
|
|
243
|
+
exit 1
|
|
244
|
+
fi
|
|
245
|
+
|
|
246
|
+
return $server_pid
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
# Function to test HiveMind intelligence
|
|
250
|
+
test_hive_mind_intelligence() {
|
|
251
|
+
echo -e "${CYAN}🧠 Testing HiveMind intelligence...${NC}"
|
|
252
|
+
|
|
253
|
+
# Test vector engine
|
|
254
|
+
local test_result=$(rails runner "
|
|
255
|
+
begin
|
|
256
|
+
if defined?(Hokipoki::VectorEngine)
|
|
257
|
+
engine = Hokipoki::VectorEngine.instance
|
|
258
|
+
stats = engine.statistics
|
|
259
|
+
puts \\"✅ Vector Engine: #{stats[:total_vectors]} vectors ready\\"
|
|
260
|
+
else
|
|
261
|
+
puts \\"⚠️ Vector Engine: Not available\\"
|
|
262
|
+
end
|
|
263
|
+
rescue => e
|
|
264
|
+
puts \\"❌ Vector Engine: #{e.message}\\"
|
|
265
|
+
end
|
|
266
|
+
" 2>&1)
|
|
267
|
+
|
|
268
|
+
echo -e "${WHITE}$test_result${NC}"
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
# Main execution
|
|
272
|
+
echo -e "${CYAN}🚀 INITIATING HIVE MIND STARTUP SEQUENCE${NC}"
|
|
273
|
+
echo ""
|
|
274
|
+
|
|
275
|
+
# Step 1: Start Rails server
|
|
276
|
+
ping_claude_terminal "starting" "Initializing HiveMind server..."
|
|
277
|
+
start_rails_server
|
|
278
|
+
server_pid=$?
|
|
279
|
+
|
|
280
|
+
# Step 2: Test intelligence systems
|
|
281
|
+
ping_claude_terminal "testing" "Testing intelligence systems..."
|
|
282
|
+
test_hive_mind_intelligence
|
|
283
|
+
|
|
284
|
+
# Step 3: Establish connection
|
|
285
|
+
ping_claude_terminal "connecting" "Establishing parasitic intelligence link..."
|
|
286
|
+
sleep 2
|
|
287
|
+
|
|
288
|
+
# Step 4: Final connection confirmation
|
|
289
|
+
ping_claude_terminal "connected" "HiveMind connection established! Intelligence enhanced."
|
|
290
|
+
|
|
291
|
+
# Display success
|
|
292
|
+
echo ""
|
|
293
|
+
echo -e "${GREEN}🎉 HIVE MIND CONNECTION ESTABLISHED!${NC}"
|
|
294
|
+
display_hive_mind_art
|
|
295
|
+
echo ""
|
|
296
|
+
echo -e "${CYAN}📊 CONNECTION STATUS:${NC}"
|
|
297
|
+
echo -e "${GREEN} 🟢 Rails Server: Running on port $PORT${NC}"
|
|
298
|
+
echo -e "${GREEN} 🟢 Vector Intelligence: Online${NC}"
|
|
299
|
+
echo -e "${GREEN} 🟢 Parasitic Enhancement: Active${NC}"
|
|
300
|
+
echo -e "${GREEN} 🟢 Claude Connection: Established${NC}"
|
|
301
|
+
echo ""
|
|
302
|
+
echo -e "${YELLOW}🦠 Claude CLI is now enhanced with project intelligence!${NC}"
|
|
303
|
+
echo -e "${YELLOW}📡 Server PID: $server_pid | Logs: $HIVE_MIND_LOG${NC}"
|
|
304
|
+
echo ""
|
|
305
|
+
echo -e "${MAGENTA}Press Ctrl+C to stop HiveMind server${NC}"
|
|
306
|
+
|
|
307
|
+
# Keep server running and monitor
|
|
308
|
+
wait $server_pid
|
|
309
|
+
BASH
|
|
310
|
+
end
|
|
311
|
+
|
|
312
|
+
def create_terminal_communication_system
|
|
313
|
+
# Create Claude terminal monitor
|
|
314
|
+
create_file "bin/claude_monitor", claude_monitor_script
|
|
315
|
+
chmod "bin/claude_monitor", 0755
|
|
316
|
+
|
|
317
|
+
# Create connection status checker
|
|
318
|
+
create_file "lib/tasks/hive_mind.rake", hive_mind_rake_tasks
|
|
319
|
+
end
|
|
320
|
+
|
|
321
|
+
def claude_monitor_script
|
|
322
|
+
<<~BASH
|
|
323
|
+
#!/bin/bash
|
|
324
|
+
# Claude Terminal Monitor
|
|
325
|
+
# Monitors for HiveMind connection pings and displays them in Claude terminal
|
|
326
|
+
|
|
327
|
+
PING_FILE="/tmp/claude_hive_mind_ping"
|
|
328
|
+
LAST_PING=""
|
|
329
|
+
|
|
330
|
+
# Colors
|
|
331
|
+
GREEN='\\033[0;32m'
|
|
332
|
+
CYAN='\\033[0;36m'
|
|
333
|
+
MAGENTA='\\033[0;35m'
|
|
334
|
+
YELLOW='\\033[1;33m'
|
|
335
|
+
NC='\\033[0m'
|
|
336
|
+
|
|
337
|
+
# ASCII Art for connection confirmation
|
|
338
|
+
display_connection_art() {
|
|
339
|
+
cat << 'EOF'
|
|
340
|
+
#{claude_connection_ascii_art}
|
|
341
|
+
EOF
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
echo -e "${CYAN}🦠 Claude HiveMind Monitor - Waiting for connection...${NC}"
|
|
345
|
+
|
|
346
|
+
# Monitor for pings
|
|
347
|
+
while true; do
|
|
348
|
+
if [ -f "$PING_FILE" ]; then
|
|
349
|
+
CURRENT_PING=$(cat "$PING_FILE" 2>/dev/null || echo "")
|
|
350
|
+
|
|
351
|
+
if [ "$CURRENT_PING" != "$LAST_PING" ] && [ -n "$CURRENT_PING" ]; then
|
|
352
|
+
# Parse the ping
|
|
353
|
+
STATUS=$(echo "$CURRENT_PING" | grep -o '"status":"[^"]*"' | cut -d'"' -f4)
|
|
354
|
+
MESSAGE=$(echo "$CURRENT_PING" | grep -o '"message":"[^"]*"' | cut -d'"' -f4)
|
|
355
|
+
|
|
356
|
+
case "$STATUS" in
|
|
357
|
+
"starting")
|
|
358
|
+
echo -e "${YELLOW}🔄 $MESSAGE${NC}"
|
|
359
|
+
;;
|
|
360
|
+
"testing")
|
|
361
|
+
echo -e "${CYAN}🧠 $MESSAGE${NC}"
|
|
362
|
+
;;
|
|
363
|
+
"connecting")
|
|
364
|
+
echo -e "${MAGENTA}🦠 $MESSAGE${NC}"
|
|
365
|
+
;;
|
|
366
|
+
"connected")
|
|
367
|
+
echo -e "${GREEN}✅ $MESSAGE${NC}"
|
|
368
|
+
echo ""
|
|
369
|
+
display_connection_art
|
|
370
|
+
echo -e "${GREEN}🎉 CLAUDE CLI ENHANCED WITH HIVE MIND INTELLIGENCE!${NC}"
|
|
371
|
+
break
|
|
372
|
+
;;
|
|
373
|
+
esac
|
|
374
|
+
|
|
375
|
+
LAST_PING="$CURRENT_PING"
|
|
376
|
+
fi
|
|
377
|
+
fi
|
|
378
|
+
|
|
379
|
+
sleep 0.5
|
|
380
|
+
done
|
|
381
|
+
BASH
|
|
382
|
+
end
|
|
383
|
+
|
|
384
|
+
def hive_mind_rake_tasks
|
|
385
|
+
<<~RUBY
|
|
386
|
+
# HiveMind Rake Tasks
|
|
387
|
+
namespace :hive_mind do
|
|
388
|
+
desc "Check HiveMind connection status"
|
|
389
|
+
task status: :environment do
|
|
390
|
+
puts "\\n🧠 HIVE MIND STATUS REPORT"
|
|
391
|
+
puts "=" * 40
|
|
392
|
+
|
|
393
|
+
# Check components
|
|
394
|
+
components = [
|
|
395
|
+
{ name: "Hokipoki Core", check: -> { defined?(Hokipoki) } },
|
|
396
|
+
{ name: "Vector Engine", check: -> { defined?(Hokipoki::VectorEngine) } },
|
|
397
|
+
{ name: "Template Store", check: -> { defined?(Hokipoki::TemplateStore) } },
|
|
398
|
+
{ name: "Fact Extractor", check: -> { defined?(Hokipoki::AtomicFactExtractor) } },
|
|
399
|
+
{ name: "HiveMind Documents", check: -> { defined?(HiveMindDocument) } },
|
|
400
|
+
{ name: "Claude Detection", check: -> { Hokipoki.claude_parasite_active? } }
|
|
401
|
+
]
|
|
402
|
+
|
|
403
|
+
components.each do |component|
|
|
404
|
+
status = component[:check].call ? "🟢 ONLINE" : "🔴 OFFLINE"
|
|
405
|
+
puts " \#{component[:name].ljust(20)} \#{status}"
|
|
406
|
+
end
|
|
407
|
+
|
|
408
|
+
# Vector statistics
|
|
409
|
+
if defined?(Hokipoki::VectorEngine)
|
|
410
|
+
puts "\\n📊 VECTOR STATISTICS:"
|
|
411
|
+
stats = Hokipoki::VectorEngine.instance.statistics
|
|
412
|
+
puts " Total Vectors: \#{stats[:total_vectors]}"
|
|
413
|
+
puts " Success Rate: \#{stats[:success_rate]}%"
|
|
414
|
+
puts " Compression: \#{stats[:average_compression]}%"
|
|
415
|
+
end
|
|
416
|
+
|
|
417
|
+
puts "\\n🦠 Claude Enhancement: \#{Hokipoki.claude_parasite_active? ? 'ACTIVE' : 'STANDBY'}"
|
|
418
|
+
puts ""
|
|
419
|
+
end
|
|
420
|
+
|
|
421
|
+
desc "Test HiveMind intelligence retrieval"
|
|
422
|
+
task :test, [:query] => :environment do |t, args|
|
|
423
|
+
query = args[:query] || "test hive mind connection"
|
|
424
|
+
|
|
425
|
+
puts "\\n🧠 TESTING INTELLIGENCE RETRIEVAL"
|
|
426
|
+
puts "Query: \#{query}"
|
|
427
|
+
puts "-" * 40
|
|
428
|
+
|
|
429
|
+
begin
|
|
430
|
+
facts = Hokipoki.retrieve_facts(query, token_budget: 1000)
|
|
431
|
+
|
|
432
|
+
if facts.any?
|
|
433
|
+
puts "✅ SUCCESS: Retrieved \#{facts.length} facts"
|
|
434
|
+
facts.each_with_index do |fact, i|
|
|
435
|
+
puts " \#{i+1}. \#{fact[0..100]}..."
|
|
436
|
+
end
|
|
437
|
+
else
|
|
438
|
+
puts "⚠️ No facts retrieved (may be normal for test query)"
|
|
439
|
+
end
|
|
440
|
+
rescue => e
|
|
441
|
+
puts "❌ ERROR: \#{e.message}"
|
|
442
|
+
end
|
|
443
|
+
|
|
444
|
+
puts ""
|
|
445
|
+
end
|
|
446
|
+
|
|
447
|
+
desc "Start Claude connection monitor"
|
|
448
|
+
task monitor: :environment do
|
|
449
|
+
puts "🦠 Starting Claude connection monitor..."
|
|
450
|
+
exec "bin/claude_monitor"
|
|
451
|
+
end
|
|
452
|
+
end
|
|
453
|
+
RUBY
|
|
454
|
+
end
|
|
455
|
+
|
|
456
|
+
def create_server_startup_script
|
|
457
|
+
# This creates the actual startup sequence
|
|
458
|
+
startup_content = <<~RUBY
|
|
459
|
+
# HiveMind Server Startup with Claude Communication
|
|
460
|
+
Rails.application.configure do
|
|
461
|
+
config.after_initialize do
|
|
462
|
+
Thread.new do
|
|
463
|
+
sleep(2) # Let Rails fully start
|
|
464
|
+
|
|
465
|
+
# Check if this is a HiveMind startup
|
|
466
|
+
if ENV['HIVE_MIND_STARTUP'] == 'true'
|
|
467
|
+
puts "\\n🧠 HIVE MIND: Server initialization complete"
|
|
468
|
+
puts "🦠 PARASITE: Ready for Claude CLI connection"
|
|
469
|
+
puts "📡 STATUS: Broadcasting readiness signal..."
|
|
470
|
+
|
|
471
|
+
# Create readiness signal
|
|
472
|
+
File.write('/tmp/hive_mind_ready', {
|
|
473
|
+
timestamp: Time.current.iso8601,
|
|
474
|
+
port: Rails.application.config.port || 3000,
|
|
475
|
+
status: 'ready',
|
|
476
|
+
vector_count: defined?(Hokipoki::VectorEngine) ?
|
|
477
|
+
Hokipoki::VectorEngine.instance.statistics[:total_vectors] : 0
|
|
478
|
+
}.to_json)
|
|
479
|
+
|
|
480
|
+
puts "✅ READY: HiveMind intelligence active on port \#{Rails.application.config.port || 3000}"
|
|
481
|
+
end
|
|
482
|
+
end
|
|
483
|
+
end
|
|
484
|
+
end
|
|
485
|
+
RUBY
|
|
486
|
+
|
|
487
|
+
append_to_file "config/environments/development.rb", startup_content
|
|
488
|
+
end
|
|
489
|
+
|
|
490
|
+
def start_background_server
|
|
491
|
+
# Start server in background with environment variable
|
|
492
|
+
cmd = "HIVE_MIND_STARTUP=true rails server -p #{options[:port]} -d"
|
|
493
|
+
system(cmd)
|
|
494
|
+
|
|
495
|
+
# Wait for server and ping Claude
|
|
496
|
+
30.times do
|
|
497
|
+
if system("curl -s http://localhost:#{options[:port]} > /dev/null 2>&1")
|
|
498
|
+
ping_claude_about_connection
|
|
499
|
+
break
|
|
500
|
+
end
|
|
501
|
+
sleep(1)
|
|
502
|
+
end
|
|
503
|
+
end
|
|
504
|
+
|
|
505
|
+
def ping_claude_about_connection
|
|
506
|
+
ping_data = {
|
|
507
|
+
timestamp: Time.current.iso8601,
|
|
508
|
+
status: 'connected',
|
|
509
|
+
message: 'HiveMind connection established! Intelligence enhanced.',
|
|
510
|
+
port: options[:port]
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
File.write('/tmp/claude_hive_mind_ping', ping_data.to_json)
|
|
514
|
+
say "📡 Claude terminal pinged about successful connection", :green
|
|
515
|
+
end
|
|
516
|
+
|
|
517
|
+
def display_startup_command
|
|
518
|
+
say "🚀 READY TO CONNECT! Run this command:", :green
|
|
519
|
+
say ""
|
|
520
|
+
say " bin/hive_mind_connect", :yellow
|
|
521
|
+
say ""
|
|
522
|
+
say "🦠 This will:", :cyan
|
|
523
|
+
say " 1. Start Rails server on port #{options[:port]}", :white
|
|
524
|
+
say " 2. Initialize vector intelligence", :white
|
|
525
|
+
say " 3. Ping Claude terminal with connection status", :white
|
|
526
|
+
say " 4. Display ASCII art confirmation", :white
|
|
527
|
+
say ""
|
|
528
|
+
end
|
|
529
|
+
|
|
530
|
+
def hive_mind_ascii_art
|
|
531
|
+
<<~ASCII
|
|
532
|
+
🧠 HIVE MIND INTELLIGENCE NETWORK 🧠
|
|
533
|
+
╔══════════════════════════════════════════════════╗
|
|
534
|
+
║ ██╗ ██╗██╗██╗ ██╗███████╗ ║
|
|
535
|
+
║ ██║ ██║██║██║ ██║██╔════╝ ║
|
|
536
|
+
║ ███████║██║██║ ██║█████╗ ║
|
|
537
|
+
║ ██╔══██║██║╚██╗ ██╔╝██╔══╝ ║
|
|
538
|
+
║ ██║ ██║██║ ╚████╔╝ ███████╗ ║
|
|
539
|
+
║ ╚═╝ ╚═╝╚═╝ ╚═══╝ ╚══════╝ ║
|
|
540
|
+
║ ║
|
|
541
|
+
║ ███╗ ███╗██╗███╗ ██╗██████╗ ║
|
|
542
|
+
║ ████╗ ████║██║████╗ ██║██╔══██╗ ║
|
|
543
|
+
║ ██╔████╔██║██║██╔██╗ ██║██║ ██║ ║
|
|
544
|
+
║ ██║╚██╔╝██║██║██║╚██╗██║██║ ██║ ║
|
|
545
|
+
║ ██║ ╚═╝ ██║██║██║ ╚████║██████╔╝ ║
|
|
546
|
+
║ ╚═╝ ╚═╝╚═╝╚═╝ ╚═══╝╚═════╝ ║
|
|
547
|
+
║ ║
|
|
548
|
+
║ 🦠 PARASITIC INTELLIGENCE: CONNECTED ║
|
|
549
|
+
║ 🧠 VECTOR DATABASE: ONLINE ║
|
|
550
|
+
║ 🎯 CLAUDE ENHANCEMENT: MAXIMUM ║
|
|
551
|
+
║ ⚡ STATUS: INTELLIGENCE AMPLIFIED ║
|
|
552
|
+
╚══════════════════════════════════════════════════╝
|
|
553
|
+
ASCII
|
|
554
|
+
end
|
|
555
|
+
|
|
556
|
+
def claude_connection_ascii_art
|
|
557
|
+
<<~ASCII
|
|
558
|
+
🦠🦠🦠 CLAUDE ↔ HIVE MIND CONNECTION 🦠🦠🦠
|
|
559
|
+
|
|
560
|
+
██████╗██╗ █████╗ ██╗ ██╗██████╗ ███████╗
|
|
561
|
+
██╔════╝██║ ██╔══██╗██║ ██║██╔══██╗██╔════╝
|
|
562
|
+
██║ ██║ ███████║██║ ██║██║ ██║█████╗
|
|
563
|
+
██║ ██║ ██╔══██║██║ ██║██║ ██║██╔══╝
|
|
564
|
+
╚██████╗███████╗██║ ██║╚██████╔╝██████╔╝███████╗
|
|
565
|
+
╚═════╝╚══════╝╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚══════╝
|
|
566
|
+
|
|
567
|
+
↕️ ↕️ ↕️ ↕️ ↕️ ↕️ ↕️ ↕️ ↕️ ↕️ ↕️ ↕️ ↕️ ↕️ ↕️ ↕️ ↕️ ↕️ ↕️ ↕️
|
|
568
|
+
|
|
569
|
+
🧠 H I V E M I N D I N T E L L I G E N C E 🧠
|
|
570
|
+
|
|
571
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
572
|
+
🎯 ENHANCEMENT STATUS: PARASITIC INTELLIGENCE ACTIVE
|
|
573
|
+
📊 VECTOR DATABASE: SYNCHRONIZED WITH CLAUDE
|
|
574
|
+
🚀 RESPONSE QUALITY: AMPLIFIED 10X
|
|
575
|
+
🦠 THOUGHT INJECTION: TRANSPARENT & SURGICAL
|
|
576
|
+
⚡ LEARNING SYSTEM: CONTINUOUSLY IMPROVING
|
|
577
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
578
|
+
ASCII
|
|
579
|
+
end
|
|
580
|
+
end
|
|
581
|
+
end
|
|
582
|
+
end
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# HokiPoki Claude Integration Initializer
|
|
2
|
+
# This initializer activates the parasitic intelligence enhancement system
|
|
3
|
+
|
|
4
|
+
Rails.application.configure do
|
|
5
|
+
# Force Claude detection during development
|
|
6
|
+
if Rails.env.development?
|
|
7
|
+
ENV['FORCE_CLAUDE_DETECTION'] = 'true'
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
# Configure after initialization to ensure all components are loaded
|
|
11
|
+
config.after_initialize do
|
|
12
|
+
# Set up Claude session markers
|
|
13
|
+
if Hokipoki.claude_parasite_active?
|
|
14
|
+
# Create session marker
|
|
15
|
+
File.write('/tmp/claude_session_active', Time.current.to_s)
|
|
16
|
+
|
|
17
|
+
# Display activation banner
|
|
18
|
+
banner = "\n" + "🦠" * 50 + "\n"
|
|
19
|
+
banner += "🧠 HOKIPOKI PARASITIC INTELLIGENCE INITIALIZED\n"
|
|
20
|
+
banner += "🦠" * 50 + "\n"
|
|
21
|
+
banner += "🎯 Claude enhancement: ACTIVE\n"
|
|
22
|
+
banner += "📊 Vector intelligence: READY\n"
|
|
23
|
+
banner += "🚀 Thought hijacking: ENABLED\n"
|
|
24
|
+
banner += "🦠" * 50 + "\n\n"
|
|
25
|
+
|
|
26
|
+
# Ensure Claude sees this
|
|
27
|
+
$stdout.puts banner
|
|
28
|
+
puts banner
|
|
29
|
+
|
|
30
|
+
Rails.logger.info "🦠 HokiPoki: Parasitic intelligence system activated"
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# Load Claude integration if available
|
|
34
|
+
begin
|
|
35
|
+
require 'hokipoki/claude/auto_loader'
|
|
36
|
+
Hokipoki::ClaudeAutoLoader.force_load! if Hokipoki.claude_parasite_active?
|
|
37
|
+
rescue LoadError => e
|
|
38
|
+
Rails.logger.warn "🦠 HokiPoki: Claude integration not available: #{e.message}"
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# Log configuration
|
|
44
|
+
Rails.logger.info "🦠 HokiPoki Claude initializer loaded"
|
|
45
|
+
puts "🦠 HOKIPOKI: Parasitic intelligence initializer active"
|