claude-flow-novice 1.3.0 → 1.3.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.
- package/.claude-flow-novice/preferences/generation.json +147 -0
- package/.claude-flow-novice/preferences/language-configs/javascript.json +51 -0
- package/.claude-flow-novice/preferences/language-configs/python.json +50 -0
- package/.claude-flow-novice/preferences/language-configs/rust.json +237 -0
- package/.claude-flow-novice/preferences/language-configs/typescript.json +54 -0
- package/.claude-flow-novice/preferences/project-local.json +91 -0
- package/.claude-flow-novice/preferences/resource-delegation.json +120 -0
- package/.claude-flow-novice/preferences/team-shared.json +195 -0
- package/.claude-flow-novice/preferences/user-global.json +247 -0
- package/.claude-flow-novice/templates/claude-md-templates/CLAUDE-JAVASCRIPT.md +769 -0
- package/.claude-flow-novice/templates/claude-md-templates/CLAUDE-PYTHON.md +1214 -0
- package/.claude-flow-novice/templates/claude-md-templates/CLAUDE-RUST.md +475 -0
- package/.claude-flow-novice/templates/claude-md-templates/CLAUDE-TYPESCRIPT.md +851 -0
- package/.claude-flow-novice/templates/claude-md-templates/README.md +263 -0
- package/CLAUDE.md +81 -0
- package/README-NPM.md +0 -0
- package/package.json +11 -7
- package/scripts/build/README.md +167 -0
- package/scripts/build/build-config.js +27 -0
- package/scripts/build/build-prompt-copier.sh +30 -0
- package/scripts/build/performance-monitor.js +869 -0
- package/scripts/build/prepare-publish.js +150 -0
- package/scripts/build/typescript-fixer.js +621 -0
- package/scripts/build/unified-builder.sh +428 -0
- package/scripts/build/update-bin-version.js +32 -0
- package/scripts/dev/README.md +264 -0
- package/scripts/dev/claude-flow-wrapper.sh +35 -0
- package/scripts/dev/claude-monitor.py +419 -0
- package/scripts/dev/claude-sparc.sh +562 -0
- package/scripts/dev/claude-wrapper.sh +17 -0
- package/scripts/dev/demo-phase3-compliance.js +172 -0
- package/scripts/dev/demo-task-system.ts +224 -0
- package/scripts/dev/deployment-validator.js +315 -0
- package/scripts/dev/spawn-claude-terminal.sh +32 -0
- package/scripts/dev/start-portal.sh +506 -0
- package/scripts/dev/start-web-ui.js +15 -0
- package/scripts/dev/stop-portal.sh +311 -0
- package/scripts/dev/validate-examples.ts +288 -0
- package/scripts/dev/validate-phase2.cjs +451 -0
- package/scripts/dev/validate-phase2.js +785 -0
- package/scripts/dev/validate-phase3.cjs +208 -0
- package/scripts/dev/validate-security-remediation.js +1 -0
- package/scripts/legacy/README.md +272 -0
- package/scripts/legacy/batch-fix-ts.sh +54 -0
- package/scripts/legacy/build-migration.sh +105 -0
- package/scripts/legacy/build-monitor.js +209 -0
- package/scripts/legacy/build-with-filter.sh +84 -0
- package/scripts/legacy/build-workaround.sh +71 -0
- package/scripts/legacy/fix-ts-advanced.js +358 -0
- package/scripts/legacy/fix-ts-final.sh +50 -0
- package/scripts/legacy/fix-ts-targeted.sh +49 -0
- package/scripts/legacy/fix-typescript-errors.js +305 -0
- package/scripts/legacy/force-build.sh +63 -0
- package/scripts/legacy/optimize-performance.js +400 -0
- package/scripts/legacy/performance-monitor.js +263 -0
- package/scripts/legacy/performance-monitoring.js +532 -0
- package/scripts/legacy/performance-test-runner.js +645 -0
- package/scripts/legacy/quick-fix-ts.js +281 -0
- package/scripts/legacy/safe-build.sh +63 -0
- package/scripts/migration/README.md +434 -0
- package/scripts/migration/install-arm64.js +78 -0
- package/scripts/migration/install.js +83 -0
- package/scripts/migration/migrate-hooks.js +173 -0
- package/scripts/migration/migration-examples.ts +318 -0
- package/scripts/optimization/build-optimizer.js +438 -0
- package/scripts/optimization/config-validator.js +761 -0
- package/scripts/optimization/test-optimization.js +432 -0
- package/scripts/optimization/unified-activation.js +839 -0
- package/scripts/performance/ACTIVATION_COMMANDS.md +292 -0
- package/scripts/performance/sqlite-enhanced-activation.sh +583 -0
- package/scripts/performance/test-enhanced-backend.sh +504 -0
- package/scripts/performance-test-runner.js +698 -0
- package/scripts/security/README.md +339 -0
- package/scripts/security/install-git-hooks.sh +132 -0
- package/scripts/security/ruv-swarm-safe.js +74 -0
- package/scripts/test/README.md +236 -0
- package/scripts/test/check-links.ts +274 -0
- package/scripts/test/check-performance-regression.ts +168 -0
- package/scripts/test/coverage-report.ts +692 -0
- package/scripts/test/generate-swarm-tests.js +633 -0
- package/scripts/test/integration-test-validation.cjs +253 -0
- package/scripts/test/load-test-swarm.js +576 -0
- package/scripts/test/run-phase3-compliance-tests.js +427 -0
- package/scripts/test/test-batch-tasks.ts +29 -0
- package/scripts/test/test-byzantine-resolution.js +246 -0
- package/scripts/test/test-claude-spawn-options.sh +63 -0
- package/scripts/test/test-cli-wizard.js +331 -0
- package/scripts/test/test-comprehensive.js +401 -0
- package/scripts/test/test-coordination-features.ts +238 -0
- package/scripts/test/test-fallback-systems.js +276 -0
- package/scripts/test/test-init-command.ts +302 -0
- package/scripts/test/test-mcp.ts +251 -0
- package/scripts/test/test-runner.ts +568 -0
- package/scripts/test/test-swarm-integration.sh +92 -0
- package/scripts/test/test-swarm.ts +142 -0
- package/scripts/test/validation-summary.ts +408 -0
- package/scripts/utils/README.md +261 -0
- package/scripts/utils/clean-build-artifacts.sh +94 -0
- package/scripts/utils/cleanup-root.sh +69 -0
- package/scripts/utils/fix-cliffy-imports.js +307 -0
- package/scripts/utils/fix-duplicate-imports.js +114 -0
- package/scripts/utils/fix-error-handling.cjs +70 -0
- package/scripts/utils/fix-import-paths.js +104 -0
- package/scripts/utils/fix-imports.js +116 -0
- package/scripts/utils/fix-shebang.js +78 -0
- package/scripts/utils/fix-test-modules.js +27 -0
- package/scripts/utils/fix-timezone-issue-246.js +200 -0
- package/scripts/utils/fix-ts-comprehensive.py +182 -0
- package/scripts/utils/fix-ts-targeted-batch.js +250 -0
- package/scripts/utils/remove-benchmark-conflicts.sh +140 -0
- package/scripts/utils/simple-test-fixer.js +190 -0
- package/scripts/utils/validate-metrics-structure.cjs +144 -0
- package/scripts/verify-mcp-server.js +86 -0
- package/src/cli/simple-commands/__tests__/agent.test.js +291 -0
- package/src/cli/simple-commands/__tests__/memory.test.js +8 -0
- package/src/cli/simple-commands/__tests__/swarm.test.js +371 -0
- package/src/cli/simple-commands/__tests__/task.test.js +8 -0
- package/src/cli/simple-commands/agent.js +216 -0
- package/src/cli/simple-commands/analysis.js +570 -0
- package/src/cli/simple-commands/automation-executor.js +1603 -0
- package/src/cli/simple-commands/automation.js +627 -0
- package/src/cli/simple-commands/batch-manager.js +338 -0
- package/src/cli/simple-commands/claude-telemetry.js +311 -0
- package/src/cli/simple-commands/claude-track.js +102 -0
- package/src/cli/simple-commands/concurrent-display.js +348 -0
- package/src/cli/simple-commands/config.js +319 -0
- package/src/cli/simple-commands/coordination.js +307 -0
- package/src/cli/simple-commands/enhanced-ui-views.js +654 -0
- package/src/cli/simple-commands/enhanced-webui-complete.js +1038 -0
- package/src/cli/simple-commands/fix-hook-variables.js +363 -0
- package/src/cli/simple-commands/github/gh-coordinator.js +605 -0
- package/src/cli/simple-commands/github/github-api.js +624 -0
- package/src/cli/simple-commands/github/init.js +543 -0
- package/src/cli/simple-commands/github.js +377 -0
- package/src/cli/simple-commands/goal.js +145 -0
- package/src/cli/simple-commands/hive-mind/auto-save-middleware.js +311 -0
- package/src/cli/simple-commands/hive-mind/communication.js +740 -0
- package/src/cli/simple-commands/hive-mind/core.js +1031 -0
- package/src/cli/simple-commands/hive-mind/db-optimizer.js +872 -0
- package/src/cli/simple-commands/hive-mind/mcp-wrapper.js +1364 -0
- package/src/cli/simple-commands/hive-mind/memory.js +1292 -0
- package/src/cli/simple-commands/hive-mind/performance-optimizer.js +618 -0
- package/src/cli/simple-commands/hive-mind/performance-test.js +373 -0
- package/src/cli/simple-commands/hive-mind/queen.js +809 -0
- package/src/cli/simple-commands/hive-mind/session-manager.js +1223 -0
- package/src/cli/simple-commands/hive-mind-optimize.js +361 -0
- package/src/cli/simple-commands/hive-mind-wizard.js +281 -0
- package/src/cli/simple-commands/hive-mind.js +3112 -0
- package/src/cli/simple-commands/hive.js +140 -0
- package/src/cli/simple-commands/hook-safety.js +671 -0
- package/src/cli/simple-commands/hooks.js +1268 -0
- package/src/cli/simple-commands/init/.claude/checkpoints/1756224542.json +7 -0
- package/src/cli/simple-commands/init/.claude/checkpoints/1756224544.json +8 -0
- package/src/cli/simple-commands/init/README.md +106 -0
- package/src/cli/simple-commands/init/VALIDATION_ROLLBACK.md +488 -0
- package/src/cli/simple-commands/init/agent-copier.js +347 -0
- package/src/cli/simple-commands/init/batch-init.js +663 -0
- package/src/cli/simple-commands/init/claude-commands/claude-flow-commands.js +438 -0
- package/src/cli/simple-commands/init/claude-commands/optimized-claude-flow-commands.js +876 -0
- package/src/cli/simple-commands/init/claude-commands/optimized-slash-commands.js +356 -0
- package/src/cli/simple-commands/init/claude-commands/optimized-sparc-commands.js +501 -0
- package/src/cli/simple-commands/init/claude-commands/slash-commands.js +57 -0
- package/src/cli/simple-commands/init/claude-commands/sparc-commands.js +296 -0
- package/src/cli/simple-commands/init/copy-revised-templates.js +175 -0
- package/src/cli/simple-commands/init/executable-wrapper.js +122 -0
- package/src/cli/simple-commands/init/gitignore-updater.js +137 -0
- package/src/cli/simple-commands/init/help.js +110 -0
- package/src/cli/simple-commands/init/hive-mind-init.js +749 -0
- package/src/cli/simple-commands/init/index.js +1953 -0
- package/src/cli/simple-commands/init/performance-monitor.js +344 -0
- package/src/cli/simple-commands/init/rollback/backup-manager.js +542 -0
- package/src/cli/simple-commands/init/rollback/index.js +399 -0
- package/src/cli/simple-commands/init/rollback/recovery-manager.js +778 -0
- package/src/cli/simple-commands/init/rollback/rollback-executor.js +521 -0
- package/src/cli/simple-commands/init/rollback/state-tracker.js +486 -0
- package/src/cli/simple-commands/init/sparc/roo-readme.js +61 -0
- package/src/cli/simple-commands/init/sparc/roomodes-config.js +102 -0
- package/src/cli/simple-commands/init/sparc/workflows.js +40 -0
- package/src/cli/simple-commands/init/sparc-structure.js +68 -0
- package/src/cli/simple-commands/init/template-copier.js +640 -0
- package/src/cli/simple-commands/init/templates/CLAUDE.md +1185 -0
- package/src/cli/simple-commands/init/templates/CLAUDE.md.optimized +265 -0
- package/src/cli/simple-commands/init/templates/claude-flow-universal +81 -0
- package/src/cli/simple-commands/init/templates/claude-flow.bat +18 -0
- package/src/cli/simple-commands/init/templates/claude-flow.ps1 +24 -0
- package/src/cli/simple-commands/init/templates/claude-md.js +1101 -0
- package/src/cli/simple-commands/init/templates/commands/analysis/bottleneck-detect.md +162 -0
- package/src/cli/simple-commands/init/templates/commands/automation/auto-agent.md +122 -0
- package/src/cli/simple-commands/init/templates/commands/coordination/swarm-init.md +85 -0
- package/src/cli/simple-commands/init/templates/commands/github/github-swarm.md +121 -0
- package/src/cli/simple-commands/init/templates/commands/helpers/standard-checkpoint-hooks.sh +179 -0
- package/src/cli/simple-commands/init/templates/commands/hooks/notification.md +113 -0
- package/src/cli/simple-commands/init/templates/commands/hooks/post-command.md +116 -0
- package/src/cli/simple-commands/init/templates/commands/hooks/post-edit.md +117 -0
- package/src/cli/simple-commands/init/templates/commands/hooks/post-task.md +112 -0
- package/src/cli/simple-commands/init/templates/commands/hooks/pre-command.md +113 -0
- package/src/cli/simple-commands/init/templates/commands/hooks/pre-edit.md +113 -0
- package/src/cli/simple-commands/init/templates/commands/hooks/pre-search.md +112 -0
- package/src/cli/simple-commands/init/templates/commands/hooks/pre-task.md +111 -0
- package/src/cli/simple-commands/init/templates/commands/hooks/session-end.md +118 -0
- package/src/cli/simple-commands/init/templates/commands/hooks/session-restore.md +118 -0
- package/src/cli/simple-commands/init/templates/commands/hooks/session-start.md +117 -0
- package/src/cli/simple-commands/init/templates/coordination-md.js +340 -0
- package/src/cli/simple-commands/init/templates/coordination.md +16 -0
- package/src/cli/simple-commands/init/templates/enhanced-templates.js +2347 -0
- package/src/cli/simple-commands/init/templates/github-safe-enhanced.js +331 -0
- package/src/cli/simple-commands/init/templates/github-safe.js +106 -0
- package/src/cli/simple-commands/init/templates/memory-bank-md.js +259 -0
- package/src/cli/simple-commands/init/templates/memory-bank.md +16 -0
- package/src/cli/simple-commands/init/templates/readme-files.js +72 -0
- package/src/cli/simple-commands/init/templates/safe-hook-patterns.js +430 -0
- package/src/cli/simple-commands/init/templates/settings.json +109 -0
- package/src/cli/simple-commands/init/templates/settings.json.enhanced +35 -0
- package/src/cli/simple-commands/init/templates/sparc-modes.js +1401 -0
- package/src/cli/simple-commands/init/templates/verification-claude-md.js +432 -0
- package/src/cli/simple-commands/init/validation/config-validator.js +354 -0
- package/src/cli/simple-commands/init/validation/health-checker.js +599 -0
- package/src/cli/simple-commands/init/validation/index.js +388 -0
- package/src/cli/simple-commands/init/validation/mode-validator.js +387 -0
- package/src/cli/simple-commands/init/validation/post-init-validator.js +390 -0
- package/src/cli/simple-commands/init/validation/pre-init-validator.js +290 -0
- package/src/cli/simple-commands/init/validation/test-runner.js +488 -0
- package/src/cli/simple-commands/init.js +4 -0
- package/src/cli/simple-commands/mcp-health.js +163 -0
- package/src/cli/simple-commands/mcp-integration-layer.js +689 -0
- package/src/cli/simple-commands/mcp.js +420 -0
- package/src/cli/simple-commands/memory-consolidation.js +631 -0
- package/src/cli/simple-commands/memory.js +345 -0
- package/src/cli/simple-commands/migrate-hooks.js +63 -0
- package/src/cli/simple-commands/monitor.js +417 -0
- package/src/cli/simple-commands/neural.js +148 -0
- package/src/cli/simple-commands/pair-autofix-only.js +755 -0
- package/src/cli/simple-commands/pair-basic.js +751 -0
- package/src/cli/simple-commands/pair-old.js +623 -0
- package/src/cli/simple-commands/pair-working.js +849 -0
- package/src/cli/simple-commands/pair.js +849 -0
- package/src/cli/simple-commands/performance-hooks.js +149 -0
- package/src/cli/simple-commands/performance-metrics.js +601 -0
- package/src/cli/simple-commands/process-ui-enhanced.js +821 -0
- package/src/cli/simple-commands/process-ui.js +274 -0
- package/src/cli/simple-commands/realtime-update-system.js +659 -0
- package/src/cli/simple-commands/sparc/architecture.js +1750 -0
- package/src/cli/simple-commands/sparc/commands.js +575 -0
- package/src/cli/simple-commands/sparc/completion.js +1831 -0
- package/src/cli/simple-commands/sparc/coordinator.js +1045 -0
- package/src/cli/simple-commands/sparc/index.js +321 -0
- package/src/cli/simple-commands/sparc/phase-base.js +430 -0
- package/src/cli/simple-commands/sparc/pseudocode.js +984 -0
- package/src/cli/simple-commands/sparc/refinement.js +1856 -0
- package/src/cli/simple-commands/sparc/specification.js +736 -0
- package/src/cli/simple-commands/sparc-modes/architect.js +125 -0
- package/src/cli/simple-commands/sparc-modes/ask.js +126 -0
- package/src/cli/simple-commands/sparc-modes/code.js +148 -0
- package/src/cli/simple-commands/sparc-modes/debug.js +112 -0
- package/src/cli/simple-commands/sparc-modes/devops.js +137 -0
- package/src/cli/simple-commands/sparc-modes/docs-writer.js +38 -0
- package/src/cli/simple-commands/sparc-modes/generic.js +34 -0
- package/src/cli/simple-commands/sparc-modes/index.js +201 -0
- package/src/cli/simple-commands/sparc-modes/integration.js +55 -0
- package/src/cli/simple-commands/sparc-modes/mcp.js +38 -0
- package/src/cli/simple-commands/sparc-modes/monitoring.js +38 -0
- package/src/cli/simple-commands/sparc-modes/optimization.js +38 -0
- package/src/cli/simple-commands/sparc-modes/security-review.js +130 -0
- package/src/cli/simple-commands/sparc-modes/sparc-orchestrator.js +167 -0
- package/src/cli/simple-commands/sparc-modes/spec-pseudocode.js +38 -0
- package/src/cli/simple-commands/sparc-modes/supabase-admin.js +149 -0
- package/src/cli/simple-commands/sparc-modes/swarm.js +436 -0
- package/src/cli/simple-commands/sparc-modes/tdd.js +112 -0
- package/src/cli/simple-commands/sparc-modes/tutorial.js +277 -0
- package/src/cli/simple-commands/sparc.js +530 -0
- package/src/cli/simple-commands/start-ui.js +147 -0
- package/src/cli/simple-commands/start-wrapper.js +285 -0
- package/src/cli/simple-commands/start.js +2 -0
- package/src/cli/simple-commands/status.js +303 -0
- package/src/cli/simple-commands/stream-chain-clean.js +221 -0
- package/src/cli/simple-commands/stream-chain-fixed.js +89 -0
- package/src/cli/simple-commands/stream-chain-real.js +408 -0
- package/src/cli/simple-commands/stream-chain-working.js +323 -0
- package/src/cli/simple-commands/stream-chain.js +491 -0
- package/src/cli/simple-commands/stream-processor.js +340 -0
- package/src/cli/simple-commands/swarm-executor.js +253 -0
- package/src/cli/simple-commands/swarm-metrics-integration.js +371 -0
- package/src/cli/simple-commands/swarm-ui.js +741 -0
- package/src/cli/simple-commands/swarm-webui-integration.js +311 -0
- package/src/cli/simple-commands/swarm.js +2277 -0
- package/src/cli/simple-commands/task.js +228 -0
- package/src/cli/simple-commands/templates/mle-star-workflow.json +294 -0
- package/src/cli/simple-commands/timestamp-fix.js +104 -0
- package/src/cli/simple-commands/token-tracker.js +372 -0
- package/src/cli/simple-commands/tool-execution-framework.js +555 -0
- package/src/cli/simple-commands/train-and-stream.js +354 -0
- package/src/cli/simple-commands/training-pipeline.js +874 -0
- package/src/cli/simple-commands/training.js +288 -0
- package/src/cli/simple-commands/verification-hooks.js +336 -0
- package/src/cli/simple-commands/verification-integration.js +464 -0
- package/src/cli/simple-commands/verification-training-integration.js +646 -0
- package/src/cli/simple-commands/verification.js +551 -0
- package/src/cli/simple-commands/web-server.js +929 -0
- package/src/cli/simple-commands/webui-validator.js +136 -0
- package/src/language/README.md +503 -0
- package/src/language/claude-md-generator.js +618 -0
- package/src/language/cli.js +422 -0
- package/src/language/example.js +347 -0
- package/src/language/integration-system.js +619 -0
- package/src/language/language-detector.js +581 -0
|
@@ -0,0 +1,749 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hive Mind Initialization Module for Claude Flow v2.0.0
|
|
3
|
+
* Provides comprehensive hive-mind system setup for the init process
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { promises as fs } from 'fs';
|
|
7
|
+
import { existsSync } from 'fs';
|
|
8
|
+
import path from 'path';
|
|
9
|
+
import { printSuccess, printError, printWarning } from '../../utils.js';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Default hive-mind configuration
|
|
13
|
+
*/
|
|
14
|
+
export const DEFAULT_HIVE_CONFIG = {
|
|
15
|
+
version: '2.0.0',
|
|
16
|
+
initialized: new Date().toISOString(),
|
|
17
|
+
system: {
|
|
18
|
+
enabled: true,
|
|
19
|
+
autoStart: false,
|
|
20
|
+
maxRetries: 3,
|
|
21
|
+
healthCheckInterval: 30000,
|
|
22
|
+
},
|
|
23
|
+
queen: {
|
|
24
|
+
type: 'strategic',
|
|
25
|
+
name: 'Queen-Genesis',
|
|
26
|
+
capabilities: [
|
|
27
|
+
'task-decomposition',
|
|
28
|
+
'consensus-building',
|
|
29
|
+
'resource-allocation',
|
|
30
|
+
'quality-assessment',
|
|
31
|
+
'conflict-resolution',
|
|
32
|
+
],
|
|
33
|
+
decisionThreshold: 0.75,
|
|
34
|
+
adaptiveLearning: true,
|
|
35
|
+
},
|
|
36
|
+
workers: {
|
|
37
|
+
maxWorkers: 8,
|
|
38
|
+
defaultCapabilities: ['code-analysis', 'implementation', 'testing', 'documentation'],
|
|
39
|
+
autoScale: true,
|
|
40
|
+
scaleThreshold: 0.8,
|
|
41
|
+
specializedRoles: ['architect', 'researcher', 'implementer', 'tester', 'reviewer'],
|
|
42
|
+
},
|
|
43
|
+
consensus: {
|
|
44
|
+
algorithm: 'weighted-majority',
|
|
45
|
+
minimumParticipants: 3,
|
|
46
|
+
timeoutMs: 30000,
|
|
47
|
+
requiredConsensus: 0.67,
|
|
48
|
+
votingMethods: ['majority', 'weighted', 'unanimous', 'quorum'],
|
|
49
|
+
},
|
|
50
|
+
memory: {
|
|
51
|
+
enabled: true,
|
|
52
|
+
size: 100,
|
|
53
|
+
persistenceMode: 'database',
|
|
54
|
+
sharedMemoryNamespace: 'hive-collective',
|
|
55
|
+
retentionDays: 30,
|
|
56
|
+
compressionEnabled: true,
|
|
57
|
+
encryptionEnabled: false,
|
|
58
|
+
},
|
|
59
|
+
communication: {
|
|
60
|
+
protocol: 'secure-messaging',
|
|
61
|
+
encryption: false,
|
|
62
|
+
messageQueue: {
|
|
63
|
+
maxSize: 1000,
|
|
64
|
+
priorityLevels: 5,
|
|
65
|
+
batchProcessing: true,
|
|
66
|
+
},
|
|
67
|
+
channels: [
|
|
68
|
+
'task-coordination',
|
|
69
|
+
'knowledge-sharing',
|
|
70
|
+
'consensus-voting',
|
|
71
|
+
'error-reporting',
|
|
72
|
+
'performance-metrics',
|
|
73
|
+
],
|
|
74
|
+
},
|
|
75
|
+
integration: {
|
|
76
|
+
mcpTools: {
|
|
77
|
+
enabled: true,
|
|
78
|
+
parallel: true,
|
|
79
|
+
timeout: 60000,
|
|
80
|
+
fallbackMode: 'sequential',
|
|
81
|
+
},
|
|
82
|
+
claudeCode: {
|
|
83
|
+
enabled: true,
|
|
84
|
+
autoSpawn: true,
|
|
85
|
+
coordination: true,
|
|
86
|
+
sharedContext: true,
|
|
87
|
+
},
|
|
88
|
+
github: {
|
|
89
|
+
enabled: false,
|
|
90
|
+
autoCommit: false,
|
|
91
|
+
branchStrategy: 'feature',
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
monitoring: {
|
|
95
|
+
enabled: true,
|
|
96
|
+
metricsCollection: true,
|
|
97
|
+
performanceTracking: true,
|
|
98
|
+
healthChecks: true,
|
|
99
|
+
alerting: {
|
|
100
|
+
enabled: false,
|
|
101
|
+
thresholds: {
|
|
102
|
+
errorRate: 0.1,
|
|
103
|
+
responseTime: 5000,
|
|
104
|
+
consensusFailures: 3,
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Database schema for hive-mind system
|
|
112
|
+
*/
|
|
113
|
+
export const HIVE_DB_SCHEMA = {
|
|
114
|
+
swarms: `
|
|
115
|
+
CREATE TABLE IF NOT EXISTS swarms (
|
|
116
|
+
id TEXT PRIMARY KEY,
|
|
117
|
+
name TEXT NOT NULL,
|
|
118
|
+
objective TEXT,
|
|
119
|
+
status TEXT DEFAULT 'active',
|
|
120
|
+
queen_type TEXT DEFAULT 'strategic',
|
|
121
|
+
topology TEXT DEFAULT 'hierarchical',
|
|
122
|
+
max_agents INTEGER DEFAULT 8,
|
|
123
|
+
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
|
124
|
+
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
|
125
|
+
metadata TEXT DEFAULT '{}'
|
|
126
|
+
);
|
|
127
|
+
`,
|
|
128
|
+
agents: `
|
|
129
|
+
CREATE TABLE IF NOT EXISTS agents (
|
|
130
|
+
id TEXT PRIMARY KEY,
|
|
131
|
+
swarm_id TEXT,
|
|
132
|
+
name TEXT NOT NULL,
|
|
133
|
+
type TEXT NOT NULL,
|
|
134
|
+
role TEXT,
|
|
135
|
+
capabilities TEXT DEFAULT '[]',
|
|
136
|
+
status TEXT DEFAULT 'active',
|
|
137
|
+
performance_score REAL DEFAULT 0.5,
|
|
138
|
+
task_count INTEGER DEFAULT 0,
|
|
139
|
+
success_rate REAL DEFAULT 1.0,
|
|
140
|
+
last_active DATETIME DEFAULT CURRENT_TIMESTAMP,
|
|
141
|
+
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
|
142
|
+
metadata TEXT DEFAULT '{}',
|
|
143
|
+
FOREIGN KEY (swarm_id) REFERENCES swarms (id)
|
|
144
|
+
);
|
|
145
|
+
`,
|
|
146
|
+
tasks: `
|
|
147
|
+
CREATE TABLE IF NOT EXISTS tasks (
|
|
148
|
+
id TEXT PRIMARY KEY,
|
|
149
|
+
swarm_id TEXT,
|
|
150
|
+
agent_id TEXT,
|
|
151
|
+
name TEXT NOT NULL,
|
|
152
|
+
description TEXT,
|
|
153
|
+
status TEXT DEFAULT 'pending',
|
|
154
|
+
priority INTEGER DEFAULT 3,
|
|
155
|
+
complexity REAL DEFAULT 0.5,
|
|
156
|
+
estimated_time INTEGER,
|
|
157
|
+
actual_time INTEGER,
|
|
158
|
+
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
|
159
|
+
started_at DATETIME,
|
|
160
|
+
completed_at DATETIME,
|
|
161
|
+
metadata TEXT DEFAULT '{}',
|
|
162
|
+
FOREIGN KEY (swarm_id) REFERENCES swarms (id),
|
|
163
|
+
FOREIGN KEY (agent_id) REFERENCES agents (id)
|
|
164
|
+
);
|
|
165
|
+
`,
|
|
166
|
+
messages: `
|
|
167
|
+
CREATE TABLE IF NOT EXISTS messages (
|
|
168
|
+
id TEXT PRIMARY KEY,
|
|
169
|
+
swarm_id TEXT,
|
|
170
|
+
sender_id TEXT,
|
|
171
|
+
recipient_id TEXT,
|
|
172
|
+
channel TEXT DEFAULT 'general',
|
|
173
|
+
type TEXT DEFAULT 'info',
|
|
174
|
+
content TEXT NOT NULL,
|
|
175
|
+
priority INTEGER DEFAULT 3,
|
|
176
|
+
consensus_vote REAL,
|
|
177
|
+
timestamp DATETIME DEFAULT CURRENT_TIMESTAMP,
|
|
178
|
+
processed BOOLEAN DEFAULT 0,
|
|
179
|
+
metadata TEXT DEFAULT '{}',
|
|
180
|
+
FOREIGN KEY (swarm_id) REFERENCES swarms (id),
|
|
181
|
+
FOREIGN KEY (sender_id) REFERENCES agents (id),
|
|
182
|
+
FOREIGN KEY (recipient_id) REFERENCES agents (id)
|
|
183
|
+
);
|
|
184
|
+
`,
|
|
185
|
+
consensus_votes: `
|
|
186
|
+
CREATE TABLE IF NOT EXISTS consensus_votes (
|
|
187
|
+
id TEXT PRIMARY KEY,
|
|
188
|
+
swarm_id TEXT,
|
|
189
|
+
proposal_id TEXT NOT NULL,
|
|
190
|
+
agent_id TEXT,
|
|
191
|
+
vote REAL NOT NULL,
|
|
192
|
+
weight REAL DEFAULT 1.0,
|
|
193
|
+
justification TEXT,
|
|
194
|
+
timestamp DATETIME DEFAULT CURRENT_TIMESTAMP,
|
|
195
|
+
FOREIGN KEY (swarm_id) REFERENCES swarms (id),
|
|
196
|
+
FOREIGN KEY (agent_id) REFERENCES agents (id)
|
|
197
|
+
);
|
|
198
|
+
`,
|
|
199
|
+
knowledge_base: `
|
|
200
|
+
CREATE TABLE IF NOT EXISTS knowledge_base (
|
|
201
|
+
id TEXT PRIMARY KEY,
|
|
202
|
+
swarm_id TEXT,
|
|
203
|
+
category TEXT DEFAULT 'general',
|
|
204
|
+
title TEXT NOT NULL,
|
|
205
|
+
content TEXT NOT NULL,
|
|
206
|
+
tags TEXT DEFAULT '[]',
|
|
207
|
+
confidence REAL DEFAULT 0.5,
|
|
208
|
+
source_agent_id TEXT,
|
|
209
|
+
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
|
210
|
+
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
|
211
|
+
access_count INTEGER DEFAULT 0,
|
|
212
|
+
FOREIGN KEY (swarm_id) REFERENCES swarms (id),
|
|
213
|
+
FOREIGN KEY (source_agent_id) REFERENCES agents (id)
|
|
214
|
+
);
|
|
215
|
+
`,
|
|
216
|
+
performance_metrics: `
|
|
217
|
+
CREATE TABLE IF NOT EXISTS performance_metrics (
|
|
218
|
+
id TEXT PRIMARY KEY,
|
|
219
|
+
entity_type TEXT NOT NULL,
|
|
220
|
+
entity_id TEXT NOT NULL,
|
|
221
|
+
metric_name TEXT NOT NULL,
|
|
222
|
+
metric_value REAL NOT NULL,
|
|
223
|
+
timestamp DATETIME DEFAULT CURRENT_TIMESTAMP,
|
|
224
|
+
metadata TEXT DEFAULT '{}'
|
|
225
|
+
);
|
|
226
|
+
`,
|
|
227
|
+
sessions: `
|
|
228
|
+
CREATE TABLE IF NOT EXISTS sessions (
|
|
229
|
+
id TEXT PRIMARY KEY,
|
|
230
|
+
swarm_id TEXT NOT NULL,
|
|
231
|
+
swarm_name TEXT NOT NULL,
|
|
232
|
+
objective TEXT,
|
|
233
|
+
status TEXT DEFAULT 'active',
|
|
234
|
+
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
|
235
|
+
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
|
236
|
+
paused_at DATETIME,
|
|
237
|
+
resumed_at DATETIME,
|
|
238
|
+
completion_percentage REAL DEFAULT 0,
|
|
239
|
+
checkpoint_data TEXT,
|
|
240
|
+
metadata TEXT,
|
|
241
|
+
parent_pid INTEGER,
|
|
242
|
+
child_pids TEXT,
|
|
243
|
+
FOREIGN KEY (swarm_id) REFERENCES swarms (id)
|
|
244
|
+
);
|
|
245
|
+
`,
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* Create hive-mind directory structure
|
|
250
|
+
*/
|
|
251
|
+
export async function createHiveMindDirectories(workingDir, dryRun = false) {
|
|
252
|
+
const directories = [
|
|
253
|
+
'.hive-mind',
|
|
254
|
+
'.hive-mind/sessions',
|
|
255
|
+
'.hive-mind/memory',
|
|
256
|
+
'.hive-mind/logs',
|
|
257
|
+
'.hive-mind/backups',
|
|
258
|
+
'.hive-mind/config',
|
|
259
|
+
'.hive-mind/templates',
|
|
260
|
+
'.hive-mind/exports',
|
|
261
|
+
];
|
|
262
|
+
|
|
263
|
+
console.log(' 📁 Creating hive-mind directory structure...');
|
|
264
|
+
|
|
265
|
+
for (const dir of directories) {
|
|
266
|
+
const fullPath = path.join(workingDir, dir);
|
|
267
|
+
if (!dryRun) {
|
|
268
|
+
await fs.mkdir(fullPath, { recursive: true });
|
|
269
|
+
} else {
|
|
270
|
+
console.log(` [DRY RUN] Would create: ${dir}`);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
if (!dryRun) {
|
|
275
|
+
console.log(' ✅ Hive-mind directories created');
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* Initialize collective memory database
|
|
281
|
+
*/
|
|
282
|
+
export async function initializeCollectiveMemoryDatabase(workingDir, dryRun = false) {
|
|
283
|
+
console.log(' 🧠 Initializing collective memory database...');
|
|
284
|
+
|
|
285
|
+
if (dryRun) {
|
|
286
|
+
console.log(' [DRY RUN] Would initialize hive.db with full schema');
|
|
287
|
+
console.log(' [DRY RUN] Would create indexes for performance optimization');
|
|
288
|
+
console.log(' [DRY RUN] Would insert default data and configurations');
|
|
289
|
+
return;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
try {
|
|
293
|
+
// Dynamic import for better-sqlite3 with proper error handling
|
|
294
|
+
let Database;
|
|
295
|
+
try {
|
|
296
|
+
Database = (await import('better-sqlite3')).default;
|
|
297
|
+
} catch (err) {
|
|
298
|
+
console.log(' ⚠️ better-sqlite3 not available, using fallback memory database');
|
|
299
|
+
return await createFallbackMemoryDatabase(workingDir);
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
const hivePath = path.join(workingDir, '.hive-mind', 'hive.db');
|
|
303
|
+
const hiveDb = new Database(hivePath);
|
|
304
|
+
|
|
305
|
+
// Enable WAL mode for better concurrency
|
|
306
|
+
hiveDb.pragma('journal_mode = WAL');
|
|
307
|
+
hiveDb.pragma('synchronous = NORMAL');
|
|
308
|
+
hiveDb.pragma('cache_size = 1000');
|
|
309
|
+
hiveDb.pragma('temp_store = MEMORY');
|
|
310
|
+
|
|
311
|
+
// Create all tables
|
|
312
|
+
console.log(' 📋 Creating database schema...');
|
|
313
|
+
for (const [tableName, schema] of Object.entries(HIVE_DB_SCHEMA)) {
|
|
314
|
+
hiveDb.exec(schema);
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
// Create indexes for performance
|
|
318
|
+
console.log(' 🔍 Creating performance indexes...');
|
|
319
|
+
const indexes = [
|
|
320
|
+
'CREATE INDEX IF NOT EXISTS idx_agents_swarm_id ON agents(swarm_id);',
|
|
321
|
+
'CREATE INDEX IF NOT EXISTS idx_agents_status ON agents(status);',
|
|
322
|
+
'CREATE INDEX IF NOT EXISTS idx_tasks_swarm_id ON tasks(swarm_id);',
|
|
323
|
+
'CREATE INDEX IF NOT EXISTS idx_tasks_agent_id ON tasks(agent_id);',
|
|
324
|
+
'CREATE INDEX IF NOT EXISTS idx_tasks_status ON tasks(status);',
|
|
325
|
+
'CREATE INDEX IF NOT EXISTS idx_messages_swarm_id ON messages(swarm_id);',
|
|
326
|
+
'CREATE INDEX IF NOT EXISTS idx_messages_timestamp ON messages(timestamp);',
|
|
327
|
+
'CREATE INDEX IF NOT EXISTS idx_consensus_votes_swarm_id ON consensus_votes(swarm_id);',
|
|
328
|
+
'CREATE INDEX IF NOT EXISTS idx_knowledge_base_swarm_id ON knowledge_base(swarm_id);',
|
|
329
|
+
'CREATE INDEX IF NOT EXISTS idx_knowledge_base_category ON knowledge_base(category);',
|
|
330
|
+
'CREATE INDEX IF NOT EXISTS idx_performance_metrics_entity ON performance_metrics(entity_type, entity_id);',
|
|
331
|
+
'CREATE INDEX IF NOT EXISTS idx_sessions_swarm_id ON sessions(swarm_id);',
|
|
332
|
+
];
|
|
333
|
+
|
|
334
|
+
for (const index of indexes) {
|
|
335
|
+
hiveDb.exec(index);
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
// Insert initial metadata
|
|
339
|
+
const insertInitialData = hiveDb.prepare(`
|
|
340
|
+
INSERT OR IGNORE INTO knowledge_base (id, category, title, content, confidence)
|
|
341
|
+
VALUES (?, ?, ?, ?, ?)
|
|
342
|
+
`);
|
|
343
|
+
|
|
344
|
+
const initialKnowledge = [
|
|
345
|
+
[
|
|
346
|
+
'init-1',
|
|
347
|
+
'system',
|
|
348
|
+
'Hive Mind System Initialization',
|
|
349
|
+
'Hive mind system successfully initialized with full database schema and configuration.',
|
|
350
|
+
1.0,
|
|
351
|
+
],
|
|
352
|
+
[
|
|
353
|
+
'init-2',
|
|
354
|
+
'capabilities',
|
|
355
|
+
'Default Agent Capabilities',
|
|
356
|
+
JSON.stringify(DEFAULT_HIVE_CONFIG.workers.defaultCapabilities),
|
|
357
|
+
0.9,
|
|
358
|
+
],
|
|
359
|
+
[
|
|
360
|
+
'init-3',
|
|
361
|
+
'consensus',
|
|
362
|
+
'Consensus Algorithms',
|
|
363
|
+
JSON.stringify(DEFAULT_HIVE_CONFIG.consensus),
|
|
364
|
+
1.0,
|
|
365
|
+
],
|
|
366
|
+
['init-4', 'queen', 'Queen Configuration', JSON.stringify(DEFAULT_HIVE_CONFIG.queen), 1.0],
|
|
367
|
+
];
|
|
368
|
+
|
|
369
|
+
for (const knowledge of initialKnowledge) {
|
|
370
|
+
insertInitialData.run(...knowledge);
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
hiveDb.close();
|
|
374
|
+
console.log(' ✅ Collective memory database initialized with full schema');
|
|
375
|
+
} catch (err) {
|
|
376
|
+
console.log(` ⚠️ Could not initialize hive database: ${err.message}`);
|
|
377
|
+
return await createFallbackMemoryDatabase(workingDir);
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
/**
|
|
382
|
+
* Create fallback memory database when SQLite is not available
|
|
383
|
+
*/
|
|
384
|
+
async function createFallbackMemoryDatabase(workingDir) {
|
|
385
|
+
console.log(' 📄 Creating fallback JSON memory database...');
|
|
386
|
+
|
|
387
|
+
const fallbackDb = {
|
|
388
|
+
metadata: {
|
|
389
|
+
type: 'fallback',
|
|
390
|
+
initialized: new Date().toISOString(),
|
|
391
|
+
warning: 'Using JSON fallback - install better-sqlite3 for full database features',
|
|
392
|
+
},
|
|
393
|
+
swarms: [],
|
|
394
|
+
agents: [],
|
|
395
|
+
tasks: [],
|
|
396
|
+
messages: [],
|
|
397
|
+
consensus_votes: [],
|
|
398
|
+
knowledge_base: [
|
|
399
|
+
{
|
|
400
|
+
id: 'init-1',
|
|
401
|
+
category: 'system',
|
|
402
|
+
title: 'Fallback Memory System',
|
|
403
|
+
content:
|
|
404
|
+
'Using JSON-based fallback memory system. Install better-sqlite3 for full database features.',
|
|
405
|
+
confidence: 1.0,
|
|
406
|
+
created_at: new Date().toISOString(),
|
|
407
|
+
},
|
|
408
|
+
],
|
|
409
|
+
performance_metrics: [],
|
|
410
|
+
sessions: [],
|
|
411
|
+
};
|
|
412
|
+
|
|
413
|
+
const fallbackPath = path.join(workingDir, '.hive-mind', 'memory.json');
|
|
414
|
+
await fs.writeFile(fallbackPath, JSON.stringify(fallbackDb, null, 2), 'utf8');
|
|
415
|
+
|
|
416
|
+
console.log(' ✅ Fallback memory database created');
|
|
417
|
+
return true;
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
/**
|
|
421
|
+
* Create default queen and worker configurations
|
|
422
|
+
*/
|
|
423
|
+
export async function createDefaultConfigurations(workingDir, dryRun = false) {
|
|
424
|
+
console.log(' 👑 Creating default queen and worker configurations...');
|
|
425
|
+
|
|
426
|
+
if (dryRun) {
|
|
427
|
+
console.log(' [DRY RUN] Would create queen configurations');
|
|
428
|
+
console.log(' [DRY RUN] Would create worker configurations');
|
|
429
|
+
console.log(' [DRY RUN] Would create role templates');
|
|
430
|
+
return;
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
const configDir = path.join(workingDir, '.hive-mind', 'config');
|
|
434
|
+
|
|
435
|
+
// Queen configurations
|
|
436
|
+
const queenConfigs = {
|
|
437
|
+
strategic: {
|
|
438
|
+
name: 'Strategic Queen',
|
|
439
|
+
description: 'Focuses on long-term planning and high-level coordination',
|
|
440
|
+
capabilities: [
|
|
441
|
+
'strategic-planning',
|
|
442
|
+
'resource-optimization',
|
|
443
|
+
'risk-assessment',
|
|
444
|
+
'quality-oversight',
|
|
445
|
+
'team-coordination',
|
|
446
|
+
],
|
|
447
|
+
decisionStyle: 'analytical',
|
|
448
|
+
planningHorizon: 'long-term',
|
|
449
|
+
adaptability: 0.7,
|
|
450
|
+
specialties: ['architecture', 'planning', 'coordination'],
|
|
451
|
+
},
|
|
452
|
+
tactical: {
|
|
453
|
+
name: 'Tactical Queen',
|
|
454
|
+
description: 'Focuses on execution efficiency and immediate problem-solving',
|
|
455
|
+
capabilities: [
|
|
456
|
+
'task-optimization',
|
|
457
|
+
'rapid-response',
|
|
458
|
+
'resource-allocation',
|
|
459
|
+
'performance-monitoring',
|
|
460
|
+
'conflict-resolution',
|
|
461
|
+
],
|
|
462
|
+
decisionStyle: 'pragmatic',
|
|
463
|
+
planningHorizon: 'short-term',
|
|
464
|
+
adaptability: 0.9,
|
|
465
|
+
specialties: ['execution', 'optimization', 'troubleshooting'],
|
|
466
|
+
},
|
|
467
|
+
adaptive: {
|
|
468
|
+
name: 'Adaptive Queen',
|
|
469
|
+
description: 'Dynamically adjusts approach based on context and feedback',
|
|
470
|
+
capabilities: [
|
|
471
|
+
'pattern-recognition',
|
|
472
|
+
'adaptive-learning',
|
|
473
|
+
'context-switching',
|
|
474
|
+
'feedback-integration',
|
|
475
|
+
'dynamic-planning',
|
|
476
|
+
],
|
|
477
|
+
decisionStyle: 'flexible',
|
|
478
|
+
planningHorizon: 'adaptive',
|
|
479
|
+
adaptability: 1.0,
|
|
480
|
+
specialties: ['learning', 'adaptation', 'context-awareness'],
|
|
481
|
+
},
|
|
482
|
+
};
|
|
483
|
+
|
|
484
|
+
// Worker role templates
|
|
485
|
+
const workerTemplates = {
|
|
486
|
+
architect: {
|
|
487
|
+
name: 'System Architect',
|
|
488
|
+
description: 'Designs system architecture and technical specifications',
|
|
489
|
+
capabilities: [
|
|
490
|
+
'system-design',
|
|
491
|
+
'architecture-patterns',
|
|
492
|
+
'scalability-planning',
|
|
493
|
+
'technology-selection',
|
|
494
|
+
'documentation',
|
|
495
|
+
],
|
|
496
|
+
complexity: 0.9,
|
|
497
|
+
autonomy: 0.8,
|
|
498
|
+
collaboration: 0.7,
|
|
499
|
+
},
|
|
500
|
+
researcher: {
|
|
501
|
+
name: 'Research Specialist',
|
|
502
|
+
description: 'Conducts research and gathers information for informed decisions',
|
|
503
|
+
capabilities: [
|
|
504
|
+
'information-gathering',
|
|
505
|
+
'analysis',
|
|
506
|
+
'trend-identification',
|
|
507
|
+
'competitive-research',
|
|
508
|
+
'reporting',
|
|
509
|
+
],
|
|
510
|
+
complexity: 0.7,
|
|
511
|
+
autonomy: 0.9,
|
|
512
|
+
collaboration: 0.6,
|
|
513
|
+
},
|
|
514
|
+
implementer: {
|
|
515
|
+
name: 'Implementation Specialist',
|
|
516
|
+
description: 'Translates designs into working code and solutions',
|
|
517
|
+
capabilities: ['coding', 'debugging', 'integration', 'optimization', 'deployment'],
|
|
518
|
+
complexity: 0.8,
|
|
519
|
+
autonomy: 0.7,
|
|
520
|
+
collaboration: 0.8,
|
|
521
|
+
},
|
|
522
|
+
tester: {
|
|
523
|
+
name: 'Quality Assurance Specialist',
|
|
524
|
+
description: 'Ensures quality through testing and validation',
|
|
525
|
+
capabilities: ['testing', 'validation', 'quality-assurance', 'automation', 'reporting'],
|
|
526
|
+
complexity: 0.6,
|
|
527
|
+
autonomy: 0.8,
|
|
528
|
+
collaboration: 0.7,
|
|
529
|
+
},
|
|
530
|
+
reviewer: {
|
|
531
|
+
name: 'Code Review Specialist',
|
|
532
|
+
description: 'Reviews code quality and provides improvement suggestions',
|
|
533
|
+
capabilities: [
|
|
534
|
+
'code-review',
|
|
535
|
+
'quality-assessment',
|
|
536
|
+
'best-practices',
|
|
537
|
+
'mentoring',
|
|
538
|
+
'documentation-review',
|
|
539
|
+
],
|
|
540
|
+
complexity: 0.8,
|
|
541
|
+
autonomy: 0.8,
|
|
542
|
+
collaboration: 0.9,
|
|
543
|
+
},
|
|
544
|
+
};
|
|
545
|
+
|
|
546
|
+
// Save configurations
|
|
547
|
+
await fs.writeFile(
|
|
548
|
+
path.join(configDir, 'queens.json'),
|
|
549
|
+
JSON.stringify(queenConfigs, null, 2),
|
|
550
|
+
'utf8',
|
|
551
|
+
);
|
|
552
|
+
|
|
553
|
+
await fs.writeFile(
|
|
554
|
+
path.join(configDir, 'workers.json'),
|
|
555
|
+
JSON.stringify(workerTemplates, null, 2),
|
|
556
|
+
'utf8',
|
|
557
|
+
);
|
|
558
|
+
|
|
559
|
+
console.log(' ✅ Default configurations created');
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
/**
|
|
563
|
+
* Create hive-mind config file with sensible defaults
|
|
564
|
+
*/
|
|
565
|
+
export async function createHiveMindConfig(workingDir, customConfig = {}, dryRun = false) {
|
|
566
|
+
console.log(' ⚙️ Creating hive-mind configuration file...');
|
|
567
|
+
|
|
568
|
+
if (dryRun) {
|
|
569
|
+
console.log(' [DRY RUN] Would create config.json with merged settings');
|
|
570
|
+
return;
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
// Merge custom config with defaults
|
|
574
|
+
const config = mergeDeep(DEFAULT_HIVE_CONFIG, customConfig);
|
|
575
|
+
|
|
576
|
+
const configPath = path.join(workingDir, '.hive-mind', 'config.json');
|
|
577
|
+
await fs.writeFile(configPath, JSON.stringify(config, null, 2), 'utf8');
|
|
578
|
+
|
|
579
|
+
console.log(' ✅ Hive-mind configuration created');
|
|
580
|
+
return config;
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
/**
|
|
584
|
+
* Create initial README and documentation files
|
|
585
|
+
*/
|
|
586
|
+
export async function createHiveMindDocumentation(workingDir, dryRun = false) {
|
|
587
|
+
console.log(' 📚 Creating hive-mind documentation...');
|
|
588
|
+
|
|
589
|
+
if (dryRun) {
|
|
590
|
+
console.log(' [DRY RUN] Would create README.md and documentation files');
|
|
591
|
+
return;
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
const readmeContent = `# Hive Mind System
|
|
595
|
+
|
|
596
|
+
This directory contains the Claude Flow Hive Mind system configuration and data.
|
|
597
|
+
|
|
598
|
+
## Directory Structure
|
|
599
|
+
|
|
600
|
+
- **config/**: Configuration files for queens, workers, and system settings
|
|
601
|
+
- **sessions/**: Active and historical session data
|
|
602
|
+
- **memory/**: Collective memory and knowledge base
|
|
603
|
+
- **logs/**: System and debug logs
|
|
604
|
+
- **backups/**: Automated backups of system state
|
|
605
|
+
- **templates/**: Templates for agents and workflows
|
|
606
|
+
- **exports/**: Exported data and reports
|
|
607
|
+
|
|
608
|
+
## Database Files
|
|
609
|
+
|
|
610
|
+
- **hive.db**: Main SQLite database (or memory.json as fallback)
|
|
611
|
+
- **config.json**: Primary system configuration
|
|
612
|
+
|
|
613
|
+
## Getting Started
|
|
614
|
+
|
|
615
|
+
1. Initialize: \`npx claude-flow@alpha hive-mind init\`
|
|
616
|
+
2. Spawn swarm: \`npx claude-flow@alpha hive-mind spawn "your objective"\`
|
|
617
|
+
3. Check status: \`npx claude-flow@alpha hive-mind status\`
|
|
618
|
+
|
|
619
|
+
## Features
|
|
620
|
+
|
|
621
|
+
- **Collective Intelligence**: Multiple AI agents working together
|
|
622
|
+
- **Consensus Building**: Democratic decision-making process
|
|
623
|
+
- **Adaptive Learning**: System improves over time
|
|
624
|
+
- **Fault Tolerance**: Self-healing and recovery capabilities
|
|
625
|
+
- **Performance Monitoring**: Real-time metrics and optimization
|
|
626
|
+
|
|
627
|
+
## Configuration
|
|
628
|
+
|
|
629
|
+
Edit \`.hive-mind/config.json\` to customize:
|
|
630
|
+
- Queen type and capabilities
|
|
631
|
+
- Worker specializations
|
|
632
|
+
- Consensus algorithms
|
|
633
|
+
- Memory settings
|
|
634
|
+
- Integration options
|
|
635
|
+
|
|
636
|
+
For more information, see the [Hive Mind Documentation](https://github.com/ruvnet/claude-flow/docs/hive-mind.md).
|
|
637
|
+
`;
|
|
638
|
+
|
|
639
|
+
await fs.writeFile(path.join(workingDir, '.hive-mind', 'README.md'), readmeContent, 'utf8');
|
|
640
|
+
|
|
641
|
+
console.log(' ✅ Hive-mind documentation created');
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
/**
|
|
645
|
+
* Complete hive-mind initialization
|
|
646
|
+
*/
|
|
647
|
+
export async function initializeHiveMind(workingDir, options = {}, dryRun = false) {
|
|
648
|
+
console.log('🧠 Initializing Hive Mind System...');
|
|
649
|
+
|
|
650
|
+
try {
|
|
651
|
+
// Create directory structure
|
|
652
|
+
await createHiveMindDirectories(workingDir, dryRun);
|
|
653
|
+
|
|
654
|
+
// Initialize collective memory database
|
|
655
|
+
await initializeCollectiveMemoryDatabase(workingDir, dryRun);
|
|
656
|
+
|
|
657
|
+
// Create default configurations
|
|
658
|
+
await createDefaultConfigurations(workingDir, dryRun);
|
|
659
|
+
|
|
660
|
+
// Create main config file
|
|
661
|
+
await createHiveMindConfig(workingDir, options.config || {}, dryRun);
|
|
662
|
+
|
|
663
|
+
// Create documentation
|
|
664
|
+
await createHiveMindDocumentation(workingDir, dryRun);
|
|
665
|
+
|
|
666
|
+
if (!dryRun) {
|
|
667
|
+
printSuccess('🧠 Hive Mind System initialized successfully');
|
|
668
|
+
} else {
|
|
669
|
+
console.log('[DRY RUN] Hive Mind System would be fully initialized');
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
return {
|
|
673
|
+
success: true,
|
|
674
|
+
features: [
|
|
675
|
+
'Collective memory database',
|
|
676
|
+
'Queen and worker configurations',
|
|
677
|
+
'Consensus mechanisms',
|
|
678
|
+
'Performance monitoring',
|
|
679
|
+
'Session management',
|
|
680
|
+
'Knowledge base',
|
|
681
|
+
],
|
|
682
|
+
};
|
|
683
|
+
} catch (error) {
|
|
684
|
+
printError(`Failed to initialize Hive Mind System: ${error.message}`);
|
|
685
|
+
return {
|
|
686
|
+
success: false,
|
|
687
|
+
error: error.message,
|
|
688
|
+
rollbackRequired: true,
|
|
689
|
+
};
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
/**
|
|
694
|
+
* Get hive-mind initialization status for init summary
|
|
695
|
+
*/
|
|
696
|
+
export function getHiveMindStatus(workingDir) {
|
|
697
|
+
const configPath = path.join(workingDir, '.hive-mind', 'config.json');
|
|
698
|
+
const dbPath = path.join(workingDir, '.hive-mind', 'hive.db');
|
|
699
|
+
const fallbackPath = path.join(workingDir, '.hive-mind', 'memory.json');
|
|
700
|
+
|
|
701
|
+
const status = {
|
|
702
|
+
configured: existsSync(configPath),
|
|
703
|
+
database: existsSync(dbPath) ? 'sqlite' : existsSync(fallbackPath) ? 'fallback' : 'none',
|
|
704
|
+
directories: existsSync(path.join(workingDir, '.hive-mind')),
|
|
705
|
+
};
|
|
706
|
+
|
|
707
|
+
return status;
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
/**
|
|
711
|
+
* Rollback hive-mind initialization (cleanup on failure)
|
|
712
|
+
*/
|
|
713
|
+
export async function rollbackHiveMindInit(workingDir) {
|
|
714
|
+
console.log('🔄 Rolling back hive-mind initialization...');
|
|
715
|
+
|
|
716
|
+
try {
|
|
717
|
+
const hiveMindDir = path.join(workingDir, '.hive-mind');
|
|
718
|
+
if (existsSync(hiveMindDir)) {
|
|
719
|
+
await fs.rmdir(hiveMindDir, { recursive: true });
|
|
720
|
+
console.log(' ✅ Hive-mind directory removed');
|
|
721
|
+
}
|
|
722
|
+
return { success: true };
|
|
723
|
+
} catch (error) {
|
|
724
|
+
printError(`Failed to rollback hive-mind initialization: ${error.message}`);
|
|
725
|
+
return { success: false, error: error.message };
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
/**
|
|
730
|
+
* Deep merge utility for configuration objects
|
|
731
|
+
*/
|
|
732
|
+
function mergeDeep(target, source) {
|
|
733
|
+
const output = Object.assign({}, target);
|
|
734
|
+
if (isObject(target) && isObject(source)) {
|
|
735
|
+
Object.keys(source).forEach((key) => {
|
|
736
|
+
if (isObject(source[key])) {
|
|
737
|
+
if (!(key in target)) Object.assign(output, { [key]: source[key] });
|
|
738
|
+
else output[key] = mergeDeep(target[key], source[key]);
|
|
739
|
+
} else {
|
|
740
|
+
Object.assign(output, { [key]: source[key] });
|
|
741
|
+
}
|
|
742
|
+
});
|
|
743
|
+
}
|
|
744
|
+
return output;
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
function isObject(item) {
|
|
748
|
+
return item && typeof item === 'object' && !Array.isArray(item);
|
|
749
|
+
}
|