claude-flow-novice 2.0.4 → 2.0.5
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/dist/src/cli/commands/guidance.js +668 -487
- package/dist/src/cli/commands/index-validate.js +29 -18
- package/dist/src/cli/commands/mcp-troubleshoot.js +282 -230
- package/dist/src/cli/commands/neural-goal-init.js +125 -92
- package/dist/src/cli/commands/swarm-exec.js +393 -317
- package/dist/src/cli/commands/validate-framework.js +1100 -983
- package/dist/src/cli/commands/validate.js +223 -144
- package/dist/src/cli/main.js +1 -1
- package/dist/src/cli/simple-commands/__tests__/agent.test.js +277 -265
- package/dist/src/cli/simple-commands/__tests__/memory.test.js +7 -6
- package/dist/src/cli/simple-commands/__tests__/swarm.test.js +356 -373
- package/dist/src/cli/simple-commands/__tests__/task.test.js +7 -6
- package/dist/src/cli/simple-commands/agent.js +193 -157
- package/dist/src/cli/simple-commands/analysis.js +446 -336
- package/dist/src/cli/simple-commands/automation-executor.js +1339 -1095
- package/dist/src/cli/simple-commands/automation.js +469 -481
- package/dist/src/cli/simple-commands/batch-manager.js +313 -261
- package/dist/src/cli/simple-commands/claude-telemetry.js +267 -241
- package/dist/src/cli/simple-commands/claude-track.js +90 -68
- package/dist/src/cli/simple-commands/concurrent-display.js +320 -266
- package/dist/src/cli/simple-commands/config.js +290 -245
- package/dist/src/cli/simple-commands/coordination.js +234 -182
- package/dist/src/cli/simple-commands/enhanced-ui-views.js +615 -812
- package/dist/src/cli/simple-commands/enhanced-webui-complete.js +981 -922
- package/dist/src/cli/simple-commands/fix-hook-variables.js +294 -274
- package/dist/src/cli/simple-commands/github/gh-coordinator.js +457 -378
- package/dist/src/cli/simple-commands/github/github-api.js +574 -535
- package/dist/src/cli/simple-commands/github/init.js +303 -276
- package/dist/src/cli/simple-commands/github.js +247 -222
- package/dist/src/cli/simple-commands/goal.js +63 -51
- package/dist/src/cli/simple-commands/hive-mind/auto-save-middleware.js +278 -208
- package/dist/src/cli/simple-commands/hive-mind/communication.js +696 -601
- package/dist/src/cli/simple-commands/hive-mind/core.js +979 -907
- package/dist/src/cli/simple-commands/hive-mind/db-optimizer.js +655 -406
- package/dist/src/cli/simple-commands/hive-mind/mcp-wrapper.js +1245 -1125
- package/dist/src/cli/simple-commands/hive-mind/memory.js +1090 -854
- package/dist/src/cli/simple-commands/hive-mind/performance-optimizer.js +574 -459
- package/dist/src/cli/simple-commands/hive-mind/performance-test.js +347 -263
- package/dist/src/cli/simple-commands/hive-mind/queen.js +768 -727
- package/dist/src/cli/simple-commands/hive-mind/session-manager.js +1049 -745
- package/dist/src/cli/simple-commands/hive-mind-optimize.js +283 -227
- package/dist/src/cli/simple-commands/hive-mind-wizard.js +217 -174
- package/dist/src/cli/simple-commands/hive-mind.js +2282 -1841
- package/dist/src/cli/simple-commands/hive.js +79 -90
- package/dist/src/cli/simple-commands/hook-safety.js +521 -431
- package/dist/src/cli/simple-commands/hooks/session-start-soul.js +254 -203
- package/dist/src/cli/simple-commands/hooks.js +1204 -1064
- package/dist/src/cli/simple-commands/init/agent-copier.js +319 -294
- package/dist/src/cli/simple-commands/init/batch-init.js +562 -496
- package/dist/src/cli/simple-commands/init/claude-commands/claude-flow-commands.js +19 -13
- package/dist/src/cli/simple-commands/init/claude-commands/optimized-claude-flow-commands.js +19 -13
- package/dist/src/cli/simple-commands/init/claude-commands/optimized-slash-commands.js +88 -61
- package/dist/src/cli/simple-commands/init/claude-commands/optimized-sparc-commands.js +150 -125
- package/dist/src/cli/simple-commands/init/claude-commands/slash-commands.js +49 -42
- package/dist/src/cli/simple-commands/init/claude-commands/sparc-commands.js +61 -43
- package/dist/src/cli/simple-commands/init/copy-revised-templates.js +147 -141
- package/dist/src/cli/simple-commands/init/executable-wrapper.js +44 -31
- package/dist/src/cli/simple-commands/init/gitignore-updater.js +90 -64
- package/dist/src/cli/simple-commands/init/help.js +107 -104
- package/dist/src/cli/simple-commands/init/hive-mind-init.js +528 -509
- package/dist/src/cli/simple-commands/init/index.js +1759 -1510
- package/dist/src/cli/simple-commands/init/performance-monitor.js +317 -234
- package/dist/src/cli/simple-commands/init/rollback/backup-manager.js +504 -441
- package/dist/src/cli/simple-commands/init/rollback/index.js +364 -289
- package/dist/src/cli/simple-commands/init/rollback/recovery-manager.js +728 -652
- package/dist/src/cli/simple-commands/init/rollback/rollback-executor.js +481 -416
- package/dist/src/cli/simple-commands/init/rollback/state-tracker.js +448 -369
- package/dist/src/cli/simple-commands/init/sparc/roo-readme.js +2 -1
- package/dist/src/cli/simple-commands/init/sparc/roomodes-config.js +99 -122
- package/dist/src/cli/simple-commands/init/sparc/workflows.js +37 -32
- package/dist/src/cli/simple-commands/init/sparc-structure.js +62 -55
- package/dist/src/cli/simple-commands/init/template-copier.js +533 -421
- package/dist/src/cli/simple-commands/init/templates/coordination-md.js +6 -3
- package/dist/src/cli/simple-commands/init/templates/enhanced-templates.js +318 -344
- package/dist/src/cli/simple-commands/init/templates/github-safe-enhanced.js +218 -173
- package/dist/src/cli/simple-commands/init/templates/github-safe.js +75 -65
- package/dist/src/cli/simple-commands/init/templates/memory-bank-md.js +6 -3
- package/dist/src/cli/simple-commands/init/templates/readme-files.js +4 -2
- package/dist/src/cli/simple-commands/init/templates/safe-hook-patterns.js +230 -187
- package/dist/src/cli/simple-commands/init/templates/sparc-modes.js +80 -53
- package/dist/src/cli/simple-commands/init/templates/verification-claude-md.js +85 -101
- package/dist/src/cli/simple-commands/init/validation/config-validator.js +330 -283
- package/dist/src/cli/simple-commands/init/validation/health-checker.js +561 -495
- package/dist/src/cli/simple-commands/init/validation/index.js +358 -302
- package/dist/src/cli/simple-commands/init/validation/mode-validator.js +359 -308
- package/dist/src/cli/simple-commands/init/validation/post-init-validator.js +366 -389
- package/dist/src/cli/simple-commands/init/validation/pre-init-validator.js +268 -270
- package/dist/src/cli/simple-commands/init/validation/test-runner.js +447 -427
- package/dist/src/cli/simple-commands/init.js +2 -1
- package/dist/src/cli/simple-commands/mcp-health.js +158 -131
- package/dist/src/cli/simple-commands/mcp-integration-layer.js +634 -533
- package/dist/src/cli/simple-commands/mcp.js +400 -345
- package/dist/src/cli/simple-commands/memory-consolidation.js +537 -426
- package/dist/src/cli/simple-commands/memory.js +311 -247
- package/dist/src/cli/simple-commands/migrate-hooks.js +46 -39
- package/dist/src/cli/simple-commands/monitor.js +363 -294
- package/dist/src/cli/simple-commands/neural.js +65 -51
- package/dist/src/cli/simple-commands/pair-autofix-only.js +662 -538
- package/dist/src/cli/simple-commands/pair-basic.js +656 -528
- package/dist/src/cli/simple-commands/pair-old.js +543 -430
- package/dist/src/cli/simple-commands/pair-working.js +751 -615
- package/dist/src/cli/simple-commands/pair.js +751 -615
- package/dist/src/cli/simple-commands/performance-hooks.js +111 -83
- package/dist/src/cli/simple-commands/performance-metrics.js +433 -348
- package/dist/src/cli/simple-commands/process-ui-enhanced.js +787 -708
- package/dist/src/cli/simple-commands/process-ui.js +254 -230
- package/dist/src/cli/simple-commands/realtime-update-system.js +611 -525
- package/dist/src/cli/simple-commands/sparc/architecture.js +1530 -1704
- package/dist/src/cli/simple-commands/sparc/commands.js +516 -438
- package/dist/src/cli/simple-commands/sparc/completion.js +1481 -1224
- package/dist/src/cli/simple-commands/sparc/coordinator.js +978 -913
- package/dist/src/cli/simple-commands/sparc/index.js +298 -241
- package/dist/src/cli/simple-commands/sparc/phase-base.js +390 -314
- package/dist/src/cli/simple-commands/sparc/pseudocode.js +869 -965
- package/dist/src/cli/simple-commands/sparc/refinement.js +1273 -980
- package/dist/src/cli/simple-commands/sparc/specification.js +645 -559
- package/dist/src/cli/simple-commands/sparc-modes/architect.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/ask.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/code.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/debug.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/devops.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/docs-writer.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/generic.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/index.js +55 -47
- package/dist/src/cli/simple-commands/sparc-modes/integration.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/mcp.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/monitoring.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/optimization.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/security-review.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/sparc-orchestrator.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/spec-pseudocode.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/supabase-admin.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/swarm.js +87 -101
- package/dist/src/cli/simple-commands/sparc-modes/tdd.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/tutorial.js +1 -1
- package/dist/src/cli/simple-commands/sparc.js +493 -465
- package/dist/src/cli/simple-commands/start-ui.js +132 -108
- package/dist/src/cli/simple-commands/start-wrapper.js +268 -240
- package/dist/src/cli/simple-commands/start.js +1 -1
- package/dist/src/cli/simple-commands/status.js +275 -254
- package/dist/src/cli/simple-commands/stream-chain-clean.js +171 -128
- package/dist/src/cli/simple-commands/stream-chain-fixed.js +82 -61
- package/dist/src/cli/simple-commands/stream-chain-real.js +331 -267
- package/dist/src/cli/simple-commands/stream-chain-working.js +263 -211
- package/dist/src/cli/simple-commands/stream-chain.js +318 -260
- package/dist/src/cli/simple-commands/stream-processor.js +315 -290
- package/dist/src/cli/simple-commands/swarm-executor.js +222 -189
- package/dist/src/cli/simple-commands/swarm-metrics-integration.js +300 -208
- package/dist/src/cli/simple-commands/swarm-ui.js +703 -623
- package/dist/src/cli/simple-commands/swarm-webui-integration.js +286 -258
- package/dist/src/cli/simple-commands/swarm.js +1082 -887
- package/dist/src/cli/simple-commands/task.js +206 -161
- package/dist/src/cli/simple-commands/timestamp-fix.js +89 -59
- package/dist/src/cli/simple-commands/token-tracker.js +316 -258
- package/dist/src/cli/simple-commands/tool-execution-framework.js +519 -433
- package/dist/src/cli/simple-commands/train-and-stream.js +331 -275
- package/dist/src/cli/simple-commands/training-pipeline.js +725 -619
- package/dist/src/cli/simple-commands/training.js +227 -170
- package/dist/src/cli/simple-commands/verification-hooks.js +284 -261
- package/dist/src/cli/simple-commands/verification-integration.js +417 -389
- package/dist/src/cli/simple-commands/verification-training-integration.js +606 -486
- package/dist/src/cli/simple-commands/verification.js +513 -493
- package/dist/src/cli/simple-commands/web-server.js +836 -766
- package/dist/src/cli/simple-commands/webui-validator.js +124 -106
- package/dist/src/coordination/byzantine-memory-channels.js +25 -1
- package/dist/src/coordination/event-bus/demo-wasm-integration.js +251 -212
- package/dist/src/coordination/event-bus/qe-event-bus.js +748 -608
- package/dist/src/coordination/event-bus/qe-event-bus.test.js +454 -379
- package/dist/src/coordination/iteration-tracker.js +454 -363
- package/dist/src/index.js +384 -35
- package/dist/src/mcp/DEPRECATED.js +60 -46
- package/dist/src/mcp/fixes/mcp-error-fixes.js +134 -115
- package/dist/src/mcp/implementations/agent-tracker.js +128 -114
- package/dist/src/mcp/implementations/daa-tools.js +350 -292
- package/dist/src/mcp/implementations/workflow-tools.js +361 -329
- package/dist/src/mcp/mcp-config-manager.js +1331 -1183
- package/dist/src/mcp/mcp-server-novice-simplified.js +17 -11
- package/dist/src/mcp/mcp-server-novice.js +17 -11
- package/dist/src/mcp/mcp-server-sdk.js +17 -11
- package/dist/src/mcp/mcp-server.js +1484 -1620
- package/dist/src/mcp/ruv-swarm-wrapper.js +239 -209
- package/dist/src/memory/advanced-serializer.js +589 -609
- package/dist/src/memory/enhanced-examples.js +305 -220
- package/dist/src/memory/enhanced-memory.js +336 -295
- package/dist/src/memory/enhanced-session-serializer.js +492 -408
- package/dist/src/memory/fallback-memory-system.js +1021 -900
- package/dist/src/memory/fallback-store.js +131 -93
- package/dist/src/memory/high-performance-serialization.js +730 -592
- package/dist/src/memory/in-memory-store.js +213 -161
- package/dist/src/memory/index.js +157 -123
- package/dist/src/memory/lock-free-structures.js +764 -578
- package/dist/src/memory/memory-mapped-persistence.js +766 -585
- package/dist/src/memory/memory-pressure-manager.js +707 -569
- package/dist/src/memory/migration.js +445 -358
- package/dist/src/memory/shared-memory.js +768 -641
- package/dist/src/memory/sqlite-store.js +325 -245
- package/dist/src/memory/sqlite-wrapper.js +151 -122
- package/dist/src/memory/swarm-memory.js +603 -470
- package/dist/src/memory/test-example.js +134 -126
- package/dist/src/memory/ultra-fast-memory-store.js +821 -622
- package/dist/src/memory/unified-memory-manager.js +437 -356
- package/dist/src/swarm/CodeRefactoringSwarm.js +952 -777
- package/dist/src/utils/__tests__/github-cli-safety-wrapper.test.js +400 -332
- package/dist/src/utils/error-handler.js +2 -36
- package/dist/src/utils/github-cli-safe.js +64 -56
- package/dist/src/utils/github-cli-safety-wrapper.js +546 -451
- package/dist/src/utils/npx-isolated-cache.js +119 -104
- package/dist/src/utils/preference-manager.js +652 -622
- package/dist/src/utils/timezone-utils.js +105 -86
- package/dist/src/web/api/apm-routes.js +353 -0
- package/dist/src/web/api/config/api-config.js +184 -0
- package/dist/src/web/api/middleware/auth.js +203 -0
- package/dist/src/web/api/middleware/cache.js +273 -0
- package/dist/src/web/api/middleware/error-handler.js +257 -0
- package/dist/src/web/api/middleware/request-logger.js +215 -0
- package/dist/src/web/api/middleware/validation.js +323 -0
- package/dist/src/web/api/routes/events.js +463 -0
- package/dist/src/web/api/routes/hierarchy.js +300 -0
- package/dist/src/web/api/routes/index.js +12 -0
- package/dist/src/web/api/routes/metrics.js +559 -0
- package/dist/src/web/api/routes/parallel-status.js +359 -0
- package/dist/src/web/api/routes/status.js +448 -0
- package/dist/src/web/api/server.js +462 -0
- package/dist/src/web/dashboard/hooks/useWebSocket.js +383 -0
- package/dist/src/web/dashboard/index.js +85 -0
- package/dist/src/web/dashboard/realtime/CustomSyncManager.js +439 -0
- package/dist/src/web/dashboard/realtime/NativeWebSocketManager.js +323 -0
- package/dist/src/web/dashboard/realtime/PerformanceBenchmark.js +527 -0
- package/dist/src/web/dashboard/realtime/RealtimeCommunicationManager.js +474 -0
- package/dist/src/web/dashboard/realtime/RealtimeServer.js +666 -0
- package/dist/src/web/dashboard/realtime/SSEManager.js +426 -0
- package/dist/src/web/dashboard/types.js +4 -0
- package/dist/src/web/messaging/agent-status-tracker.js +453 -0
- package/dist/src/web/messaging/human-intervention-system.js +305 -0
- package/dist/src/web/messaging/message-filter.js +302 -0
- package/dist/src/web/messaging/swarm-message-router.js +324 -0
- package/dist/src/web/messaging/transparency-logger.js +421 -0
- package/dist/src/web/portal-server.js +460 -0
- package/dist/src/web/server.js +322 -0
- package/dist/src/web/websocket/apm-websocket-handler.js +453 -0
- package/dist/src/web/websocket/websocket-manager.js +780 -0
- package/package.json +5 -3
- package/dist/src/cli/minimal-main.js +0 -22
- package/dist/src/enterprise/analytics-manager.js +0 -1135
- package/dist/src/enterprise/audit-manager.js +0 -1115
- package/dist/src/enterprise/cloud-manager.js +0 -891
- package/dist/src/enterprise/deployment-manager.js +0 -966
- package/dist/src/enterprise/index.js +0 -6
- package/dist/src/enterprise/project-manager.js +0 -584
- package/dist/src/enterprise/security-manager.js +0 -991
- package/dist/src/migration/index.js +0 -92
- package/dist/src/migration/logger.js +0 -121
- package/dist/src/migration/migration-analyzer.js +0 -268
- package/dist/src/migration/migration-runner.js +0 -522
- package/dist/src/migration/migration-validator.js +0 -285
- package/dist/src/migration/progress-reporter.js +0 -150
- package/dist/src/migration/rollback-manager.js +0 -321
- package/dist/src/migration/tests/migration-system.test.js +0 -7
- package/dist/src/migration/types.js +0 -3
- package/dist/src/swarm/__tests__/integration.test.js +0 -227
- package/dist/src/swarm/__tests__/prompt-copier.test.js +0 -344
- package/dist/src/swarm/advanced-orchestrator.js +0 -1095
- package/dist/src/swarm/claude-code-interface.js +0 -961
- package/dist/src/swarm/claude-flow-executor.js +0 -229
- package/dist/src/swarm/consensus-coordinator.js +0 -475
- package/dist/src/swarm/coordinator.js +0 -2993
- package/dist/src/swarm/direct-executor.js +0 -1180
- package/dist/src/swarm/error-recovery/advanced-error-detection.js +0 -691
- package/dist/src/swarm/error-recovery/automated-recovery-workflows.js +0 -998
- package/dist/src/swarm/error-recovery/error-recovery-coordinator.js +0 -1197
- package/dist/src/swarm/error-recovery/recovery-monitoring.js +0 -772
- package/dist/src/swarm/error-recovery/resilience-architecture.js +0 -714
- package/dist/src/swarm/error-recovery/self-healing-mechanisms.js +0 -1319
- package/dist/src/swarm/error-recovery/test-error-recovery-effectiveness.js +0 -808
- package/dist/src/swarm/executor-v2.js +0 -322
- package/dist/src/swarm/executor.js +0 -815
- package/dist/src/swarm/hive-mind-integration.js +0 -703
- package/dist/src/swarm/index.js +0 -41
- package/dist/src/swarm/json-output-aggregator.js +0 -267
- package/dist/src/swarm/large-scale-coordinator.js +0 -542
- package/dist/src/swarm/mcp-integration-wrapper.js +0 -628
- package/dist/src/swarm/memory.js +0 -1117
- package/dist/src/swarm/optimizations/__tests__/optimization.test.js +0 -348
- package/dist/src/swarm/optimizations/async-file-manager.js +0 -285
- package/dist/src/swarm/optimizations/circular-buffer.js +0 -162
- package/dist/src/swarm/optimizations/connection-pool.js +0 -244
- package/dist/src/swarm/optimizations/index.js +0 -28
- package/dist/src/swarm/optimizations/optimized-executor.js +0 -320
- package/dist/src/swarm/optimizations/ttl-map.js +0 -234
- package/dist/src/swarm/prompt-cli.js +0 -200
- package/dist/src/swarm/prompt-copier-enhanced.js +0 -202
- package/dist/src/swarm/prompt-copier.js +0 -381
- package/dist/src/swarm/prompt-manager.js +0 -295
- package/dist/src/swarm/prompt-utils.js +0 -310
- package/dist/src/swarm/result-aggregator.js +0 -718
- package/dist/src/swarm/sparc-executor.js +0 -1568
- package/dist/src/swarm/strategies/auto.js +0 -758
- package/dist/src/swarm/strategies/base.js +0 -128
- package/dist/src/swarm/strategies/research.js +0 -914
- package/dist/src/swarm/strategies/strategy-metrics-patch.js +0 -2
- package/dist/src/swarm/types.js +0 -52
- package/dist/src/swarm/workers/copy-worker.js +0 -56
- package/dist/src/validators/epic-config-schema.js +0 -214
- package/dist/src/validators/index.js +0 -10
- package/dist/src/validators/swarm-init-validator.js +0 -259
- package/dist/src/validators/todowrite-batching-validator.js +0 -215
- package/dist/src/validators/todowrite-integration.js +0 -187
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/documentSymbols/browser/documentSymbols.js +0 -23
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/dropOrPasteInto/browser/copyPasteContribution.js +0 -57
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/dropOrPasteInto/browser/copyPasteController.js +0 -401
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/dropOrPasteInto/browser/defaultProviders.js +0 -181
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/dropOrPasteInto/browser/dropIntoEditorContribution.js +0 -44
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/dropOrPasteInto/browser/dropIntoEditorController.js +0 -157
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/dropOrPasteInto/browser/edit.js +0 -71
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/editorState/browser/editorState.js +0 -112
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/find/browser/findController.js +0 -990
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/find/browser/findDecorations.js +0 -296
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/find/browser/findModel.js +0 -488
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/find/browser/findOptionsWidget.js +0 -138
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/find/browser/findState.js +0 -243
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/find/browser/findWidget.js +0 -1177
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/folding/browser/folding.js +0 -1093
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/folding/browser/foldingDecorations.js +0 -133
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/folding/browser/foldingModel.js +0 -538
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/folding/browser/foldingRanges.js +0 -351
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/fontZoom/browser/fontZoom.js +0 -49
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/format/browser/format.js +0 -360
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/format/browser/formatActions.js +0 -263
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/format/browser/formattingEdit.js +0 -54
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/gotoSymbol/browser/link/clickLinkGesture.js +0 -149
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/hover/browser/contentHover.js +0 -874
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/inlineCompletions/browser/commandIds.js +0 -7
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/inlineCompletions/browser/commands.js +0 -199
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/linesOperations/browser/copyLinesCommand.js +0 -70
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/quickAccess/browser/commandsQuickAccess.js +0 -26
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/quickAccess/browser/editorNavigationQuickAccess.js +0 -153
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/readOnlyMessage/browser/contribution.js +0 -33
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/semanticTokens/browser/documentSemanticTokens.js +0 -354
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/smartSelect/browser/bracketSelections.js +0 -146
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/suggest/browser/completionModel.js +0 -224
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/unicodeHighlighter/browser/bannerController.js +0 -119
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/edcore.main.js +0 -14
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/editor.all.js +0 -63
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/editor.api.js +0 -55
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/editor.main.js +0 -7
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/editor.worker.js +0 -25
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/standalone/browser/colorizer.js +0 -118
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/language/css/css.worker.js +0 -36869
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/language/css/cssMode.js +0 -2035
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/accessibility/browser/accessibilityService.js +0 -88
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/accessibility/common/accessibility.js +0 -9
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/action/common/action.js +0 -7
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/action/common/actionCommonCategories.js +0 -13
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/actionWidget/browser/actionList.js +0 -276
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/actionWidget/browser/actionWidget.js +0 -248
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/actionWidget/common/actionWidget.js +0 -5
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/actions/common/actions.js +0 -409
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/audioCues/browser/audioCueService.js +0 -176
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/clipboard/browser/clipboardService.js +0 -141
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/clipboard/common/clipboardService.js +0 -6
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/commands/common/commands.js +0 -80
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/configuration/common/configuration.js +0 -86
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/configuration/common/configurationModels.js +0 -554
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/configuration/common/configurationRegistry.js +0 -317
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/configuration/common/configurations.js +0 -41
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/contextkey/browser/contextKeyService.js +0 -432
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/contextkey/common/contextkey.js +0 -1547
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/contextkey/common/contextkeys.js +0 -18
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/contextview/browser/contextMenuHandler.js +0 -124
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/contextview/browser/contextMenuService.js +0 -101
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/contextview/browser/contextView.js +0 -7
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/contextview/browser/contextViewService.js +0 -72
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/dialogs/common/dialogs.js +0 -2
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/dnd/browser/dnd.js +0 -36
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/editor/common/editor.js +0 -17
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/environment/common/environment.js +0 -2
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/extensions/common/extensions.js +0 -47
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/files/common/files.js +0 -9
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/history/browser/contextScopedHistoryWidget.js +0 -105
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/instantiation/common/descriptors.js +0 -11
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/instantiation/common/extensions.js +0 -15
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/keybinding/common/abstractKeybindingService.js +0 -277
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/keybinding/common/baseResolvedKeybinding.js +0 -53
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/quickinput/browser/commandsQuickAccess.js +0 -354
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/theme/browser/defaultStyles.js +0 -162
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/theme/common/colorRegistry.js +0 -482
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/abap/abap.js +0 -10
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/apex/apex.js +0 -10
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/azcli/azcli.js +0 -10
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/bat/bat.js +0 -10
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/bicep/bicep.js +0 -11
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/cameligo/cameligo.js +0 -10
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/clojure/clojure.js +0 -10
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/coffee/coffee.js +0 -10
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/cpp/cpp.js +0 -10
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/csharp/csharp.js +0 -10
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/csp/csp.js +0 -10
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/css/css.js +0 -12
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/cypher/cypher.js +0 -10
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/dart/dart.js +0 -10
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/dockerfile/dockerfile.js +0 -10
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/ecl/ecl.js +0 -10
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/elixir/elixir.js +0 -10
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/flow9/flow9.js +0 -10
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/editor/editor.main.js +0 -745
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/editor/editor.main.nls.de.js +0 -31
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/editor/editor.main.nls.es.js +0 -31
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/editor/editor.main.nls.fr.js +0 -29
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/editor/editor.main.nls.it.js +0 -29
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/editor/editor.main.nls.ja.js +0 -31
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/editor/editor.main.nls.js +0 -29
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/editor/editor.main.nls.ko.js +0 -29
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/editor/editor.main.nls.ru.js +0 -31
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/editor/editor.main.nls.zh-cn.js +0 -31
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/editor/editor.main.nls.zh-tw.js +0 -29
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/language/css/cssMode.js +0 -13
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/language/css/cssWorker.js +0 -81
- package/dist/src/web/frontend/node_modules/.multicast-dns-iKseM9bB/cli.js +0 -64
- package/dist/src/web/frontend/node_modules/.multicast-dns-iKseM9bB/example.js +0 -36
- package/dist/src/web/frontend/node_modules/.multicast-dns-iKseM9bB/index.js +0 -205
- package/dist/src/web/frontend/node_modules/.multicast-dns-iKseM9bB/test.js +0 -260
- package/dist/src/web/frontend/node_modules/.nanoid-PAMEV9Hd/async/index.browser.js +0 -34
- package/dist/src/web/frontend/node_modules/.nanoid-PAMEV9Hd/async/index.js +0 -35
- package/dist/src/web/frontend/node_modules/.nanoid-PAMEV9Hd/async/index.native.js +0 -26
- package/dist/src/web/frontend/node_modules/.nanoid-PAMEV9Hd/index.browser.js +0 -34
- package/dist/src/web/frontend/node_modules/.nanoid-PAMEV9Hd/index.js +0 -45
- package/dist/src/web/frontend/node_modules/.nanoid-PAMEV9Hd/nanoid.js +0 -1
- package/dist/src/web/frontend/node_modules/.nanoid-PAMEV9Hd/non-secure/index.js +0 -21
- package/dist/src/web/frontend/node_modules/.nanoid-PAMEV9Hd/url-alphabet/index.js +0 -3
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/bin/nodemon.js +0 -16
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/cli/index.js +0 -49
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/cli/parse.js +0 -230
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/config/command.js +0 -43
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/config/defaults.js +0 -34
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/config/exec.js +0 -234
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/config/index.js +0 -93
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/config/load.js +0 -225
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/help/index.js +0 -27
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/index.js +0 -1
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/monitor/index.js +0 -4
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/monitor/match.js +0 -287
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/monitor/run.js +0 -562
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/monitor/signals.js +0 -34
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/monitor/watch.js +0 -244
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/nodemon.js +0 -317
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/rules/add.js +0 -89
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/rules/index.js +0 -53
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/rules/parse.js +0 -43
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/spawn.js +0 -74
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/utils/bus.js +0 -44
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/utils/clone.js +0 -40
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/utils/colour.js +0 -26
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/utils/index.js +0 -103
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/utils/log.js +0 -82
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/utils/merge.js +0 -47
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/version.js +0 -100
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/node_modules/brace-expansion/index.js +0 -201
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/node_modules/has-flag/index.js +0 -8
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/node_modules/minimatch/minimatch.js +0 -947
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/node_modules/supports-color/browser.js +0 -5
- package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/node_modules/supports-color/index.js +0 -131
- package/dist/src/web/frontend/node_modules/.pidtree-icfat3SQ/bin/pidtree.js +0 -128
- package/dist/src/web/frontend/node_modules/.pidtree-icfat3SQ/index.js +0 -49
- package/dist/src/web/frontend/node_modules/.pidtree-icfat3SQ/lib/bin.js +0 -61
- package/dist/src/web/frontend/node_modules/.pidtree-icfat3SQ/lib/get.js +0 -45
- package/dist/src/web/frontend/node_modules/.pidtree-icfat3SQ/lib/pidtree.js +0 -104
- package/dist/src/web/frontend/node_modules/.pidtree-icfat3SQ/lib/ps.js +0 -47
- package/dist/src/web/frontend/node_modules/.pidtree-icfat3SQ/lib/wmic.js +0 -49
- package/dist/src/web/frontend/node_modules/.prettier-ApZm3b7s/doc.js +0 -1270
- package/dist/src/web/frontend/node_modules/.prettier-ApZm3b7s/plugins/acorn.js +0 -15
- package/dist/src/web/frontend/node_modules/.prettier-ApZm3b7s/plugins/angular.js +0 -2
- package/dist/src/web/frontend/node_modules/.prettier-ApZm3b7s/plugins/babel.js +0 -15
- package/dist/src/web/frontend/node_modules/.prettier-ApZm3b7s/plugins/estree.js +0 -36
- package/dist/src/web/frontend/node_modules/.prettier-ApZm3b7s/plugins/flow.js +0 -19
- package/dist/src/web/frontend/node_modules/.prettier-ApZm3b7s/plugins/glimmer.js +0 -29
- package/dist/src/web/frontend/node_modules/.prettier-ApZm3b7s/plugins/graphql.js +0 -29
- package/dist/src/web/frontend/node_modules/.prettier-ApZm3b7s/plugins/html.js +0 -22
- package/dist/src/web/frontend/node_modules/.prettier-ApZm3b7s/plugins/markdown.js +0 -63
- package/dist/src/web/frontend/node_modules/.prettier-ApZm3b7s/plugins/meriyah.js +0 -4
- package/dist/src/web/frontend/node_modules/.prettier-ApZm3b7s/plugins/postcss.js +0 -54
- package/dist/src/web/frontend/node_modules/.prettier-ApZm3b7s/plugins/typescript.js +0 -20
- package/dist/src/web/frontend/node_modules/.prettier-ApZm3b7s/plugins/yaml.js +0 -160
- package/dist/src/web/frontend/node_modules/.prettier-ApZm3b7s/standalone.js +0 -34
- package/dist/src/web/frontend/node_modules/.react-scripts-OTANyoRb/bin/react-scripts.js +0 -58
- package/dist/src/web/frontend/node_modules/.react-scripts-OTANyoRb/config/env.js +0 -112
- package/dist/src/web/frontend/node_modules/.react-scripts-OTANyoRb/config/getHttpsConfig.js +0 -74
- package/dist/src/web/frontend/node_modules/.react-scripts-OTANyoRb/config/jest/babelTransform.js +0 -37
- package/dist/src/web/frontend/node_modules/.react-scripts-OTANyoRb/config/jest/cssTransform.js +0 -22
- package/dist/src/web/frontend/node_modules/.react-scripts-OTANyoRb/config/jest/fileTransform.js +0 -40
- package/dist/src/web/frontend/node_modules/.react-scripts-OTANyoRb/config/modules.js +0 -142
- package/dist/src/web/frontend/node_modules/.react-scripts-OTANyoRb/config/paths.js +0 -153
- package/dist/src/web/frontend/node_modules/.react-scripts-OTANyoRb/config/webpack/persistentCache/createEnvironmentHash.js +0 -9
- package/dist/src/web/frontend/node_modules/.react-scripts-OTANyoRb/config/webpack.config.js +0 -796
- package/dist/src/web/frontend/node_modules/.react-scripts-OTANyoRb/config/webpackDevServer.config.js +0 -135
- package/dist/src/web/frontend/node_modules/.react-scripts-OTANyoRb/scripts/build.js +0 -225
- package/dist/src/web/frontend/node_modules/.react-scripts-OTANyoRb/scripts/eject.js +0 -340
|
@@ -1,1084 +1,1271 @@
|
|
|
1
1
|
// init/index.js - Initialize Claude Code integration files
|
|
2
|
-
import { printSuccess, printError, printWarning } from
|
|
3
|
-
import { existsSync } from
|
|
4
|
-
import { promises as fs } from
|
|
5
|
-
import { fileURLToPath } from
|
|
6
|
-
import { dirname, join } from
|
|
7
|
-
import process from
|
|
8
|
-
import { spawn, execSync } from
|
|
2
|
+
import { printSuccess, printError, printWarning, exit } from '../../utils.js';
|
|
3
|
+
import { existsSync } from 'fs';
|
|
4
|
+
import { promises as fs } from 'fs';
|
|
5
|
+
import { fileURLToPath } from 'url';
|
|
6
|
+
import { dirname, join } from 'path';
|
|
7
|
+
import process from 'process';
|
|
8
|
+
import { spawn, execSync } from 'child_process';
|
|
9
|
+
import { promisify } from 'util';
|
|
10
|
+
|
|
9
11
|
// Helper to replace Deno.Command
|
|
10
12
|
function runCommand(command, args, options = {}) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
...options.env
|
|
17
|
-
},
|
|
18
|
-
stdio: options.stdout === 'inherit' ? 'inherit' : 'pipe'
|
|
19
|
-
});
|
|
20
|
-
let stdout = '';
|
|
21
|
-
let stderr = '';
|
|
22
|
-
if (options.stdout !== 'inherit') {
|
|
23
|
-
child.stdout.on('data', (data)=>{
|
|
24
|
-
stdout += data;
|
|
25
|
-
});
|
|
26
|
-
child.stderr.on('data', (data)=>{
|
|
27
|
-
stderr += data;
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
child.on('close', (code)=>{
|
|
31
|
-
if (code === 0) {
|
|
32
|
-
resolve({
|
|
33
|
-
success: true,
|
|
34
|
-
code,
|
|
35
|
-
stdout,
|
|
36
|
-
stderr
|
|
37
|
-
});
|
|
38
|
-
} else {
|
|
39
|
-
reject(new Error(`Command failed with exit code ${code}`));
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
child.on('error', reject);
|
|
13
|
+
return new Promise((resolve, reject) => {
|
|
14
|
+
const child = spawn(command, args, {
|
|
15
|
+
cwd: options.cwd,
|
|
16
|
+
env: { ...process.env, ...options.env },
|
|
17
|
+
stdio: options.stdout === 'inherit' ? 'inherit' : 'pipe',
|
|
43
18
|
});
|
|
19
|
+
|
|
20
|
+
let stdout = '';
|
|
21
|
+
let stderr = '';
|
|
22
|
+
|
|
23
|
+
if (options.stdout !== 'inherit') {
|
|
24
|
+
child.stdout.on('data', (data) => {
|
|
25
|
+
stdout += data;
|
|
26
|
+
});
|
|
27
|
+
child.stderr.on('data', (data) => {
|
|
28
|
+
stderr += data;
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
child.on('close', (code) => {
|
|
33
|
+
if (code === 0) {
|
|
34
|
+
resolve({ success: true, code, stdout, stderr });
|
|
35
|
+
} else {
|
|
36
|
+
reject(new Error(`Command failed with exit code ${code}`));
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
child.on('error', reject);
|
|
41
|
+
});
|
|
44
42
|
}
|
|
45
|
-
import { createLocalExecutable } from
|
|
46
|
-
import { createSparcStructureManually } from
|
|
47
|
-
import { createClaudeSlashCommands } from
|
|
48
|
-
import { createOptimizedClaudeSlashCommands } from
|
|
49
|
-
import { copyTemplates } from
|
|
50
|
-
import { copyRevisedTemplates, validateTemplatesExist } from
|
|
51
|
-
import {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
import {
|
|
58
|
-
import {
|
|
59
|
-
import {
|
|
60
|
-
import {
|
|
61
|
-
import {
|
|
62
|
-
|
|
43
|
+
import { createLocalExecutable } from './executable-wrapper.js';
|
|
44
|
+
import { createSparcStructureManually } from './sparc-structure.js';
|
|
45
|
+
import { createClaudeSlashCommands } from './claude-commands/slash-commands.js';
|
|
46
|
+
import { createOptimizedClaudeSlashCommands } from './claude-commands/optimized-slash-commands.js';
|
|
47
|
+
import { copyTemplates } from './template-copier.js';
|
|
48
|
+
import { copyRevisedTemplates, validateTemplatesExist } from './copy-revised-templates.js';
|
|
49
|
+
import {
|
|
50
|
+
copyAgentFiles,
|
|
51
|
+
createAgentDirectories,
|
|
52
|
+
validateAgentSystem,
|
|
53
|
+
copyCommandFiles,
|
|
54
|
+
} from './agent-copier.js';
|
|
55
|
+
import { showInitHelp } from './help.js';
|
|
56
|
+
import { batchInitCommand, batchInitFromConfig, validateBatchOptions } from './batch-init.js';
|
|
57
|
+
import { ValidationSystem, runFullValidation } from './validation/index.js';
|
|
58
|
+
import { RollbackSystem, createAtomicOperation } from './rollback/index.js';
|
|
59
|
+
import {
|
|
60
|
+
createEnhancedClaudeMd,
|
|
61
|
+
createEnhancedSettingsJson,
|
|
62
|
+
createWrapperScript,
|
|
63
|
+
createCommandDoc,
|
|
64
|
+
createHelperScript,
|
|
65
|
+
COMMAND_STRUCTURE,
|
|
66
|
+
} from './templates/enhanced-templates.js';
|
|
67
|
+
import { getIsolatedNpxEnv } from '../../../utils/npx-isolated-cache.js';
|
|
68
|
+
import { updateGitignore, needsGitignoreUpdate } from './gitignore-updater.js';
|
|
69
|
+
import {
|
|
70
|
+
createVerificationClaudeMd,
|
|
71
|
+
createVerificationSettingsJson,
|
|
72
|
+
} from './templates/verification-claude-md.js';
|
|
73
|
+
import { createFullMemoryBankMd, createMinimalMemoryBankMd } from './templates/memory-bank-md.js';
|
|
74
|
+
import {
|
|
75
|
+
createFullCoordinationMd,
|
|
76
|
+
createMinimalCoordinationMd,
|
|
77
|
+
} from './templates/coordination-md.js';
|
|
78
|
+
import { createAgentsReadme, createSessionsReadme } from './templates/readme-files.js';
|
|
79
|
+
import { initializeHiveMind, getHiveMindStatus, rollbackHiveMindInit } from './hive-mind-init.js';
|
|
80
|
+
|
|
63
81
|
// Get the directory path of this module for resolving template files
|
|
64
82
|
const __filename = fileURLToPath(import.meta.url);
|
|
65
83
|
const __dirname = dirname(__filename);
|
|
84
|
+
|
|
66
85
|
/**
|
|
67
86
|
* Read the CLAUDE.md template file
|
|
68
87
|
* @returns {Promise<string>} The template content
|
|
69
|
-
*/
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
88
|
+
*/
|
|
89
|
+
async function readClaudeMdTemplate() {
|
|
90
|
+
// In source: templates/CLAUDE.md
|
|
91
|
+
// In dist: the files are copied directly to init/ directory (not templates/)
|
|
92
|
+
const possiblePaths = [
|
|
93
|
+
join(__dirname, 'templates', 'CLAUDE.md'), // Source location
|
|
94
|
+
join(__dirname, 'CLAUDE.md'), // Dist location (files copied directly)
|
|
95
|
+
];
|
|
96
|
+
|
|
97
|
+
for (const templatePath of possiblePaths) {
|
|
98
|
+
try {
|
|
99
|
+
const content = await fs.readFile(templatePath, 'utf8');
|
|
100
|
+
console.log(`✅ Using CLAUDE.md template from: ${templatePath}`);
|
|
101
|
+
return content;
|
|
102
|
+
} catch (error) {
|
|
103
|
+
// Try next path
|
|
104
|
+
continue;
|
|
84
105
|
}
|
|
85
|
-
|
|
86
|
-
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// If template not found, throw error instead of falling back
|
|
109
|
+
throw new Error('CLAUDE.md template file not found! Please ensure templates are included in the build.');
|
|
87
110
|
}
|
|
111
|
+
|
|
88
112
|
/**
|
|
89
113
|
* Check if Claude Code CLI is installed
|
|
90
|
-
*/
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
}
|
|
114
|
+
*/
|
|
115
|
+
function isClaudeCodeInstalled() {
|
|
116
|
+
try {
|
|
117
|
+
execSync('which claude', { stdio: 'ignore' });
|
|
118
|
+
return true;
|
|
119
|
+
} catch {
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
99
122
|
}
|
|
123
|
+
|
|
100
124
|
/**
|
|
101
125
|
* Set up MCP servers in Claude Code (Legacy - replaced by bulletproof system)
|
|
102
|
-
*/
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
+
*/
|
|
127
|
+
async function setupMcpServers(dryRun = false) {
|
|
128
|
+
console.log('\n🔌 Setting up MCP servers for Claude Code...');
|
|
129
|
+
|
|
130
|
+
const servers = [
|
|
131
|
+
{
|
|
132
|
+
name: 'claude-flow-novice',
|
|
133
|
+
command: 'node dist/mcp/mcp-server-sdk.js',
|
|
134
|
+
description: 'Claude Flow Novice MCP server with 30 essential tools',
|
|
135
|
+
},
|
|
136
|
+
];
|
|
137
|
+
|
|
138
|
+
for (const server of servers) {
|
|
139
|
+
try {
|
|
140
|
+
if (!dryRun) {
|
|
141
|
+
console.log(` 🔄 Adding ${server.name}...`);
|
|
142
|
+
execSync(`claude mcp add ${server.name} ${server.command}`, { stdio: 'inherit' });
|
|
143
|
+
console.log(` ✅ Added ${server.name} - ${server.description}`);
|
|
144
|
+
} else {
|
|
145
|
+
console.log(` [DRY RUN] Would add ${server.name} - ${server.description}`);
|
|
146
|
+
}
|
|
147
|
+
} catch (err) {
|
|
148
|
+
console.log(` ⚠️ Failed to add ${server.name}: ${err.message}`);
|
|
149
|
+
console.log(
|
|
150
|
+
` You can add it manually with: claude mcp add ${server.name} ${server.command}`,
|
|
151
|
+
);
|
|
126
152
|
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
if (!dryRun) {
|
|
156
|
+
console.log('\n 📋 Verifying MCP servers...');
|
|
157
|
+
try {
|
|
158
|
+
execSync('claude mcp list', { stdio: 'inherit' });
|
|
159
|
+
} catch (err) {
|
|
160
|
+
console.log(' ⚠️ Could not verify MCP servers');
|
|
136
161
|
}
|
|
162
|
+
}
|
|
137
163
|
}
|
|
164
|
+
|
|
138
165
|
/**
|
|
139
166
|
* Bulletproof MCP setup using the new configuration manager
|
|
140
|
-
*/
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
167
|
+
*/
|
|
168
|
+
async function setupBulletproofMcp(options = {}) {
|
|
169
|
+
console.log('\n🛡️ Setting up bulletproof MCP configuration...');
|
|
170
|
+
|
|
171
|
+
try {
|
|
172
|
+
// Import the MCP configuration manager
|
|
173
|
+
const { enhancedMcpInit } = await import('../../mcp/mcp-config-manager.js');
|
|
174
|
+
|
|
175
|
+
const result = await enhancedMcpInit({
|
|
176
|
+
verbose: options.verbose || false,
|
|
177
|
+
autoFix: options.autoFix !== false, // Default to true
|
|
178
|
+
dryRun: options.dryRun || false,
|
|
179
|
+
enhancedUx: true, // Enable enhanced user experience
|
|
180
|
+
showEducation: options.showEducation || false // Show educational content for first-time users
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
if (result.success) {
|
|
184
|
+
console.log('✅ Bulletproof MCP configuration completed successfully');
|
|
185
|
+
|
|
186
|
+
// Display additional success information
|
|
187
|
+
if (result.details) {
|
|
188
|
+
console.log(` • Issues Fixed: ${result.details.issuesFixed || 0}`);
|
|
189
|
+
console.log(` • Health Score: ${result.details.healthScore || 'N/A'}/100`);
|
|
190
|
+
console.log(` • Duration: ${result.duration || 'N/A'}ms`);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
return true;
|
|
194
|
+
} else {
|
|
195
|
+
console.log(`⚠️ MCP configuration had issues: ${result.error}`);
|
|
196
|
+
|
|
197
|
+
// Display recovery information if available
|
|
198
|
+
if (result.rollbackAvailable) {
|
|
199
|
+
console.log(' 🔄 Automatic rollback was performed');
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
if (result.recovery && result.recovery.recommendedActions) {
|
|
203
|
+
console.log('\n 🛠️ Recommended actions:');
|
|
204
|
+
result.recovery.recommendedActions.slice(0, 3).forEach((action, i) => {
|
|
205
|
+
console.log(` ${i + 1}. ${action}`);
|
|
151
206
|
});
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
// Display recovery information if available
|
|
164
|
-
if (result.rollbackAvailable) {
|
|
165
|
-
console.log(' 🔄 Automatic rollback was performed');
|
|
166
|
-
}
|
|
167
|
-
if (result.recovery && result.recovery.recommendedActions) {
|
|
168
|
-
console.log('\n 🛠️ Recommended actions:');
|
|
169
|
-
result.recovery.recommendedActions.slice(0, 3).forEach((action, i)=>{
|
|
170
|
-
console.log(` ${i + 1}. ${action}`);
|
|
171
|
-
});
|
|
172
|
-
}
|
|
173
|
-
return false;
|
|
174
|
-
}
|
|
175
|
-
} catch (error) {
|
|
176
|
-
console.log(`⚠️ Bulletproof MCP setup failed: ${error.message}`);
|
|
177
|
-
console.log(' This may be due to missing dependencies or system configuration.');
|
|
178
|
-
// Check if it's a dependency issue
|
|
179
|
-
if (error.message.includes('Cannot find module') || error.message.includes('import')) {
|
|
180
|
-
console.log(' 💡 Try installing dependencies: npm install');
|
|
181
|
-
}
|
|
182
|
-
console.log(' 📞 Falling back to legacy MCP setup...');
|
|
183
|
-
// Fallback to legacy setup
|
|
184
|
-
await setupMcpServers(options.dryRun);
|
|
185
|
-
return false;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
return false;
|
|
210
|
+
}
|
|
211
|
+
} catch (error) {
|
|
212
|
+
console.log(`⚠️ Bulletproof MCP setup failed: ${error.message}`);
|
|
213
|
+
console.log(' This may be due to missing dependencies or system configuration.');
|
|
214
|
+
|
|
215
|
+
// Check if it's a dependency issue
|
|
216
|
+
if (error.message.includes('Cannot find module') || error.message.includes('import')) {
|
|
217
|
+
console.log(' 💡 Try installing dependencies: npm install');
|
|
186
218
|
}
|
|
219
|
+
|
|
220
|
+
console.log(' 📞 Falling back to legacy MCP setup...');
|
|
221
|
+
|
|
222
|
+
// Fallback to legacy setup
|
|
223
|
+
await setupMcpServers(options.dryRun);
|
|
224
|
+
return false;
|
|
225
|
+
}
|
|
187
226
|
}
|
|
227
|
+
|
|
188
228
|
export async function initCommand(subArgs, flags) {
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
229
|
+
// Show help if requested
|
|
230
|
+
if (flags.help || flags.h || subArgs.includes('--help') || subArgs.includes('-h')) {
|
|
231
|
+
showInitHelp();
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
// Check for verification flags first
|
|
236
|
+
const hasVerificationFlags =
|
|
237
|
+
subArgs.includes('--verify') || subArgs.includes('--pair') || flags.verify || flags.pair;
|
|
238
|
+
|
|
239
|
+
// Flow-nexus mode removed
|
|
240
|
+
|
|
241
|
+
// Default to enhanced Claude Flow v2 init unless other modes are specified
|
|
242
|
+
// Use --basic flag for old behavior, or verification flags for verification mode
|
|
243
|
+
if (!flags.basic && !flags.minimal && !flags.sparc && !hasVerificationFlags) {
|
|
244
|
+
return await enhancedClaudeFlowInit(flags, subArgs);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
// Check for validation and rollback commands
|
|
248
|
+
if (subArgs.includes('--validate') || subArgs.includes('--validate-only')) {
|
|
249
|
+
return handleValidationCommand(subArgs, flags);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
if (subArgs.includes('--rollback')) {
|
|
253
|
+
return handleRollbackCommand(subArgs, flags);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
if (subArgs.includes('--list-backups')) {
|
|
257
|
+
return handleListBackups(subArgs, flags);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
// Check for batch operations
|
|
261
|
+
const batchInitFlag = flags['batch-init'] || subArgs.includes('--batch-init');
|
|
262
|
+
const configFlag = flags.config || subArgs.includes('--config');
|
|
263
|
+
|
|
264
|
+
if (batchInitFlag || configFlag) {
|
|
265
|
+
return handleBatchInit(subArgs, flags);
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
// Parse init options
|
|
269
|
+
const initForce = subArgs.includes('--force') || subArgs.includes('-f') || flags.force;
|
|
270
|
+
const initMinimal = subArgs.includes('--minimal') || subArgs.includes('-m') || flags.minimal;
|
|
271
|
+
const initSparc = flags.roo || (subArgs && subArgs.includes('--roo')); // SPARC only with --roo flag
|
|
272
|
+
const initDryRun = subArgs.includes('--dry-run') || subArgs.includes('-d') || flags.dryRun;
|
|
273
|
+
const initOptimized = initSparc && initForce; // Use optimized templates when both flags are present
|
|
274
|
+
const selectedModes = flags.modes ? flags.modes.split(',') : null; // Support selective mode initialization
|
|
275
|
+
|
|
276
|
+
// Check for verification and pair programming flags
|
|
277
|
+
const initVerify = subArgs.includes('--verify') || flags.verify;
|
|
278
|
+
const initPair = subArgs.includes('--pair') || flags.pair;
|
|
279
|
+
|
|
280
|
+
// Get the actual working directory (where the command was run from)
|
|
281
|
+
// Use PWD environment variable which preserves the original directory
|
|
282
|
+
const workingDir = process.env.PWD || cwd();
|
|
283
|
+
console.log(`📁 Initializing in: ${workingDir}`);
|
|
284
|
+
|
|
285
|
+
// Change to the working directory to ensure all file operations happen there
|
|
286
|
+
try {
|
|
287
|
+
process.chdir(workingDir);
|
|
288
|
+
} catch (err) {
|
|
289
|
+
printWarning(`Could not change to directory ${workingDir}: ${err.message}`);
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
try {
|
|
293
|
+
printSuccess('Initializing Claude Code integration files...');
|
|
294
|
+
|
|
295
|
+
// Check if files already exist in the working directory
|
|
296
|
+
const files = ['CLAUDE.md', 'memory-bank.md', 'coordination.md'];
|
|
297
|
+
const existingFiles = [];
|
|
298
|
+
|
|
299
|
+
for (const file of files) {
|
|
300
|
+
try {
|
|
301
|
+
await fs.stat(`${workingDir}/${file}`);
|
|
302
|
+
existingFiles.push(file);
|
|
303
|
+
} catch {
|
|
304
|
+
// File doesn't exist, which is what we want
|
|
305
|
+
}
|
|
208
306
|
}
|
|
209
|
-
|
|
210
|
-
|
|
307
|
+
|
|
308
|
+
if (existingFiles.length > 0 && !initForce) {
|
|
309
|
+
printWarning(`The following files already exist: ${existingFiles.join(', ')}`);
|
|
310
|
+
console.log('Use --force to overwrite existing files');
|
|
311
|
+
return;
|
|
211
312
|
}
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
const
|
|
215
|
-
|
|
216
|
-
|
|
313
|
+
|
|
314
|
+
// Use template copier to copy all template files
|
|
315
|
+
const templateOptions = {
|
|
316
|
+
sparc: initSparc,
|
|
317
|
+
minimal: initMinimal,
|
|
318
|
+
optimized: initOptimized,
|
|
319
|
+
dryRun: initDryRun,
|
|
320
|
+
force: initForce,
|
|
321
|
+
selectedModes: selectedModes,
|
|
322
|
+
verify: initVerify,
|
|
323
|
+
pair: initPair,
|
|
324
|
+
};
|
|
325
|
+
|
|
326
|
+
// If verification flags are set, always use generated templates for CLAUDE.md and settings.json
|
|
327
|
+
if (initVerify || initPair) {
|
|
328
|
+
console.log(' 📁 Creating verification-focused configuration...');
|
|
329
|
+
|
|
330
|
+
// Create verification CLAUDE.md
|
|
331
|
+
if (!initDryRun) {
|
|
332
|
+
const { createVerificationClaudeMd, createVerificationSettingsJson } = await import(
|
|
333
|
+
'./templates/verification-claude-md.js'
|
|
334
|
+
);
|
|
335
|
+
await fs.writeFile(`${workingDir}/CLAUDE.md`, createVerificationClaudeMd(), 'utf8');
|
|
336
|
+
|
|
337
|
+
// Create .claude directory and settings
|
|
338
|
+
await fs.mkdir(`${workingDir}/.claude`, { recursive: true });
|
|
339
|
+
await fs.writeFile(
|
|
340
|
+
`${workingDir}/.claude/settings.json`,
|
|
341
|
+
createVerificationSettingsJson(),
|
|
342
|
+
'utf8',
|
|
343
|
+
);
|
|
344
|
+
console.log(' ✅ Created verification-focused CLAUDE.md and settings.json');
|
|
345
|
+
} else {
|
|
346
|
+
console.log(' [DRY RUN] Would create verification-focused CLAUDE.md and settings.json');
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
// Copy other template files from repository if available
|
|
350
|
+
const validation = validateTemplatesExist();
|
|
351
|
+
if (validation.valid) {
|
|
352
|
+
const revisedResults = await copyRevisedTemplates(workingDir, {
|
|
353
|
+
force: initForce,
|
|
354
|
+
dryRun: initDryRun,
|
|
355
|
+
verbose: false,
|
|
356
|
+
sparc: initSparc,
|
|
357
|
+
});
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
// Also create standard memory and coordination files
|
|
361
|
+
const copyResults = await copyTemplates(workingDir, {
|
|
362
|
+
...templateOptions,
|
|
363
|
+
skipClaudeMd: true, // Don't overwrite the verification CLAUDE.md
|
|
364
|
+
skipSettings: true, // Don't overwrite the verification settings.json
|
|
365
|
+
});
|
|
366
|
+
} else {
|
|
367
|
+
// Standard template copying logic
|
|
368
|
+
const validation = validateTemplatesExist();
|
|
369
|
+
if (validation.valid) {
|
|
370
|
+
console.log(' 📁 Copying revised template files...');
|
|
371
|
+
const revisedResults = await copyRevisedTemplates(workingDir, {
|
|
372
|
+
force: initForce,
|
|
373
|
+
dryRun: initDryRun,
|
|
374
|
+
verbose: true,
|
|
375
|
+
sparc: initSparc,
|
|
376
|
+
});
|
|
377
|
+
|
|
378
|
+
if (revisedResults.success) {
|
|
379
|
+
console.log(` ✅ Copied ${revisedResults.copiedFiles.length} template files`);
|
|
380
|
+
if (revisedResults.skippedFiles.length > 0) {
|
|
381
|
+
console.log(` ⏭️ Skipped ${revisedResults.skippedFiles.length} existing files`);
|
|
382
|
+
}
|
|
383
|
+
} else {
|
|
384
|
+
console.log(' ⚠️ Some template files could not be copied:');
|
|
385
|
+
revisedResults.errors.forEach((err) => console.log(` - ${err}`));
|
|
386
|
+
}
|
|
387
|
+
} else {
|
|
388
|
+
// Fall back to generated templates
|
|
389
|
+
console.log(' ⚠️ Revised templates not available, using generated templates');
|
|
390
|
+
const copyResults = await copyTemplates(workingDir, templateOptions);
|
|
391
|
+
|
|
392
|
+
if (!copyResults.success) {
|
|
393
|
+
printError('Failed to copy templates:');
|
|
394
|
+
copyResults.errors.forEach((err) => console.log(` ❌ ${err}`));
|
|
395
|
+
return;
|
|
396
|
+
}
|
|
397
|
+
}
|
|
217
398
|
}
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
//
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
// Change to the working directory to ensure all file operations happen there
|
|
233
|
-
try {
|
|
234
|
-
process.chdir(workingDir);
|
|
235
|
-
} catch (err) {
|
|
236
|
-
printWarning(`Could not change to directory ${workingDir}: ${err.message}`);
|
|
399
|
+
|
|
400
|
+
// Agent setup moved to end of function where execution is guaranteed
|
|
401
|
+
|
|
402
|
+
// Directory structure is created by template copier
|
|
403
|
+
|
|
404
|
+
// SPARC files are created by template copier when --sparc flag is used
|
|
405
|
+
|
|
406
|
+
// Memory README files and persistence database are created by template copier
|
|
407
|
+
|
|
408
|
+
// Create local claude-flow-novice executable wrapper
|
|
409
|
+
if (!initDryRun) {
|
|
410
|
+
await createLocalExecutable(workingDir);
|
|
411
|
+
} else {
|
|
412
|
+
console.log(' [DRY RUN] Would create local claude-flow-novice executable wrapper');
|
|
237
413
|
}
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
];
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
414
|
+
|
|
415
|
+
// SPARC initialization
|
|
416
|
+
if (initSparc) {
|
|
417
|
+
console.log('\n🚀 Initializing SPARC development environment...');
|
|
418
|
+
|
|
419
|
+
if (initDryRun) {
|
|
420
|
+
console.log(' [DRY RUN] Would run: npx -y create-sparc init --force');
|
|
421
|
+
console.log(' [DRY RUN] Would create SPARC environment with all modes');
|
|
422
|
+
console.log(
|
|
423
|
+
' [DRY RUN] Would create Claude slash commands' +
|
|
424
|
+
(initOptimized ? ' (Batchtools-optimized)' : ''),
|
|
425
|
+
);
|
|
426
|
+
if (selectedModes) {
|
|
427
|
+
console.log(
|
|
428
|
+
` [DRY RUN] Would create commands for selected modes: ${selectedModes.join(', ')}`,
|
|
429
|
+
);
|
|
254
430
|
}
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
431
|
+
} else {
|
|
432
|
+
// Check if create-sparc exists and run it
|
|
433
|
+
let sparcInitialized = false;
|
|
434
|
+
try {
|
|
435
|
+
// Use isolated NPX cache to prevent concurrent conflicts
|
|
436
|
+
console.log(' 🔄 Running: npx -y create-sparc init --force');
|
|
437
|
+
const createSparcResult = await runCommand(
|
|
438
|
+
'npx',
|
|
439
|
+
['-y', 'create-sparc', 'init', '--force'],
|
|
440
|
+
{
|
|
441
|
+
cwd: workingDir,
|
|
442
|
+
stdout: 'inherit',
|
|
443
|
+
stderr: 'inherit',
|
|
444
|
+
env: getIsolatedNpxEnv({
|
|
445
|
+
PWD: workingDir,
|
|
446
|
+
}),
|
|
447
|
+
},
|
|
448
|
+
);
|
|
449
|
+
|
|
450
|
+
if (createSparcResult.success) {
|
|
451
|
+
console.log(' ✅ SPARC environment initialized successfully');
|
|
452
|
+
sparcInitialized = true;
|
|
453
|
+
} else {
|
|
454
|
+
printWarning('create-sparc failed, creating basic SPARC structure manually...');
|
|
455
|
+
|
|
456
|
+
// Fallback: create basic SPARC structure manually
|
|
457
|
+
await createSparcStructureManually();
|
|
458
|
+
sparcInitialized = true; // Manual creation still counts as initialized
|
|
459
|
+
}
|
|
460
|
+
} catch (err) {
|
|
461
|
+
printWarning('create-sparc not available, creating basic SPARC structure manually...');
|
|
462
|
+
|
|
463
|
+
// Fallback: create basic SPARC structure manually
|
|
464
|
+
await createSparcStructureManually();
|
|
465
|
+
sparcInitialized = true; // Manual creation still counts as initialized
|
|
259
466
|
}
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
force: initForce,
|
|
267
|
-
selectedModes: selectedModes,
|
|
268
|
-
verify: initVerify,
|
|
269
|
-
pair: initPair
|
|
270
|
-
};
|
|
271
|
-
// If verification flags are set, always use generated templates for CLAUDE.md and settings.json
|
|
272
|
-
if (initVerify || initPair) {
|
|
273
|
-
console.log(' 📁 Creating verification-focused configuration...');
|
|
274
|
-
// Create verification CLAUDE.md
|
|
275
|
-
if (!initDryRun) {
|
|
276
|
-
const { createVerificationClaudeMd, createVerificationSettingsJson } = await import("./templates/verification-claude-md.js");
|
|
277
|
-
await fs.writeFile(`${workingDir}/CLAUDE.md`, createVerificationClaudeMd(), 'utf8');
|
|
278
|
-
// Create .claude directory and settings
|
|
279
|
-
await fs.mkdir(`${workingDir}/.claude`, {
|
|
280
|
-
recursive: true
|
|
281
|
-
});
|
|
282
|
-
await fs.writeFile(`${workingDir}/.claude/settings.json`, createVerificationSettingsJson(), 'utf8');
|
|
283
|
-
console.log(' ✅ Created verification-focused CLAUDE.md and settings.json');
|
|
284
|
-
} else {
|
|
285
|
-
console.log(' [DRY RUN] Would create verification-focused CLAUDE.md and settings.json');
|
|
286
|
-
}
|
|
287
|
-
// Copy other template files from repository if available
|
|
288
|
-
const validation = validateTemplatesExist();
|
|
289
|
-
if (validation.valid) {
|
|
290
|
-
const revisedResults = await copyRevisedTemplates(workingDir, {
|
|
291
|
-
force: initForce,
|
|
292
|
-
dryRun: initDryRun,
|
|
293
|
-
verbose: false,
|
|
294
|
-
sparc: initSparc
|
|
295
|
-
});
|
|
296
|
-
}
|
|
297
|
-
// Also create standard memory and coordination files
|
|
298
|
-
const copyResults = await copyTemplates(workingDir, {
|
|
299
|
-
...templateOptions,
|
|
300
|
-
skipClaudeMd: true,
|
|
301
|
-
skipSettings: true
|
|
302
|
-
});
|
|
303
|
-
} else {
|
|
304
|
-
// Standard template copying logic
|
|
305
|
-
const validation = validateTemplatesExist();
|
|
306
|
-
if (validation.valid) {
|
|
307
|
-
console.log(' 📁 Copying revised template files...');
|
|
308
|
-
const revisedResults = await copyRevisedTemplates(workingDir, {
|
|
309
|
-
force: initForce,
|
|
310
|
-
dryRun: initDryRun,
|
|
311
|
-
verbose: true,
|
|
312
|
-
sparc: initSparc
|
|
313
|
-
});
|
|
314
|
-
if (revisedResults.success) {
|
|
315
|
-
console.log(` ✅ Copied ${revisedResults.copiedFiles.length} template files`);
|
|
316
|
-
if (revisedResults.skippedFiles.length > 0) {
|
|
317
|
-
console.log(` ⏭️ Skipped ${revisedResults.skippedFiles.length} existing files`);
|
|
318
|
-
}
|
|
319
|
-
} else {
|
|
320
|
-
console.log(' ⚠️ Some template files could not be copied:');
|
|
321
|
-
revisedResults.errors.forEach((err)=>console.log(` - ${err}`));
|
|
322
|
-
}
|
|
467
|
+
|
|
468
|
+
// Always create Claude slash commands after SPARC initialization
|
|
469
|
+
if (sparcInitialized) {
|
|
470
|
+
try {
|
|
471
|
+
if (initOptimized) {
|
|
472
|
+
await createOptimizedClaudeSlashCommands(workingDir, selectedModes);
|
|
323
473
|
} else {
|
|
324
|
-
|
|
325
|
-
console.log(' ⚠️ Revised templates not available, using generated templates');
|
|
326
|
-
const copyResults = await copyTemplates(workingDir, templateOptions);
|
|
327
|
-
if (!copyResults.success) {
|
|
328
|
-
printError('Failed to copy templates:');
|
|
329
|
-
copyResults.errors.forEach((err)=>console.log(` ❌ ${err}`));
|
|
330
|
-
return;
|
|
331
|
-
}
|
|
474
|
+
await createClaudeSlashCommands(workingDir);
|
|
332
475
|
}
|
|
476
|
+
} catch (err) {
|
|
477
|
+
// Legacy slash command creation - silently skip if it fails
|
|
478
|
+
// SPARC slash commands are already created successfully above
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
if (initDryRun) {
|
|
485
|
+
printSuccess("🔍 Dry run completed! Here's what would be created:");
|
|
486
|
+
console.log('\n📋 Summary of planned initialization:');
|
|
487
|
+
console.log(
|
|
488
|
+
` • Configuration: ${initOptimized ? 'Batchtools-optimized SPARC' : initSparc ? 'SPARC-enhanced' : 'Standard'}`,
|
|
489
|
+
);
|
|
490
|
+
console.log(
|
|
491
|
+
` • Template type: ${initOptimized ? 'Optimized for parallel processing' : 'Standard'}`,
|
|
492
|
+
);
|
|
493
|
+
console.log(' • Core files: CLAUDE.md, memory-bank.md, coordination.md');
|
|
494
|
+
console.log(' • Directory structure: memory/, coordination/, .claude/');
|
|
495
|
+
console.log(' • Local executable: ./claude-flow');
|
|
496
|
+
if (initSparc) {
|
|
497
|
+
console.log(
|
|
498
|
+
` • Claude Code slash commands: ${selectedModes ? selectedModes.length : 'All'} SPARC mode commands`,
|
|
499
|
+
);
|
|
500
|
+
console.log(' • SPARC environment with all development modes');
|
|
501
|
+
}
|
|
502
|
+
if (initOptimized) {
|
|
503
|
+
console.log(' • Batchtools optimization: Enabled for parallel processing');
|
|
504
|
+
console.log(' • Performance enhancements: Smart batching, concurrent operations');
|
|
505
|
+
}
|
|
506
|
+
console.log('\n🚀 To proceed with initialization, run the same command without --dry-run');
|
|
507
|
+
} else {
|
|
508
|
+
printSuccess('🎉 Claude Code integration files initialized successfully!');
|
|
509
|
+
|
|
510
|
+
if (initOptimized) {
|
|
511
|
+
console.log('\n⚡ Batchtools Optimization Enabled!');
|
|
512
|
+
console.log(' • Parallel processing capabilities activated');
|
|
513
|
+
console.log(' • Performance improvements: 250-500% faster operations');
|
|
514
|
+
console.log(' • Smart batching and concurrent operations available');
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
console.log('\n📋 What was created:');
|
|
518
|
+
console.log(
|
|
519
|
+
` ✅ CLAUDE.md (${initOptimized ? 'Batchtools-optimized' : initSparc ? 'SPARC-enhanced' : 'Standard configuration'})`,
|
|
520
|
+
);
|
|
521
|
+
console.log(
|
|
522
|
+
` ✅ memory-bank.md (${initOptimized ? 'With parallel processing' : 'Standard memory system'})`,
|
|
523
|
+
);
|
|
524
|
+
console.log(
|
|
525
|
+
` ✅ coordination.md (${initOptimized ? 'Enhanced with batchtools' : 'Standard coordination'})`,
|
|
526
|
+
);
|
|
527
|
+
console.log(' ✅ Directory structure with memory/ and coordination/');
|
|
528
|
+
console.log(' ✅ Local executable at ./claude-flow');
|
|
529
|
+
console.log(' ✅ Persistence database at memory/claude-flow-data.json');
|
|
530
|
+
console.log(' ✅ Agent system with 64 specialized agents in .claude/agents/');
|
|
531
|
+
|
|
532
|
+
if (initSparc) {
|
|
533
|
+
const modeCount = selectedModes ? selectedModes.length : '20+';
|
|
534
|
+
console.log(` ✅ Claude Code slash commands (${modeCount} SPARC modes)`);
|
|
535
|
+
console.log(' ✅ Complete SPARC development environment');
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
console.log('\n🚀 Next steps:');
|
|
539
|
+
console.log('1. Review and customize the generated files for your project');
|
|
540
|
+
console.log("2. Run './claude-flow-novice start' to begin the orchestration system");
|
|
541
|
+
console.log("3. Use './claude-flow' instead of 'npx claude-flow' for all commands");
|
|
542
|
+
console.log("4. Use 'claude --dangerously-skip-permissions' for unattended operation");
|
|
543
|
+
|
|
544
|
+
if (initSparc) {
|
|
545
|
+
console.log(
|
|
546
|
+
'5. Use Claude Code slash commands: /sparc, /sparc-architect, /sparc-tdd, etc.',
|
|
547
|
+
);
|
|
548
|
+
console.log("6. Explore SPARC modes with './claude-flow-novice sparc modes'");
|
|
549
|
+
console.log('7. Try TDD workflow with \'./claude-flow-novice sparc tdd "your task"\'');
|
|
550
|
+
|
|
551
|
+
if (initOptimized) {
|
|
552
|
+
console.log('8. Use batchtools commands: /batchtools, /performance for optimization');
|
|
553
|
+
console.log('9. Enable parallel processing with --parallel flags');
|
|
554
|
+
console.log("10. Monitor performance with './claude-flow-novice performance monitor'");
|
|
333
555
|
}
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
// Update .gitignore
|
|
559
|
+
const gitignoreResult = await updateGitignore(workingDir, initForce, initDryRun);
|
|
560
|
+
if (gitignoreResult.success) {
|
|
339
561
|
if (!initDryRun) {
|
|
340
|
-
|
|
562
|
+
console.log(` ✅ ${gitignoreResult.message}`);
|
|
341
563
|
} else {
|
|
342
|
-
|
|
564
|
+
console.log(` ${gitignoreResult.message}`);
|
|
343
565
|
}
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
await createSparcStructureManually();
|
|
380
|
-
sparcInitialized = true; // Manual creation still counts as initialized
|
|
381
|
-
}
|
|
382
|
-
} catch (err) {
|
|
383
|
-
printWarning('create-sparc not available, creating basic SPARC structure manually...');
|
|
384
|
-
// Fallback: create basic SPARC structure manually
|
|
385
|
-
await createSparcStructureManually();
|
|
386
|
-
sparcInitialized = true; // Manual creation still counts as initialized
|
|
387
|
-
}
|
|
388
|
-
// Always create Claude slash commands after SPARC initialization
|
|
389
|
-
if (sparcInitialized) {
|
|
390
|
-
try {
|
|
391
|
-
if (initOptimized) {
|
|
392
|
-
await createOptimizedClaudeSlashCommands(workingDir, selectedModes);
|
|
393
|
-
} else {
|
|
394
|
-
await createClaudeSlashCommands(workingDir);
|
|
395
|
-
}
|
|
396
|
-
} catch (err) {
|
|
397
|
-
// Legacy slash command creation - silently skip if it fails
|
|
398
|
-
// SPARC slash commands are already created successfully above
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
}
|
|
566
|
+
} else {
|
|
567
|
+
console.log(` ⚠️ ${gitignoreResult.message}`);
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
console.log('\n💡 Tips:');
|
|
571
|
+
console.log(" • Type '/' in Claude Code to see all available slash commands");
|
|
572
|
+
console.log(" • Use './claude-flow-novice status' to check system health");
|
|
573
|
+
console.log(" • Store important context with './claude-flow-novice memory store'");
|
|
574
|
+
|
|
575
|
+
if (initOptimized) {
|
|
576
|
+
console.log(' • Use --parallel flags for concurrent operations');
|
|
577
|
+
console.log(' • Enable batch processing for multiple related tasks');
|
|
578
|
+
console.log(' • Monitor performance with real-time metrics');
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
// Initialize hive-mind system for standard init
|
|
582
|
+
console.log('\n🧠 Initializing basic hive-mind system...');
|
|
583
|
+
try {
|
|
584
|
+
const hiveMindOptions = {
|
|
585
|
+
config: {
|
|
586
|
+
integration: {
|
|
587
|
+
claudeCode: { enabled: isClaudeCodeInstalled() },
|
|
588
|
+
mcpTools: { enabled: true },
|
|
589
|
+
},
|
|
590
|
+
monitoring: { enabled: false }, // Basic setup for standard init
|
|
591
|
+
},
|
|
592
|
+
};
|
|
593
|
+
|
|
594
|
+
const hiveMindResult = await initializeHiveMind(workingDir, hiveMindOptions, false);
|
|
595
|
+
|
|
596
|
+
if (hiveMindResult.success) {
|
|
597
|
+
console.log(' ✅ Basic hive-mind system initialized');
|
|
598
|
+
console.log(' 💡 Use "npx claude-flow-novice hive-mind" for advanced features');
|
|
599
|
+
} else {
|
|
600
|
+
console.log(` ⚠️ Hive-mind setup skipped: ${hiveMindResult.error}`);
|
|
402
601
|
}
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
602
|
+
} catch (err) {
|
|
603
|
+
console.log(` ⚠️ Hive-mind setup skipped: ${err.message}`);
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
// Check for Claude Code and set up MCP servers (always enabled by default)
|
|
607
|
+
if (!initDryRun && isClaudeCodeInstalled()) {
|
|
608
|
+
console.log('\n🔍 Claude Code CLI detected!');
|
|
609
|
+
const skipMcp = subArgs && subArgs.includes && subArgs.includes('--skip-mcp');
|
|
610
|
+
|
|
611
|
+
if (!skipMcp) {
|
|
612
|
+
// Use bulletproof MCP setup instead of legacy
|
|
613
|
+
const mcpSuccess = await setupBulletproofMcp({
|
|
614
|
+
verbose: false,
|
|
615
|
+
autoFix: true,
|
|
616
|
+
dryRun: initDryRun
|
|
617
|
+
});
|
|
618
|
+
|
|
619
|
+
if (!mcpSuccess) {
|
|
620
|
+
console.log(' 💡 If you encounter issues, run: claude mcp remove claude-flow-novice -s local');
|
|
621
|
+
}
|
|
420
622
|
} else {
|
|
421
|
-
|
|
422
|
-
if (initOptimized) {
|
|
423
|
-
console.log('\n⚡ Batchtools Optimization Enabled!');
|
|
424
|
-
console.log(' • Parallel processing capabilities activated');
|
|
425
|
-
console.log(' • Performance improvements: 250-500% faster operations');
|
|
426
|
-
console.log(' • Smart batching and concurrent operations available');
|
|
427
|
-
}
|
|
428
|
-
console.log('\n📋 What was created:');
|
|
429
|
-
console.log(` ✅ CLAUDE.md (${initOptimized ? 'Batchtools-optimized' : initSparc ? 'SPARC-enhanced' : 'Standard configuration'})`);
|
|
430
|
-
console.log(` ✅ memory-bank.md (${initOptimized ? 'With parallel processing' : 'Standard memory system'})`);
|
|
431
|
-
console.log(` ✅ coordination.md (${initOptimized ? 'Enhanced with batchtools' : 'Standard coordination'})`);
|
|
432
|
-
console.log(' ✅ Directory structure with memory/ and coordination/');
|
|
433
|
-
console.log(' ✅ Local executable at ./claude-flow');
|
|
434
|
-
console.log(' ✅ Persistence database at memory/claude-flow-data.json');
|
|
435
|
-
console.log(' ✅ Agent system with 64 specialized agents in .claude/agents/');
|
|
436
|
-
if (initSparc) {
|
|
437
|
-
const modeCount = selectedModes ? selectedModes.length : '20+';
|
|
438
|
-
console.log(` ✅ Claude Code slash commands (${modeCount} SPARC modes)`);
|
|
439
|
-
console.log(' ✅ Complete SPARC development environment');
|
|
440
|
-
}
|
|
441
|
-
console.log('\n🚀 Next steps:');
|
|
442
|
-
console.log('1. Review and customize the generated files for your project');
|
|
443
|
-
console.log("2. Run './claude-flow-novice start' to begin the orchestration system");
|
|
444
|
-
console.log("3. Use './claude-flow' instead of 'npx claude-flow' for all commands");
|
|
445
|
-
console.log("4. Use 'claude --dangerously-skip-permissions' for unattended operation");
|
|
446
|
-
if (initSparc) {
|
|
447
|
-
console.log('5. Use Claude Code slash commands: /sparc, /sparc-architect, /sparc-tdd, etc.');
|
|
448
|
-
console.log("6. Explore SPARC modes with './claude-flow-novice sparc modes'");
|
|
449
|
-
console.log('7. Try TDD workflow with \'./claude-flow-novice sparc tdd "your task"\'');
|
|
450
|
-
if (initOptimized) {
|
|
451
|
-
console.log('8. Use batchtools commands: /batchtools, /performance for optimization');
|
|
452
|
-
console.log('9. Enable parallel processing with --parallel flags');
|
|
453
|
-
console.log("10. Monitor performance with './claude-flow-novice performance monitor'");
|
|
454
|
-
}
|
|
455
|
-
}
|
|
456
|
-
// Update .gitignore
|
|
457
|
-
const gitignoreResult = await updateGitignore(workingDir, initForce, initDryRun);
|
|
458
|
-
if (gitignoreResult.success) {
|
|
459
|
-
if (!initDryRun) {
|
|
460
|
-
console.log(` ✅ ${gitignoreResult.message}`);
|
|
461
|
-
} else {
|
|
462
|
-
console.log(` ${gitignoreResult.message}`);
|
|
463
|
-
}
|
|
464
|
-
} else {
|
|
465
|
-
console.log(` ⚠️ ${gitignoreResult.message}`);
|
|
466
|
-
}
|
|
467
|
-
console.log('\n💡 Tips:');
|
|
468
|
-
console.log(" • Type '/' in Claude Code to see all available slash commands");
|
|
469
|
-
console.log(" • Use './claude-flow-novice status' to check system health");
|
|
470
|
-
console.log(" • Store important context with './claude-flow-novice memory store'");
|
|
471
|
-
if (initOptimized) {
|
|
472
|
-
console.log(' • Use --parallel flags for concurrent operations');
|
|
473
|
-
console.log(' • Enable batch processing for multiple related tasks');
|
|
474
|
-
console.log(' • Monitor performance with real-time metrics');
|
|
475
|
-
}
|
|
476
|
-
// Initialize hive-mind system for standard init
|
|
477
|
-
console.log('\n🧠 Initializing basic hive-mind system...');
|
|
478
|
-
try {
|
|
479
|
-
const hiveMindOptions = {
|
|
480
|
-
config: {
|
|
481
|
-
integration: {
|
|
482
|
-
claudeCode: {
|
|
483
|
-
enabled: isClaudeCodeInstalled()
|
|
484
|
-
},
|
|
485
|
-
mcpTools: {
|
|
486
|
-
enabled: true
|
|
487
|
-
}
|
|
488
|
-
},
|
|
489
|
-
monitoring: {
|
|
490
|
-
enabled: false
|
|
491
|
-
}
|
|
492
|
-
}
|
|
493
|
-
};
|
|
494
|
-
const hiveMindResult = await initializeHiveMind(workingDir, hiveMindOptions, false);
|
|
495
|
-
if (hiveMindResult.success) {
|
|
496
|
-
console.log(' ✅ Basic hive-mind system initialized');
|
|
497
|
-
console.log(' 💡 Use "npx claude-flow-novice hive-mind" for advanced features');
|
|
498
|
-
} else {
|
|
499
|
-
console.log(` ⚠️ Hive-mind setup skipped: ${hiveMindResult.error}`);
|
|
500
|
-
}
|
|
501
|
-
} catch (err) {
|
|
502
|
-
console.log(` ⚠️ Hive-mind setup skipped: ${err.message}`);
|
|
503
|
-
}
|
|
504
|
-
// Check for Claude Code and set up MCP servers (always enabled by default)
|
|
505
|
-
if (!initDryRun && isClaudeCodeInstalled()) {
|
|
506
|
-
console.log('\n🔍 Claude Code CLI detected!');
|
|
507
|
-
const skipMcp = subArgs && subArgs.includes && subArgs.includes('--skip-mcp');
|
|
508
|
-
if (!skipMcp) {
|
|
509
|
-
// Use bulletproof MCP setup instead of legacy
|
|
510
|
-
const mcpSuccess = await setupBulletproofMcp({
|
|
511
|
-
verbose: false,
|
|
512
|
-
autoFix: true,
|
|
513
|
-
dryRun: initDryRun
|
|
514
|
-
});
|
|
515
|
-
if (!mcpSuccess) {
|
|
516
|
-
console.log(' 💡 If you encounter issues, run: claude mcp remove claude-flow-novice -s local');
|
|
517
|
-
}
|
|
518
|
-
} else {
|
|
519
|
-
console.log(' ℹ️ Skipping MCP setup (--skip-mcp flag used)');
|
|
520
|
-
}
|
|
521
|
-
} else if (!initDryRun && !isClaudeCodeInstalled()) {
|
|
522
|
-
console.log('\n⚠️ Claude Code CLI not detected!');
|
|
523
|
-
console.log(' 📥 Install with: npm install -g @anthropic-ai/claude-code');
|
|
524
|
-
console.log(' 📋 Then add MCP servers manually with:');
|
|
525
|
-
console.log(' claude mcp add claude-flow-novice claude-flow-novice mcp start');
|
|
526
|
-
console.log(' claude mcp add ruv-swarm npx ruv-swarm mcp start');
|
|
527
|
-
// Flow-nexus integration removed
|
|
528
|
-
}
|
|
623
|
+
console.log(' ℹ️ Skipping MCP setup (--skip-mcp flag used)');
|
|
529
624
|
}
|
|
530
|
-
|
|
531
|
-
|
|
625
|
+
} else if (!initDryRun && !isClaudeCodeInstalled()) {
|
|
626
|
+
console.log('\n⚠️ Claude Code CLI not detected!');
|
|
627
|
+
console.log(' 📥 Install with: npm install -g @anthropic-ai/claude-code');
|
|
628
|
+
console.log(' 📋 Then add MCP servers manually with:');
|
|
629
|
+
console.log(' claude mcp add claude-flow-novice claude-flow-novice mcp start');
|
|
630
|
+
console.log(' claude mcp add ruv-swarm npx ruv-swarm mcp start');
|
|
631
|
+
// Flow-nexus integration removed
|
|
632
|
+
}
|
|
532
633
|
}
|
|
634
|
+
} catch (err) {
|
|
635
|
+
printError(`Failed to initialize files: ${err.message}`);
|
|
636
|
+
}
|
|
533
637
|
}
|
|
638
|
+
|
|
534
639
|
// Handle batch initialization
|
|
535
640
|
async function handleBatchInit(subArgs, flags) {
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
641
|
+
try {
|
|
642
|
+
// Options parsing from flags and subArgs
|
|
643
|
+
const options = {
|
|
644
|
+
parallel: !flags['no-parallel'] && flags.parallel !== false,
|
|
645
|
+
sparc: flags.sparc || flags.s,
|
|
646
|
+
minimal: flags.minimal || flags.m,
|
|
647
|
+
force: flags.force || flags.f,
|
|
648
|
+
maxConcurrency: flags['max-concurrent'] || 5,
|
|
649
|
+
progressTracking: true,
|
|
650
|
+
template: flags.template,
|
|
651
|
+
environments: flags.environments
|
|
652
|
+
? flags.environments.split(',').map((env) => env.trim())
|
|
653
|
+
: ['dev'],
|
|
654
|
+
};
|
|
655
|
+
|
|
656
|
+
// Validate options
|
|
657
|
+
const validationErrors = validateBatchOptions(options);
|
|
658
|
+
if (validationErrors.length > 0) {
|
|
659
|
+
printError('Batch options validation failed:');
|
|
660
|
+
validationErrors.forEach((error) => console.error(` - ${error}`));
|
|
661
|
+
return;
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
// Config file mode
|
|
665
|
+
if (flags.config) {
|
|
666
|
+
const configFile = flags.config;
|
|
667
|
+
printSuccess(`Loading batch configuration from: ${configFile}`);
|
|
668
|
+
const results = await batchInitFromConfig(configFile, options);
|
|
669
|
+
if (results) {
|
|
670
|
+
printSuccess('Batch initialization from config completed');
|
|
671
|
+
}
|
|
672
|
+
return;
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
// Batch init mode
|
|
676
|
+
if (flags['batch-init']) {
|
|
677
|
+
const projectsString = flags['batch-init'];
|
|
678
|
+
const projects = projectsString.split(',').map((project) => project.trim());
|
|
679
|
+
|
|
680
|
+
if (projects.length === 0) {
|
|
681
|
+
printError('No projects specified for batch initialization');
|
|
682
|
+
return;
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
printSuccess(`Initializing ${projects.length} projects in batch mode`);
|
|
686
|
+
const results = await batchInitCommand(projects, options);
|
|
687
|
+
|
|
688
|
+
if (results) {
|
|
689
|
+
const successful = results.filter((r) => r.success).length;
|
|
690
|
+
const failed = results.filter((r) => !r.success).length;
|
|
691
|
+
|
|
692
|
+
if (failed === 0) {
|
|
693
|
+
printSuccess(`All ${successful} projects initialized successfully`);
|
|
694
|
+
} else {
|
|
695
|
+
printWarning(`${successful} projects succeeded, ${failed} failed`);
|
|
587
696
|
}
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
printError(`Batch initialization failed: ${err.message}`);
|
|
697
|
+
}
|
|
698
|
+
return;
|
|
591
699
|
}
|
|
700
|
+
|
|
701
|
+
printError('No batch operation specified. Use --batch-init <projects> or --config <file>');
|
|
702
|
+
} catch (err) {
|
|
703
|
+
printError(`Batch initialization failed: ${err.message}`);
|
|
704
|
+
}
|
|
592
705
|
}
|
|
706
|
+
|
|
593
707
|
/**
|
|
594
708
|
* Enhanced initialization command with validation and rollback
|
|
595
|
-
*/
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
}
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
709
|
+
*/
|
|
710
|
+
async function enhancedInitCommand(subArgs, flags) {
|
|
711
|
+
console.log('🛡️ Starting enhanced initialization with validation and rollback...');
|
|
712
|
+
|
|
713
|
+
// Store parameters to avoid scope issues in async context
|
|
714
|
+
const args = subArgs || [];
|
|
715
|
+
const options = flags || {};
|
|
716
|
+
|
|
717
|
+
// Get the working directory
|
|
718
|
+
const workingDir = process.env.PWD || process.cwd();
|
|
719
|
+
|
|
720
|
+
// Initialize systems
|
|
721
|
+
const rollbackSystem = new RollbackSystem(workingDir);
|
|
722
|
+
const validationSystem = new ValidationSystem(workingDir);
|
|
723
|
+
|
|
724
|
+
let atomicOp = null;
|
|
725
|
+
|
|
726
|
+
try {
|
|
727
|
+
// Parse options
|
|
728
|
+
const initOptions = {
|
|
729
|
+
force: args.includes('--force') || args.includes('-f') || options.force,
|
|
730
|
+
minimal: args.includes('--minimal') || args.includes('-m') || options.minimal,
|
|
731
|
+
sparc: args.includes('--sparc') || args.includes('-s') || options.sparc,
|
|
732
|
+
skipPreValidation: args.includes('--skip-pre-validation'),
|
|
733
|
+
skipBackup: args.includes('--skip-backup'),
|
|
734
|
+
validateOnly: args.includes('--validate-only'),
|
|
735
|
+
};
|
|
736
|
+
|
|
737
|
+
// Phase 1: Pre-initialization validation
|
|
738
|
+
if (!initOptions.skipPreValidation) {
|
|
739
|
+
console.log('\n🔍 Phase 1: Pre-initialization validation...');
|
|
740
|
+
const preValidation = await validationSystem.validatePreInit(initOptions);
|
|
741
|
+
|
|
742
|
+
if (!preValidation.success) {
|
|
743
|
+
printError('Pre-initialization validation failed:');
|
|
744
|
+
preValidation.errors.forEach((error) => console.error(` ❌ ${error}`));
|
|
745
|
+
return;
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
if (preValidation.warnings.length > 0) {
|
|
749
|
+
printWarning('Pre-initialization warnings:');
|
|
750
|
+
preValidation.warnings.forEach((warning) => console.warn(` ⚠️ ${warning}`));
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
printSuccess('Pre-initialization validation passed');
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
// Stop here if validation-only mode
|
|
757
|
+
if (options.validateOnly) {
|
|
758
|
+
console.log('\n✅ Validation-only mode completed');
|
|
759
|
+
return;
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
// Phase 2: Create backup
|
|
763
|
+
if (!options.skipBackup) {
|
|
764
|
+
console.log('\n💾 Phase 2: Creating backup...');
|
|
765
|
+
const backupResult = await rollbackSystem.createPreInitBackup();
|
|
766
|
+
|
|
767
|
+
if (!backupResult.success) {
|
|
768
|
+
printError('Backup creation failed:');
|
|
769
|
+
backupResult.errors.forEach((error) => console.error(` ❌ ${error}`));
|
|
770
|
+
return;
|
|
771
|
+
}
|
|
772
|
+
}
|
|
773
|
+
|
|
774
|
+
// Phase 3: Initialize with atomic operations
|
|
775
|
+
console.log('\n🔧 Phase 3: Atomic initialization...');
|
|
776
|
+
atomicOp = createAtomicOperation(rollbackSystem, 'enhanced-init');
|
|
777
|
+
|
|
778
|
+
const atomicBegin = await atomicOp.begin();
|
|
779
|
+
if (!atomicBegin) {
|
|
780
|
+
printError('Failed to begin atomic operation');
|
|
781
|
+
return;
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
// Perform initialization steps with checkpoints
|
|
785
|
+
await performInitializationWithCheckpoints(rollbackSystem, options, workingDir, dryRun);
|
|
786
|
+
|
|
787
|
+
// Phase 4: Post-initialization validation
|
|
788
|
+
console.log('\n✅ Phase 4: Post-initialization validation...');
|
|
789
|
+
const postValidation = await validationSystem.validatePostInit();
|
|
790
|
+
|
|
791
|
+
if (!postValidation.success) {
|
|
792
|
+
printError('Post-initialization validation failed:');
|
|
793
|
+
postValidation.errors.forEach((error) => console.error(` ❌ ${error}`));
|
|
794
|
+
|
|
795
|
+
// Attempt automatic rollback
|
|
796
|
+
console.log('\n🔄 Attempting automatic rollback...');
|
|
797
|
+
await atomicOp.rollback();
|
|
798
|
+
printWarning('Initialization rolled back due to validation failure');
|
|
799
|
+
return;
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
// Phase 5: Configuration validation
|
|
803
|
+
console.log('\n🔧 Phase 5: Configuration validation...');
|
|
804
|
+
const configValidation = await validationSystem.validateConfiguration();
|
|
805
|
+
|
|
806
|
+
if (configValidation.warnings.length > 0) {
|
|
807
|
+
printWarning('Configuration warnings:');
|
|
808
|
+
configValidation.warnings.forEach((warning) => console.warn(` ⚠️ ${warning}`));
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
// Phase 6: Health checks
|
|
812
|
+
console.log('\n🏥 Phase 6: System health checks...');
|
|
813
|
+
const healthChecks = await validationSystem.runHealthChecks();
|
|
814
|
+
|
|
815
|
+
if (healthChecks.warnings.length > 0) {
|
|
816
|
+
printWarning('Health check warnings:');
|
|
817
|
+
healthChecks.warnings.forEach((warning) => console.warn(` ⚠️ ${warning}`));
|
|
818
|
+
}
|
|
819
|
+
|
|
820
|
+
// Commit atomic operation
|
|
821
|
+
await atomicOp.commit();
|
|
822
|
+
|
|
823
|
+
// Generate and display validation report
|
|
824
|
+
const fullValidation = await runFullValidation(workingDir, {
|
|
825
|
+
postInit: true,
|
|
826
|
+
skipPreInit: options.skipPreValidation,
|
|
827
|
+
});
|
|
828
|
+
|
|
829
|
+
console.log('\n📊 Validation Report:');
|
|
830
|
+
console.log(fullValidation.report);
|
|
831
|
+
|
|
832
|
+
printSuccess('🎉 Enhanced initialization completed successfully!');
|
|
833
|
+
console.log('\n✨ Your SPARC environment is fully validated and ready to use');
|
|
834
|
+
} catch (error) {
|
|
835
|
+
printError(`Enhanced initialization failed: ${error.message}`);
|
|
836
|
+
|
|
837
|
+
// Attempt rollback if atomic operation is active
|
|
838
|
+
if (atomicOp && !atomicOp.completed) {
|
|
839
|
+
console.log('\n🔄 Performing emergency rollback...');
|
|
840
|
+
try {
|
|
841
|
+
await atomicOp.rollback();
|
|
842
|
+
printWarning('Emergency rollback completed');
|
|
843
|
+
} catch (rollbackError) {
|
|
844
|
+
printError(`Rollback also failed: ${rollbackError.message}`);
|
|
845
|
+
}
|
|
705
846
|
}
|
|
847
|
+
}
|
|
706
848
|
}
|
|
849
|
+
|
|
707
850
|
/**
|
|
708
851
|
* Handle validation commands
|
|
709
|
-
*/
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
852
|
+
*/
|
|
853
|
+
async function handleValidationCommand(subArgs, flags) {
|
|
854
|
+
const workingDir = process.env.PWD || process.cwd();
|
|
855
|
+
|
|
856
|
+
console.log('🔍 Running validation checks...');
|
|
857
|
+
|
|
858
|
+
const options = {
|
|
859
|
+
skipPreInit: subArgs.includes('--skip-pre-init'),
|
|
860
|
+
skipConfig: subArgs.includes('--skip-config'),
|
|
861
|
+
skipModeTest: subArgs.includes('--skip-mode-test'),
|
|
862
|
+
postInit: !subArgs.includes('--pre-init-only'),
|
|
863
|
+
};
|
|
864
|
+
|
|
865
|
+
try {
|
|
866
|
+
const validationResults = await runFullValidation(workingDir, options);
|
|
867
|
+
|
|
868
|
+
console.log('\n📊 Validation Results:');
|
|
869
|
+
console.log(validationResults.report);
|
|
870
|
+
|
|
871
|
+
if (validationResults.success) {
|
|
872
|
+
printSuccess('✅ All validation checks passed');
|
|
873
|
+
} else {
|
|
874
|
+
printError('❌ Some validation checks failed');
|
|
875
|
+
process.exit(1);
|
|
731
876
|
}
|
|
877
|
+
} catch (error) {
|
|
878
|
+
printError(`Validation failed: ${error.message}`);
|
|
879
|
+
process.exit(1);
|
|
880
|
+
}
|
|
732
881
|
}
|
|
882
|
+
|
|
733
883
|
/**
|
|
734
884
|
* Handle rollback commands
|
|
735
|
-
*/
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
printError('Partial rollback requires --phase <phase-name>');
|
|
763
|
-
}
|
|
885
|
+
*/
|
|
886
|
+
async function handleRollbackCommand(subArgs, flags) {
|
|
887
|
+
const workingDir = process.env.PWD || process.cwd();
|
|
888
|
+
const rollbackSystem = new RollbackSystem(workingDir);
|
|
889
|
+
|
|
890
|
+
try {
|
|
891
|
+
// Check for specific rollback options
|
|
892
|
+
if (subArgs.includes('--full')) {
|
|
893
|
+
console.log('🔄 Performing full rollback...');
|
|
894
|
+
const result = await rollbackSystem.performFullRollback();
|
|
895
|
+
|
|
896
|
+
if (result.success) {
|
|
897
|
+
printSuccess('Full rollback completed successfully');
|
|
898
|
+
} else {
|
|
899
|
+
printError('Full rollback failed:');
|
|
900
|
+
result.errors.forEach((error) => console.error(` ❌ ${error}`));
|
|
901
|
+
}
|
|
902
|
+
} else if (subArgs.includes('--partial')) {
|
|
903
|
+
const phaseIndex = subArgs.findIndex((arg) => arg === '--phase');
|
|
904
|
+
if (phaseIndex !== -1 && subArgs[phaseIndex + 1]) {
|
|
905
|
+
const phase = subArgs[phaseIndex + 1];
|
|
906
|
+
console.log(`🔄 Performing partial rollback for phase: ${phase}`);
|
|
907
|
+
|
|
908
|
+
const result = await rollbackSystem.performPartialRollback(phase);
|
|
909
|
+
|
|
910
|
+
if (result.success) {
|
|
911
|
+
printSuccess(`Partial rollback completed for phase: ${phase}`);
|
|
764
912
|
} else {
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
if (rollbackPoints.rollbackPoints.length === 0) {
|
|
768
|
-
printWarning('No rollback points available');
|
|
769
|
-
return;
|
|
770
|
-
}
|
|
771
|
-
console.log('\n📋 Available rollback points:');
|
|
772
|
-
rollbackPoints.rollbackPoints.forEach((point, index)=>{
|
|
773
|
-
const date = new Date(point.timestamp).toLocaleString();
|
|
774
|
-
console.log(` ${index + 1}. ${point.type} - ${date}`);
|
|
775
|
-
});
|
|
776
|
-
// For now, rollback to the most recent point
|
|
777
|
-
const latest = rollbackPoints.rollbackPoints[0];
|
|
778
|
-
if (latest) {
|
|
779
|
-
console.log(`\n🔄 Rolling back to: ${latest.type} (${new Date(latest.timestamp).toLocaleString()})`);
|
|
780
|
-
const result = await rollbackSystem.performFullRollback(latest.backupId);
|
|
781
|
-
if (result.success) {
|
|
782
|
-
printSuccess('Rollback completed successfully');
|
|
783
|
-
} else {
|
|
784
|
-
printError('Rollback failed');
|
|
785
|
-
}
|
|
786
|
-
}
|
|
913
|
+
printError(`Partial rollback failed for phase: ${phase}`);
|
|
914
|
+
result.errors.forEach((error) => console.error(` ❌ ${error}`));
|
|
787
915
|
}
|
|
788
|
-
|
|
789
|
-
printError(
|
|
916
|
+
} else {
|
|
917
|
+
printError('Partial rollback requires --phase <phase-name>');
|
|
918
|
+
}
|
|
919
|
+
} else {
|
|
920
|
+
// Interactive rollback point selection
|
|
921
|
+
const rollbackPoints = await rollbackSystem.listRollbackPoints();
|
|
922
|
+
|
|
923
|
+
if (rollbackPoints.rollbackPoints.length === 0) {
|
|
924
|
+
printWarning('No rollback points available');
|
|
925
|
+
return;
|
|
926
|
+
}
|
|
927
|
+
|
|
928
|
+
console.log('\n📋 Available rollback points:');
|
|
929
|
+
rollbackPoints.rollbackPoints.forEach((point, index) => {
|
|
930
|
+
const date = new Date(point.timestamp).toLocaleString();
|
|
931
|
+
console.log(` ${index + 1}. ${point.type} - ${date}`);
|
|
932
|
+
});
|
|
933
|
+
|
|
934
|
+
// For now, rollback to the most recent point
|
|
935
|
+
const latest = rollbackPoints.rollbackPoints[0];
|
|
936
|
+
if (latest) {
|
|
937
|
+
console.log(
|
|
938
|
+
`\n🔄 Rolling back to: ${latest.type} (${new Date(latest.timestamp).toLocaleString()})`,
|
|
939
|
+
);
|
|
940
|
+
const result = await rollbackSystem.performFullRollback(latest.backupId);
|
|
941
|
+
|
|
942
|
+
if (result.success) {
|
|
943
|
+
printSuccess('Rollback completed successfully');
|
|
944
|
+
} else {
|
|
945
|
+
printError('Rollback failed');
|
|
946
|
+
}
|
|
947
|
+
}
|
|
790
948
|
}
|
|
949
|
+
} catch (error) {
|
|
950
|
+
printError(`Rollback operation failed: ${error.message}`);
|
|
951
|
+
}
|
|
791
952
|
}
|
|
953
|
+
|
|
792
954
|
/**
|
|
793
955
|
* Handle list backups command
|
|
794
|
-
*/
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
956
|
+
*/
|
|
957
|
+
async function handleListBackups(subArgs, flags) {
|
|
958
|
+
const workingDir = process.env.PWD || process.cwd();
|
|
959
|
+
const rollbackSystem = new RollbackSystem(workingDir);
|
|
960
|
+
|
|
961
|
+
try {
|
|
962
|
+
const rollbackPoints = await rollbackSystem.listRollbackPoints();
|
|
963
|
+
|
|
964
|
+
console.log('\n📋 Rollback Points and Backups:');
|
|
965
|
+
|
|
966
|
+
if (rollbackPoints.rollbackPoints.length === 0) {
|
|
967
|
+
console.log(' No rollback points available');
|
|
968
|
+
} else {
|
|
969
|
+
console.log('\n🔄 Rollback Points:');
|
|
970
|
+
rollbackPoints.rollbackPoints.forEach((point, index) => {
|
|
971
|
+
const date = new Date(point.timestamp).toLocaleString();
|
|
972
|
+
console.log(` ${index + 1}. ${point.type} - ${date} (${point.backupId || 'No backup'})`);
|
|
973
|
+
});
|
|
974
|
+
}
|
|
975
|
+
|
|
976
|
+
if (rollbackPoints.checkpoints.length > 0) {
|
|
977
|
+
console.log('\n📍 Checkpoints:');
|
|
978
|
+
rollbackPoints.checkpoints.slice(-5).forEach((checkpoint, index) => {
|
|
979
|
+
const date = new Date(checkpoint.timestamp).toLocaleString();
|
|
980
|
+
console.log(` ${index + 1}. ${checkpoint.phase} - ${date} (${checkpoint.status})`);
|
|
981
|
+
});
|
|
818
982
|
}
|
|
983
|
+
} catch (error) {
|
|
984
|
+
printError(`Failed to list backups: ${error.message}`);
|
|
985
|
+
}
|
|
819
986
|
}
|
|
987
|
+
|
|
820
988
|
/**
|
|
821
989
|
* Perform initialization with checkpoints
|
|
822
|
-
*/
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
name: 'claude-commands',
|
|
863
|
-
action: ()=>createClaudeSlashCommands(workingDir)
|
|
864
|
-
});
|
|
865
|
-
}
|
|
866
|
-
for (const phase of phases){
|
|
867
|
-
console.log(` 🔧 ${phase.name}...`);
|
|
868
|
-
// Create checkpoint before phase
|
|
869
|
-
await rollbackSystem.createCheckpoint(phase.name, {
|
|
870
|
-
timestamp: Date.now(),
|
|
871
|
-
phase: phase.name
|
|
872
|
-
});
|
|
873
|
-
try {
|
|
874
|
-
await phase.action();
|
|
875
|
-
console.log(` ✅ ${phase.name} completed`);
|
|
876
|
-
} catch (error) {
|
|
877
|
-
console.error(` ❌ ${phase.name} failed: ${error.message}`);
|
|
878
|
-
throw error;
|
|
879
|
-
}
|
|
990
|
+
*/
|
|
991
|
+
async function performInitializationWithCheckpoints(
|
|
992
|
+
rollbackSystem,
|
|
993
|
+
options,
|
|
994
|
+
workingDir,
|
|
995
|
+
dryRun = false,
|
|
996
|
+
) {
|
|
997
|
+
const phases = [
|
|
998
|
+
{ name: 'file-creation', action: () => createInitialFiles(options, workingDir, dryRun) },
|
|
999
|
+
{ name: 'directory-structure', action: () => createDirectoryStructure(workingDir, dryRun) },
|
|
1000
|
+
{ name: 'memory-setup', action: () => setupMemorySystem(workingDir, dryRun) },
|
|
1001
|
+
{ name: 'agent-system', action: () => setupAgentSystem(workingDir, dryRun, options) },
|
|
1002
|
+
{ name: 'mcp-config', action: () => setupMcpConfiguration(workingDir, dryRun) },
|
|
1003
|
+
{ name: 'hooks-system', action: () => setupHooksSystem(workingDir, dryRun) },
|
|
1004
|
+
{ name: 'coordination-setup', action: () => setupCoordinationSystem(workingDir, dryRun) },
|
|
1005
|
+
{ name: 'executable-creation', action: () => createLocalExecutable(workingDir, dryRun) },
|
|
1006
|
+
];
|
|
1007
|
+
|
|
1008
|
+
if (options.sparc) {
|
|
1009
|
+
phases.push(
|
|
1010
|
+
{ name: 'sparc-init', action: () => createSparcStructureManually() },
|
|
1011
|
+
{ name: 'claude-commands', action: () => createClaudeSlashCommands(workingDir) },
|
|
1012
|
+
);
|
|
1013
|
+
}
|
|
1014
|
+
|
|
1015
|
+
for (const phase of phases) {
|
|
1016
|
+
console.log(` 🔧 ${phase.name}...`);
|
|
1017
|
+
|
|
1018
|
+
// Create checkpoint before phase
|
|
1019
|
+
await rollbackSystem.createCheckpoint(phase.name, {
|
|
1020
|
+
timestamp: Date.now(),
|
|
1021
|
+
phase: phase.name,
|
|
1022
|
+
});
|
|
1023
|
+
|
|
1024
|
+
try {
|
|
1025
|
+
await phase.action();
|
|
1026
|
+
console.log(` ✅ ${phase.name} completed`);
|
|
1027
|
+
} catch (error) {
|
|
1028
|
+
console.error(` ❌ ${phase.name} failed: ${error.message}`);
|
|
1029
|
+
throw error;
|
|
880
1030
|
}
|
|
1031
|
+
}
|
|
881
1032
|
}
|
|
1033
|
+
|
|
882
1034
|
// Helper functions for atomic initialization
|
|
883
|
-
async function createInitialFiles(options, workingDir,
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
1035
|
+
async function createInitialFiles(options, workingDir, dryRun = false) {
|
|
1036
|
+
if (!dryRun) {
|
|
1037
|
+
// Use template file instead of generation
|
|
1038
|
+
const claudeMd = await readClaudeMdTemplate();
|
|
1039
|
+
await fs.writeFile(`${workingDir}/CLAUDE.md`, claudeMd, 'utf8');
|
|
1040
|
+
|
|
1041
|
+
const memoryBankMd = options.minimal ? createMinimalMemoryBankMd() : createFullMemoryBankMd();
|
|
1042
|
+
await fs.writeFile(`${workingDir}/memory-bank.md`, memoryBankMd, 'utf8');
|
|
1043
|
+
|
|
1044
|
+
const coordinationMd = options.minimal
|
|
1045
|
+
? createMinimalCoordinationMd()
|
|
1046
|
+
: createFullCoordinationMd();
|
|
1047
|
+
await fs.writeFile(`${workingDir}/coordination.md`, coordinationMd, 'utf8');
|
|
1048
|
+
}
|
|
893
1049
|
}
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
}
|
|
1050
|
+
|
|
1051
|
+
async function createDirectoryStructure(workingDir, dryRun = false) {
|
|
1052
|
+
const directories = [
|
|
1053
|
+
'memory',
|
|
1054
|
+
'memory/agents',
|
|
1055
|
+
'memory/sessions',
|
|
1056
|
+
'coordination',
|
|
1057
|
+
'coordination/memory_bank',
|
|
1058
|
+
'coordination/subtasks',
|
|
1059
|
+
'coordination/orchestration',
|
|
1060
|
+
'.claude',
|
|
1061
|
+
'.claude/commands',
|
|
1062
|
+
'.claude/logs',
|
|
1063
|
+
];
|
|
1064
|
+
|
|
1065
|
+
if (!dryRun) {
|
|
1066
|
+
for (const dir of directories) {
|
|
1067
|
+
await fs.mkdir(`${workingDir}/${dir}`, { recursive: true });
|
|
913
1068
|
}
|
|
1069
|
+
}
|
|
914
1070
|
}
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
}
|
|
1071
|
+
|
|
1072
|
+
async function setupMemorySystem(workingDir, dryRun = false) {
|
|
1073
|
+
if (!dryRun) {
|
|
1074
|
+
const initialData = { agents: [], tasks: [], lastUpdated: Date.now() };
|
|
1075
|
+
await fs.writeFile(
|
|
1076
|
+
`${workingDir}/memory/claude-flow-data.json`,
|
|
1077
|
+
JSON.stringify(initialData, null, 2),
|
|
1078
|
+
'utf8',
|
|
1079
|
+
);
|
|
1080
|
+
|
|
1081
|
+
await fs.writeFile(`${workingDir}/memory/agents/README.md`, createAgentsReadme(), 'utf8');
|
|
1082
|
+
await fs.writeFile(`${workingDir}/memory/sessions/README.md`, createSessionsReadme(), 'utf8');
|
|
1083
|
+
}
|
|
926
1084
|
}
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
1085
|
+
|
|
1086
|
+
async function setupAgentSystem(workingDir, dryRun = false, options = {}) {
|
|
1087
|
+
if (!dryRun) {
|
|
1088
|
+
console.log('🤖 Setting up agent system...');
|
|
1089
|
+
|
|
1090
|
+
// Create agent directories
|
|
1091
|
+
await createAgentDirectories(workingDir, dryRun);
|
|
1092
|
+
|
|
1093
|
+
// Copy all agent files (80+ agents)
|
|
1094
|
+
const agentResult = await copyAgentFiles(workingDir, {
|
|
1095
|
+
force: options.force || false,
|
|
1096
|
+
dryRun: dryRun,
|
|
1097
|
+
});
|
|
1098
|
+
|
|
1099
|
+
if (agentResult.success) {
|
|
1100
|
+
await validateAgentSystem(workingDir);
|
|
1101
|
+
|
|
1102
|
+
// Copy command files
|
|
1103
|
+
const commandResult = await copyCommandFiles(workingDir, {
|
|
1104
|
+
force: options.force || false,
|
|
1105
|
+
dryRun: dryRun,
|
|
1106
|
+
});
|
|
1107
|
+
|
|
1108
|
+
if (commandResult.success) {
|
|
1109
|
+
console.log(' ✅ Agent system setup complete with 80+ specialized agents');
|
|
1110
|
+
} else {
|
|
1111
|
+
console.log(' ⚠️ Command system setup failed:', commandResult.error);
|
|
1112
|
+
}
|
|
1113
|
+
} else {
|
|
1114
|
+
console.log(' ⚠️ Agent system setup failed:', agentResult.error);
|
|
952
1115
|
}
|
|
1116
|
+
}
|
|
953
1117
|
}
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
1118
|
+
|
|
1119
|
+
async function setupMcpConfiguration(workingDir, dryRun = false) {
|
|
1120
|
+
if (!dryRun) {
|
|
1121
|
+
console.log('🔌 Setting up MCP configuration...');
|
|
1122
|
+
|
|
1123
|
+
const mcpConfig = {
|
|
1124
|
+
"mcpServers": {
|
|
1125
|
+
"claude-flow-novice": {
|
|
1126
|
+
"command": "npx",
|
|
1127
|
+
"args": ["claude-flow-novice", "mcp", "start"],
|
|
1128
|
+
"env": {
|
|
1129
|
+
"CLAUDE_FLOW_NOVICE_MODE": "novice",
|
|
1130
|
+
"CLAUDE_FLOW_NOVICE_SIMPLIFIED": "true"
|
|
1131
|
+
}
|
|
1132
|
+
}
|
|
1133
|
+
}
|
|
1134
|
+
};
|
|
1135
|
+
|
|
1136
|
+
await fs.writeFile(
|
|
1137
|
+
`${workingDir}/.mcp.json`,
|
|
1138
|
+
JSON.stringify(mcpConfig, null, 2),
|
|
1139
|
+
'utf8'
|
|
1140
|
+
);
|
|
1141
|
+
console.log(' ✅ Created .mcp.json configuration');
|
|
1142
|
+
}
|
|
976
1143
|
}
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1144
|
+
|
|
1145
|
+
async function setupHooksSystem(workingDir, dryRun = false) {
|
|
1146
|
+
if (!dryRun) {
|
|
1147
|
+
console.log('🪝 Setting up hooks system...');
|
|
1148
|
+
|
|
1149
|
+
// Create .claude/settings.json with hooks configuration
|
|
1150
|
+
const settingsConfig = {
|
|
1151
|
+
"hooks": {
|
|
1152
|
+
"pre-tool": {
|
|
1153
|
+
"command": "npx claude-flow-novice hooks pre-task --description \"{{description}}\"",
|
|
1154
|
+
"enabled": true
|
|
1155
|
+
},
|
|
1156
|
+
"post-tool": {
|
|
1157
|
+
"command": "npx claude-flow-novice hooks post-task --task-id \"{{taskId}}\"",
|
|
1158
|
+
"enabled": true
|
|
1159
|
+
},
|
|
1160
|
+
"pre-edit": {
|
|
1161
|
+
"command": "npx claude-flow-novice hooks pre-edit --file \"{{file}}\"",
|
|
1162
|
+
"enabled": true
|
|
1163
|
+
},
|
|
1164
|
+
"post-edit": {
|
|
1165
|
+
"command": "npx claude-flow-novice hooks post-edit --file \"{{file}}\" --memory-key \"swarm/{{agent}}/{{step}}\"",
|
|
1166
|
+
"enabled": true
|
|
1167
|
+
}
|
|
1168
|
+
},
|
|
1169
|
+
"coordination": {
|
|
1170
|
+
"autoSpawn": true,
|
|
1171
|
+
"memoryPersistence": true,
|
|
1172
|
+
"swarmOrchestration": true
|
|
1173
|
+
}
|
|
1174
|
+
};
|
|
1175
|
+
|
|
1176
|
+
await fs.writeFile(
|
|
1177
|
+
`${workingDir}/.claude/settings.json`,
|
|
1178
|
+
JSON.stringify(settingsConfig, null, 2),
|
|
1179
|
+
'utf8'
|
|
1180
|
+
);
|
|
1181
|
+
console.log(' ✅ Created hooks configuration');
|
|
1182
|
+
}
|
|
1009
1183
|
}
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
//
|
|
1184
|
+
|
|
1185
|
+
async function setupCoordinationSystem(workingDir, dryRun = false) {
|
|
1186
|
+
// Coordination system is already set up by createDirectoryStructure
|
|
1187
|
+
// This is a placeholder for future coordination setup logic
|
|
1013
1188
|
}
|
|
1189
|
+
|
|
1014
1190
|
/**
|
|
1015
1191
|
* Setup monitoring and telemetry for token tracking
|
|
1016
|
-
*/
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1192
|
+
*/
|
|
1193
|
+
async function setupMonitoring(workingDir) {
|
|
1194
|
+
console.log(' 📈 Configuring token usage tracking...');
|
|
1195
|
+
|
|
1196
|
+
const fs = await import('fs/promises');
|
|
1197
|
+
const path = await import('path');
|
|
1198
|
+
|
|
1199
|
+
try {
|
|
1200
|
+
// Create .claude-flow-novice directory for tracking data
|
|
1201
|
+
const trackingDir = path.join(workingDir, '.claude-flow');
|
|
1202
|
+
await fs.mkdir(trackingDir, { recursive: true });
|
|
1203
|
+
|
|
1204
|
+
// Create initial token usage file
|
|
1205
|
+
const tokenUsageFile = path.join(trackingDir, 'token-usage.json');
|
|
1206
|
+
const initialData = {
|
|
1207
|
+
total: 0,
|
|
1208
|
+
input: 0,
|
|
1209
|
+
output: 0,
|
|
1210
|
+
byAgent: {},
|
|
1211
|
+
lastUpdated: new Date().toISOString(),
|
|
1212
|
+
};
|
|
1213
|
+
|
|
1214
|
+
await fs.writeFile(tokenUsageFile, JSON.stringify(initialData, null, 2));
|
|
1215
|
+
printSuccess(' ✓ Created token usage tracking file');
|
|
1216
|
+
|
|
1217
|
+
// Add telemetry configuration to .claude/settings.json if it exists
|
|
1218
|
+
const settingsPath = path.join(workingDir, '.claude', 'settings.json');
|
|
1020
1219
|
try {
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
},
|
|
1071
|
-
storage: {
|
|
1072
|
-
location: '.claude-flow/token-usage.json',
|
|
1073
|
-
format: 'json',
|
|
1074
|
-
rotation: 'monthly'
|
|
1075
|
-
}
|
|
1076
|
-
};
|
|
1077
|
-
const configPath = path.join(trackingDir, 'monitoring.config.json');
|
|
1078
|
-
await fs.writeFile(configPath, JSON.stringify(monitoringConfig, null, 2));
|
|
1079
|
-
printSuccess(' ✓ Created monitoring configuration');
|
|
1080
|
-
// Create shell profile snippet for environment variable
|
|
1081
|
-
const envSnippet = `
|
|
1220
|
+
const settingsContent = await fs.readFile(settingsPath, 'utf8');
|
|
1221
|
+
const settings = JSON.parse(settingsContent);
|
|
1222
|
+
|
|
1223
|
+
// Add telemetry hook
|
|
1224
|
+
if (!settings.hooks) settings.hooks = {};
|
|
1225
|
+
if (!settings.hooks['post-task']) settings.hooks['post-task'] = [];
|
|
1226
|
+
|
|
1227
|
+
// Add token tracking hook
|
|
1228
|
+
const tokenTrackingHook =
|
|
1229
|
+
'npx claude-flow-novice internal track-tokens --session-id {{session_id}} --tokens {{token_usage}}';
|
|
1230
|
+
if (!settings.hooks['post-task'].includes(tokenTrackingHook)) {
|
|
1231
|
+
settings.hooks['post-task'].push(tokenTrackingHook);
|
|
1232
|
+
}
|
|
1233
|
+
|
|
1234
|
+
await fs.writeFile(settingsPath, JSON.stringify(settings, null, 2));
|
|
1235
|
+
printSuccess(' ✓ Added token tracking hooks to settings');
|
|
1236
|
+
} catch (err) {
|
|
1237
|
+
console.log(' ⚠️ Could not update settings.json:', err.message);
|
|
1238
|
+
}
|
|
1239
|
+
|
|
1240
|
+
// Create monitoring configuration
|
|
1241
|
+
const monitoringConfig = {
|
|
1242
|
+
enabled: true,
|
|
1243
|
+
telemetry: {
|
|
1244
|
+
claudeCode: {
|
|
1245
|
+
env: 'CLAUDE_CODE_ENABLE_TELEMETRY',
|
|
1246
|
+
value: '1',
|
|
1247
|
+
description: 'Enable Claude Code OpenTelemetry metrics',
|
|
1248
|
+
},
|
|
1249
|
+
},
|
|
1250
|
+
tracking: {
|
|
1251
|
+
tokens: true,
|
|
1252
|
+
costs: true,
|
|
1253
|
+
agents: true,
|
|
1254
|
+
sessions: true,
|
|
1255
|
+
},
|
|
1256
|
+
storage: {
|
|
1257
|
+
location: '.claude-flow/token-usage.json',
|
|
1258
|
+
format: 'json',
|
|
1259
|
+
rotation: 'monthly',
|
|
1260
|
+
},
|
|
1261
|
+
};
|
|
1262
|
+
|
|
1263
|
+
const configPath = path.join(trackingDir, 'monitoring.config.json');
|
|
1264
|
+
await fs.writeFile(configPath, JSON.stringify(monitoringConfig, null, 2));
|
|
1265
|
+
printSuccess(' ✓ Created monitoring configuration');
|
|
1266
|
+
|
|
1267
|
+
// Create shell profile snippet for environment variable
|
|
1268
|
+
const envSnippet = `
|
|
1082
1269
|
# Claude Flow Token Tracking
|
|
1083
1270
|
# Add this to your shell profile (.bashrc, .zshrc, etc.)
|
|
1084
1271
|
export CLAUDE_CODE_ENABLE_TELEMETRY=1
|
|
@@ -1086,544 +1273,606 @@ export CLAUDE_CODE_ENABLE_TELEMETRY=1
|
|
|
1086
1273
|
# Optional: Set custom metrics path
|
|
1087
1274
|
# export CLAUDE_METRICS_PATH="$HOME/.claude/metrics"
|
|
1088
1275
|
`;
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1276
|
+
|
|
1277
|
+
const envPath = path.join(trackingDir, 'env-setup.sh');
|
|
1278
|
+
await fs.writeFile(envPath, envSnippet.trim());
|
|
1279
|
+
printSuccess(' ✓ Created environment setup script');
|
|
1280
|
+
|
|
1281
|
+
console.log('\n 📋 To enable Claude Code telemetry:');
|
|
1282
|
+
console.log(' 1. Add to your shell profile: export CLAUDE_CODE_ENABLE_TELEMETRY=1');
|
|
1283
|
+
console.log(' 2. Or run: source .claude-flow/env-setup.sh');
|
|
1284
|
+
console.log('\n 💡 Token usage will be tracked in .claude-flow/token-usage.json');
|
|
1285
|
+
console.log(' Run: claude-flow-novice analysis token-usage --breakdown --cost-analysis');
|
|
1286
|
+
} catch (err) {
|
|
1287
|
+
printError(` Failed to setup monitoring: ${err.message}`);
|
|
1288
|
+
}
|
|
1100
1289
|
}
|
|
1290
|
+
|
|
1101
1291
|
/**
|
|
1102
1292
|
* Enhanced Claude Flow v2.0.0 initialization
|
|
1103
|
-
*/
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1293
|
+
*/
|
|
1294
|
+
async function enhancedClaudeFlowInit(flags, subArgs = []) {
|
|
1295
|
+
console.log('🚀 Initializing Claude Flow v2.0.0 with enhanced features...');
|
|
1296
|
+
|
|
1297
|
+
const workingDir = process.cwd();
|
|
1298
|
+
const force = flags.force || flags.f;
|
|
1299
|
+
const dryRun = flags.dryRun || flags['dry-run'] || flags.d;
|
|
1300
|
+
const initSparc = flags.roo || (subArgs && subArgs.includes('--roo')); // SPARC only with --roo flag
|
|
1301
|
+
|
|
1302
|
+
// Store parameters to avoid scope issues in async context
|
|
1303
|
+
const args = subArgs || [];
|
|
1304
|
+
const options = flags || {};
|
|
1305
|
+
|
|
1306
|
+
// Import fs module for Node.js
|
|
1307
|
+
const fs = await import('fs/promises');
|
|
1308
|
+
const { chmod } = fs;
|
|
1309
|
+
|
|
1310
|
+
try {
|
|
1311
|
+
// Check existing files
|
|
1312
|
+
const existingFiles = [];
|
|
1313
|
+
const filesToCheck = [
|
|
1314
|
+
'CLAUDE.md',
|
|
1315
|
+
'.claude/settings.json',
|
|
1316
|
+
'.mcp.json',
|
|
1317
|
+
'claude-flow.config.json',
|
|
1318
|
+
];
|
|
1319
|
+
|
|
1320
|
+
for (const file of filesToCheck) {
|
|
1321
|
+
if (existsSync(`${workingDir}/${file}`)) {
|
|
1322
|
+
existingFiles.push(file);
|
|
1323
|
+
}
|
|
1324
|
+
}
|
|
1325
|
+
|
|
1326
|
+
if (existingFiles.length > 0 && !force) {
|
|
1327
|
+
printWarning(`The following files already exist: ${existingFiles.join(', ')}`);
|
|
1328
|
+
console.log('Use --force to overwrite existing files');
|
|
1329
|
+
return;
|
|
1330
|
+
}
|
|
1331
|
+
|
|
1332
|
+
// Create CLAUDE.md from template
|
|
1333
|
+
if (!dryRun) {
|
|
1334
|
+
const claudeMdContent = await readClaudeMdTemplate();
|
|
1335
|
+
await fs.writeFile(`${workingDir}/CLAUDE.md`, claudeMdContent, 'utf8');
|
|
1336
|
+
printSuccess('✓ Created CLAUDE.md (Claude Flow v2.0.0 - Optimized Template)');
|
|
1337
|
+
} else {
|
|
1338
|
+
console.log('[DRY RUN] Would create CLAUDE.md (Claude Flow v2.0.0 - Optimized Template)');
|
|
1339
|
+
}
|
|
1340
|
+
|
|
1341
|
+
// Create .claude directory structure
|
|
1342
|
+
const claudeDir = `${workingDir}/.claude`;
|
|
1343
|
+
if (!dryRun) {
|
|
1344
|
+
await fs.mkdir(claudeDir, { recursive: true });
|
|
1345
|
+
await fs.mkdir(`${claudeDir}/commands`, { recursive: true });
|
|
1346
|
+
await fs.mkdir(`${claudeDir}/helpers`, { recursive: true });
|
|
1347
|
+
printSuccess('✓ Created .claude directory structure');
|
|
1348
|
+
} else {
|
|
1349
|
+
console.log('[DRY RUN] Would create .claude directory structure');
|
|
1350
|
+
}
|
|
1351
|
+
|
|
1352
|
+
// Create settings.json
|
|
1353
|
+
if (!dryRun) {
|
|
1354
|
+
await fs.writeFile(`${claudeDir}/settings.json`, createEnhancedSettingsJson(), 'utf8');
|
|
1355
|
+
printSuccess('✓ Created .claude/settings.json with hooks and MCP configuration');
|
|
1356
|
+
} else {
|
|
1357
|
+
console.log('[DRY RUN] Would create .claude/settings.json');
|
|
1358
|
+
}
|
|
1359
|
+
|
|
1360
|
+
// Create settings.local.json with default MCP permissions
|
|
1361
|
+
const settingsLocal = {
|
|
1362
|
+
permissions: {
|
|
1363
|
+
allow: ['mcp__ruv-swarm', 'mcp__claude-flow'],
|
|
1364
|
+
deny: [],
|
|
1365
|
+
},
|
|
1366
|
+
};
|
|
1367
|
+
|
|
1368
|
+
if (!dryRun) {
|
|
1369
|
+
await fs.writeFile(
|
|
1370
|
+
`${claudeDir}/settings.local.json`,
|
|
1371
|
+
JSON.stringify(settingsLocal, null, 2, 'utf8'),
|
|
1372
|
+
);
|
|
1373
|
+
printSuccess('✓ Created .claude/settings.local.json with default MCP permissions');
|
|
1374
|
+
} else {
|
|
1375
|
+
console.log(
|
|
1376
|
+
'[DRY RUN] Would create .claude/settings.local.json with default MCP permissions',
|
|
1377
|
+
);
|
|
1378
|
+
}
|
|
1379
|
+
|
|
1380
|
+
// Setup bulletproof MCP configuration instead of legacy approach
|
|
1381
|
+
console.log('\n🛡️ Setting up bulletproof MCP configuration...');
|
|
1382
|
+
|
|
1383
|
+
const mcpOptions = {
|
|
1384
|
+
verbose: flags.verbose || false,
|
|
1385
|
+
autoFix: flags['auto-fix'] !== false && !flags['no-auto-fix'], // Default true unless explicitly disabled
|
|
1386
|
+
dryRun: dryRun,
|
|
1387
|
+
enhancedUx: true, // Enable enhanced user experience
|
|
1388
|
+
showEducation: flags['show-education'] || false,
|
|
1389
|
+
serverConfig: {
|
|
1390
|
+
mcpServers: {
|
|
1391
|
+
'claude-flow-novice': {
|
|
1392
|
+
command: 'npx',
|
|
1393
|
+
args: ['claude-flow-novice', 'mcp', 'start'],
|
|
1394
|
+
env: {
|
|
1395
|
+
NODE_ENV: 'production',
|
|
1396
|
+
CLAUDE_FLOW_NOVICE_MODE: 'novice'
|
|
1127
1397
|
}
|
|
1398
|
+
}
|
|
1128
1399
|
}
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
// Create .claude directory structure
|
|
1143
|
-
const claudeDir = `${workingDir}/.claude`;
|
|
1144
|
-
if (!dryRun1) {
|
|
1145
|
-
await fs.mkdir(claudeDir, {
|
|
1146
|
-
recursive: true
|
|
1147
|
-
});
|
|
1148
|
-
await fs.mkdir(`${claudeDir}/commands`, {
|
|
1149
|
-
recursive: true
|
|
1150
|
-
});
|
|
1151
|
-
await fs.mkdir(`${claudeDir}/helpers`, {
|
|
1152
|
-
recursive: true
|
|
1153
|
-
});
|
|
1154
|
-
printSuccess('✓ Created .claude directory structure');
|
|
1155
|
-
} else {
|
|
1156
|
-
console.log('[DRY RUN] Would create .claude directory structure');
|
|
1157
|
-
}
|
|
1158
|
-
// Create settings.json
|
|
1159
|
-
if (!dryRun1) {
|
|
1160
|
-
await fs.writeFile(`${claudeDir}/settings.json`, createEnhancedSettingsJson(), 'utf8');
|
|
1161
|
-
printSuccess('✓ Created .claude/settings.json with hooks and MCP configuration');
|
|
1162
|
-
} else {
|
|
1163
|
-
console.log('[DRY RUN] Would create .claude/settings.json');
|
|
1164
|
-
}
|
|
1165
|
-
// Create settings.local.json with default MCP permissions
|
|
1166
|
-
const settingsLocal = {
|
|
1167
|
-
permissions: {
|
|
1168
|
-
allow: [
|
|
1169
|
-
'mcp__ruv-swarm',
|
|
1170
|
-
'mcp__claude-flow'
|
|
1171
|
-
],
|
|
1172
|
-
deny: []
|
|
1173
|
-
}
|
|
1174
|
-
};
|
|
1175
|
-
if (!dryRun1) {
|
|
1176
|
-
await fs.writeFile(`${claudeDir}/settings.local.json`, JSON.stringify(settingsLocal, null, 2, 'utf8'));
|
|
1177
|
-
printSuccess('✓ Created .claude/settings.local.json with default MCP permissions');
|
|
1178
|
-
} else {
|
|
1179
|
-
console.log('[DRY RUN] Would create .claude/settings.local.json with default MCP permissions');
|
|
1400
|
+
}
|
|
1401
|
+
};
|
|
1402
|
+
|
|
1403
|
+
let mcpSuccess = false;
|
|
1404
|
+
try {
|
|
1405
|
+
const { enhancedMcpInit } = await import('../../mcp/mcp-config-manager.js');
|
|
1406
|
+
const result = await enhancedMcpInit(mcpOptions);
|
|
1407
|
+
|
|
1408
|
+
if (result.success) {
|
|
1409
|
+
printSuccess('✓ Bulletproof MCP configuration completed successfully');
|
|
1410
|
+
if (result.details) {
|
|
1411
|
+
console.log(` • Issues Fixed: ${result.details.issuesFixed || 0}`);
|
|
1412
|
+
console.log(` • Health Score: ${result.details.healthScore || 'N/A'}/100`);
|
|
1180
1413
|
}
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
dryRun: dryRun1,
|
|
1187
|
-
enhancedUx: true,
|
|
1188
|
-
showEducation: flags['show-education'] || false,
|
|
1189
|
-
serverConfig: {
|
|
1190
|
-
mcpServers: {
|
|
1191
|
-
'claude-flow-novice': {
|
|
1192
|
-
command: 'npx',
|
|
1193
|
-
args: [
|
|
1194
|
-
'claude-flow-novice',
|
|
1195
|
-
'mcp',
|
|
1196
|
-
'start'
|
|
1197
|
-
],
|
|
1198
|
-
env: {
|
|
1199
|
-
NODE_ENV: 'production',
|
|
1200
|
-
CLAUDE_FLOW_NOVICE_MODE: 'novice'
|
|
1201
|
-
}
|
|
1202
|
-
}
|
|
1203
|
-
}
|
|
1204
|
-
}
|
|
1205
|
-
};
|
|
1206
|
-
let mcpSuccess = false;
|
|
1207
|
-
try {
|
|
1208
|
-
const { enhancedMcpInit } = await import("../../mcp/mcp-config-manager.js");
|
|
1209
|
-
const result = await enhancedMcpInit(mcpOptions);
|
|
1210
|
-
if (result.success) {
|
|
1211
|
-
printSuccess('✓ Bulletproof MCP configuration completed successfully');
|
|
1212
|
-
if (result.details) {
|
|
1213
|
-
console.log(` • Issues Fixed: ${result.details.issuesFixed || 0}`);
|
|
1214
|
-
console.log(` • Health Score: ${result.details.healthScore || 'N/A'}/100`);
|
|
1215
|
-
}
|
|
1216
|
-
mcpSuccess = true;
|
|
1217
|
-
} else {
|
|
1218
|
-
printWarning(`⚠️ MCP configuration had issues: ${result.error || 'Unknown error'}`);
|
|
1219
|
-
if (result.rollbackAvailable) {
|
|
1220
|
-
console.log(' 🔄 Automatic rollback was performed');
|
|
1221
|
-
}
|
|
1222
|
-
}
|
|
1223
|
-
} catch (error) {
|
|
1224
|
-
printWarning(`⚠️ Bulletproof MCP setup failed: ${error.message}`);
|
|
1225
|
-
printWarning(' 📞 Falling back to legacy MCP configuration...');
|
|
1226
|
-
// Fallback to legacy config creation
|
|
1227
|
-
const mcpConfig = {
|
|
1228
|
-
mcpServers: {
|
|
1229
|
-
'claude-flow-novice': {
|
|
1230
|
-
command: 'npx',
|
|
1231
|
-
args: [
|
|
1232
|
-
'claude-flow-novice',
|
|
1233
|
-
'mcp',
|
|
1234
|
-
'start'
|
|
1235
|
-
],
|
|
1236
|
-
env: {
|
|
1237
|
-
NODE_ENV: 'production',
|
|
1238
|
-
CLAUDE_FLOW_NOVICE_MODE: 'novice'
|
|
1239
|
-
}
|
|
1240
|
-
}
|
|
1241
|
-
}
|
|
1242
|
-
};
|
|
1243
|
-
if (!dryRun1) {
|
|
1244
|
-
await fs.writeFile(`${workingDir}/.mcp.json`, JSON.stringify(mcpConfig, null, 2), 'utf8');
|
|
1245
|
-
printSuccess('✓ Created .mcp.json with legacy configuration');
|
|
1246
|
-
} else {
|
|
1247
|
-
console.log('[DRY RUN] Would create .mcp.json with legacy configuration');
|
|
1248
|
-
}
|
|
1249
|
-
mcpSuccess = true; // Consider legacy success for continuation
|
|
1414
|
+
mcpSuccess = true;
|
|
1415
|
+
} else {
|
|
1416
|
+
printWarning(`⚠️ MCP configuration had issues: ${result.error || 'Unknown error'}`);
|
|
1417
|
+
if (result.rollbackAvailable) {
|
|
1418
|
+
console.log(' 🔄 Automatic rollback was performed');
|
|
1250
1419
|
}
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
defaultTopology: 'hierarchical',
|
|
1266
|
-
executionStrategy: 'parallel',
|
|
1267
|
-
tokenOptimization: true,
|
|
1268
|
-
cacheEnabled: true,
|
|
1269
|
-
telemetryLevel: 'detailed'
|
|
1420
|
+
}
|
|
1421
|
+
} catch (error) {
|
|
1422
|
+
printWarning(`⚠️ Bulletproof MCP setup failed: ${error.message}`);
|
|
1423
|
+
printWarning(' 📞 Falling back to legacy MCP configuration...');
|
|
1424
|
+
|
|
1425
|
+
// Fallback to legacy config creation
|
|
1426
|
+
const mcpConfig = {
|
|
1427
|
+
mcpServers: {
|
|
1428
|
+
'claude-flow-novice': {
|
|
1429
|
+
command: 'npx',
|
|
1430
|
+
args: ['claude-flow-novice', 'mcp', 'start'],
|
|
1431
|
+
env: {
|
|
1432
|
+
NODE_ENV: 'production',
|
|
1433
|
+
CLAUDE_FLOW_NOVICE_MODE: 'novice'
|
|
1270
1434
|
}
|
|
1271
|
-
|
|
1272
|
-
if (!dryRun1) {
|
|
1273
|
-
await fs.writeFile(`${workingDir}/claude-flow.config.json`, JSON.stringify(claudeFlowConfig, null, 2, 'utf8'));
|
|
1274
|
-
printSuccess('✓ Created claude-flow.config.json for Claude Flow settings');
|
|
1275
|
-
} else {
|
|
1276
|
-
console.log('[DRY RUN] Would create claude-flow.config.json for Claude Flow settings');
|
|
1435
|
+
}
|
|
1277
1436
|
}
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1437
|
+
};
|
|
1438
|
+
|
|
1439
|
+
if (!dryRun) {
|
|
1440
|
+
await fs.writeFile(`${workingDir}/.mcp.json`, JSON.stringify(mcpConfig, null, 2), 'utf8');
|
|
1441
|
+
printSuccess('✓ Created .mcp.json with legacy configuration');
|
|
1442
|
+
} else {
|
|
1443
|
+
console.log('[DRY RUN] Would create .mcp.json with legacy configuration');
|
|
1444
|
+
}
|
|
1445
|
+
mcpSuccess = true; // Consider legacy success for continuation
|
|
1446
|
+
}
|
|
1447
|
+
|
|
1448
|
+
// Create claude-flow.config.json for Claude Flow specific settings
|
|
1449
|
+
const claudeFlowConfig = {
|
|
1450
|
+
features: {
|
|
1451
|
+
autoTopologySelection: true,
|
|
1452
|
+
parallelExecution: true,
|
|
1453
|
+
neuralTraining: true,
|
|
1454
|
+
bottleneckAnalysis: true,
|
|
1455
|
+
smartAutoSpawning: true,
|
|
1456
|
+
selfHealingWorkflows: true,
|
|
1457
|
+
crossSessionMemory: true,
|
|
1458
|
+
githubIntegration: true,
|
|
1459
|
+
},
|
|
1460
|
+
performance: {
|
|
1461
|
+
maxAgents: 10,
|
|
1462
|
+
defaultTopology: 'hierarchical',
|
|
1463
|
+
executionStrategy: 'parallel',
|
|
1464
|
+
tokenOptimization: true,
|
|
1465
|
+
cacheEnabled: true,
|
|
1466
|
+
telemetryLevel: 'detailed',
|
|
1467
|
+
},
|
|
1468
|
+
};
|
|
1469
|
+
|
|
1470
|
+
if (!dryRun) {
|
|
1471
|
+
await fs.writeFile(
|
|
1472
|
+
`${workingDir}/claude-flow.config.json`,
|
|
1473
|
+
JSON.stringify(claudeFlowConfig, null, 2, 'utf8'),
|
|
1474
|
+
);
|
|
1475
|
+
printSuccess('✓ Created claude-flow.config.json for Claude Flow settings');
|
|
1476
|
+
} else {
|
|
1477
|
+
console.log('[DRY RUN] Would create claude-flow.config.json for Claude Flow settings');
|
|
1478
|
+
}
|
|
1479
|
+
|
|
1480
|
+
// Create command documentation
|
|
1481
|
+
for (const [category, commands] of Object.entries(COMMAND_STRUCTURE)) {
|
|
1482
|
+
const categoryDir = `${claudeDir}/commands/${category}`;
|
|
1483
|
+
|
|
1484
|
+
if (!dryRun) {
|
|
1485
|
+
await fs.mkdir(categoryDir, { recursive: true });
|
|
1486
|
+
|
|
1487
|
+
// Create category README
|
|
1488
|
+
const categoryReadme = `# ${category.charAt(0).toUpperCase() + category.slice(1)} Commands
|
|
1287
1489
|
|
|
1288
1490
|
Commands for ${category} operations in Claude Flow.
|
|
1289
1491
|
|
|
1290
1492
|
## Available Commands
|
|
1291
1493
|
|
|
1292
|
-
${commands.map((cmd)
|
|
1494
|
+
${commands.map((cmd) => `- [${cmd}](./${cmd}.md)`).join('\n')}
|
|
1293
1495
|
`;
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
console.log(` ✓ Created ${commands.length} ${category} command docs`);
|
|
1303
|
-
} else {
|
|
1304
|
-
console.log(`[DRY RUN] Would create ${commands.length} ${category} command docs`);
|
|
1305
|
-
}
|
|
1306
|
-
}
|
|
1307
|
-
// Create wrapper scripts
|
|
1308
|
-
if (!dryRun1) {
|
|
1309
|
-
// Unix wrapper - now uses universal ES module compatible wrapper
|
|
1310
|
-
const unixWrapper = createWrapperScript('unix');
|
|
1311
|
-
await fs.writeFile(`${workingDir}/claude-flow`, unixWrapper, 'utf8');
|
|
1312
|
-
await fs.chmod(`${workingDir}/claude-flow`, 0o755);
|
|
1313
|
-
// Windows wrapper
|
|
1314
|
-
await fs.writeFile(`${workingDir}/claude-flow.bat`, createWrapperScript('windows', 'utf8'));
|
|
1315
|
-
// PowerShell wrapper
|
|
1316
|
-
await fs.writeFile(`${workingDir}/claude-flow.ps1`, createWrapperScript('powershell', 'utf8'));
|
|
1317
|
-
printSuccess('✓ Created platform-specific wrapper scripts');
|
|
1318
|
-
} else {
|
|
1319
|
-
console.log('[DRY RUN] Would create wrapper scripts');
|
|
1496
|
+
await fs.writeFile(`${categoryDir}/README.md`, categoryReadme, 'utf8');
|
|
1497
|
+
|
|
1498
|
+
// Create individual command docs
|
|
1499
|
+
for (const command of commands) {
|
|
1500
|
+
const doc = createCommandDoc(category, command);
|
|
1501
|
+
if (doc) {
|
|
1502
|
+
await fs.writeFile(`${categoryDir}/${command}.md`, doc, 'utf8');
|
|
1503
|
+
}
|
|
1320
1504
|
}
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1505
|
+
|
|
1506
|
+
console.log(` ✓ Created ${commands.length} ${category} command docs`);
|
|
1507
|
+
} else {
|
|
1508
|
+
console.log(`[DRY RUN] Would create ${commands.length} ${category} command docs`);
|
|
1509
|
+
}
|
|
1510
|
+
}
|
|
1511
|
+
|
|
1512
|
+
// Create wrapper scripts
|
|
1513
|
+
if (!dryRun) {
|
|
1514
|
+
// Unix wrapper - now uses universal ES module compatible wrapper
|
|
1515
|
+
const unixWrapper = createWrapperScript('unix');
|
|
1516
|
+
await fs.writeFile(`${workingDir}/claude-flow`, unixWrapper, 'utf8');
|
|
1517
|
+
await fs.chmod(`${workingDir}/claude-flow`, 0o755);
|
|
1518
|
+
|
|
1519
|
+
// Windows wrapper
|
|
1520
|
+
await fs.writeFile(`${workingDir}/claude-flow.bat`, createWrapperScript('windows', 'utf8'));
|
|
1521
|
+
|
|
1522
|
+
// PowerShell wrapper
|
|
1523
|
+
await fs.writeFile(
|
|
1524
|
+
`${workingDir}/claude-flow.ps1`,
|
|
1525
|
+
createWrapperScript('powershell', 'utf8'),
|
|
1526
|
+
);
|
|
1527
|
+
|
|
1528
|
+
printSuccess('✓ Created platform-specific wrapper scripts');
|
|
1529
|
+
} else {
|
|
1530
|
+
console.log('[DRY RUN] Would create wrapper scripts');
|
|
1531
|
+
}
|
|
1532
|
+
|
|
1533
|
+
// Create helper scripts
|
|
1534
|
+
const helpers = [
|
|
1535
|
+
'setup-mcp.sh',
|
|
1536
|
+
'quick-start.sh',
|
|
1537
|
+
'github-setup.sh',
|
|
1538
|
+
'github-safe.js',
|
|
1539
|
+
'standard-checkpoint-hooks.sh',
|
|
1540
|
+
'checkpoint-manager.sh',
|
|
1541
|
+
];
|
|
1542
|
+
for (const helper of helpers) {
|
|
1543
|
+
if (!dryRun) {
|
|
1544
|
+
const content = createHelperScript(helper);
|
|
1545
|
+
if (content) {
|
|
1546
|
+
await fs.writeFile(`${claudeDir}/helpers/${helper}`, content, 'utf8');
|
|
1547
|
+
await fs.chmod(`${claudeDir}/helpers/${helper}`, 0o755);
|
|
1338
1548
|
}
|
|
1339
|
-
|
|
1340
|
-
|
|
1549
|
+
}
|
|
1550
|
+
}
|
|
1551
|
+
|
|
1552
|
+
if (!dryRun) {
|
|
1553
|
+
printSuccess(`✓ Created ${helpers.length} helper scripts`);
|
|
1554
|
+
} else {
|
|
1555
|
+
console.log(`[DRY RUN] Would create ${helpers.length} helper scripts`);
|
|
1556
|
+
}
|
|
1557
|
+
|
|
1558
|
+
// Create standard directories from original init
|
|
1559
|
+
const standardDirs = [
|
|
1560
|
+
'memory',
|
|
1561
|
+
'memory/agents',
|
|
1562
|
+
'memory/sessions',
|
|
1563
|
+
'coordination',
|
|
1564
|
+
'coordination/memory_bank',
|
|
1565
|
+
'coordination/subtasks',
|
|
1566
|
+
'coordination/orchestration',
|
|
1567
|
+
'.swarm', // Add .swarm directory for shared memory
|
|
1568
|
+
'.hive-mind', // Add .hive-mind directory for hive-mind system
|
|
1569
|
+
'.claude/checkpoints', // Add checkpoints directory for Git checkpoint system
|
|
1570
|
+
];
|
|
1571
|
+
|
|
1572
|
+
for (const dir of standardDirs) {
|
|
1573
|
+
if (!dryRun) {
|
|
1574
|
+
await fs.mkdir(`${workingDir}/${dir}`, { recursive: true });
|
|
1575
|
+
}
|
|
1576
|
+
}
|
|
1577
|
+
|
|
1578
|
+
if (!dryRun) {
|
|
1579
|
+
printSuccess('✓ Created standard directory structure');
|
|
1580
|
+
|
|
1581
|
+
// Initialize memory system
|
|
1582
|
+
const initialData = { agents: [], tasks: [], lastUpdated: Date.now() };
|
|
1583
|
+
await fs.writeFile(
|
|
1584
|
+
`${workingDir}/memory/claude-flow-data.json`,
|
|
1585
|
+
JSON.stringify(initialData, null, 2, 'utf8'),
|
|
1586
|
+
);
|
|
1587
|
+
|
|
1588
|
+
// Create README files
|
|
1589
|
+
await fs.writeFile(`${workingDir}/memory/agents/README.md`, createAgentsReadme(), 'utf8');
|
|
1590
|
+
await fs.writeFile(`${workingDir}/memory/sessions/README.md`, createSessionsReadme(), 'utf8');
|
|
1591
|
+
|
|
1592
|
+
printSuccess('✓ Initialized memory system');
|
|
1593
|
+
|
|
1594
|
+
// Initialize memory database with fallback support
|
|
1595
|
+
try {
|
|
1596
|
+
// Import and initialize FallbackMemoryStore to create the database
|
|
1597
|
+
const { FallbackMemoryStore } = await import('../../../memory/fallback-store.js');
|
|
1598
|
+
const memoryStore = new FallbackMemoryStore();
|
|
1599
|
+
await memoryStore.initialize();
|
|
1600
|
+
|
|
1601
|
+
if (memoryStore.isUsingFallback()) {
|
|
1602
|
+
printSuccess('✓ Initialized memory system (in-memory fallback for npx compatibility)');
|
|
1603
|
+
console.log(
|
|
1604
|
+
' 💡 For persistent storage, install locally: npm install claude-flow@alpha',
|
|
1605
|
+
);
|
|
1341
1606
|
} else {
|
|
1342
|
-
|
|
1343
|
-
}
|
|
1344
|
-
// Create standard directories from original init
|
|
1345
|
-
const standardDirs = [
|
|
1346
|
-
'memory',
|
|
1347
|
-
'memory/agents',
|
|
1348
|
-
'memory/sessions',
|
|
1349
|
-
'coordination',
|
|
1350
|
-
'coordination/memory_bank',
|
|
1351
|
-
'coordination/subtasks',
|
|
1352
|
-
'coordination/orchestration',
|
|
1353
|
-
'.swarm',
|
|
1354
|
-
'.hive-mind',
|
|
1355
|
-
'.claude/checkpoints'
|
|
1356
|
-
];
|
|
1357
|
-
for (const dir of standardDirs){
|
|
1358
|
-
if (!dryRun1) {
|
|
1359
|
-
await fs.mkdir(`${workingDir}/${dir}`, {
|
|
1360
|
-
recursive: true
|
|
1361
|
-
});
|
|
1362
|
-
}
|
|
1363
|
-
}
|
|
1364
|
-
if (!dryRun1) {
|
|
1365
|
-
printSuccess('✓ Created standard directory structure');
|
|
1366
|
-
// Initialize memory system
|
|
1367
|
-
const initialData = {
|
|
1368
|
-
agents: [],
|
|
1369
|
-
tasks: [],
|
|
1370
|
-
lastUpdated: Date.now()
|
|
1371
|
-
};
|
|
1372
|
-
await fs.writeFile(`${workingDir}/memory/claude-flow-data.json`, JSON.stringify(initialData, null, 2, 'utf8'));
|
|
1373
|
-
// Create README files
|
|
1374
|
-
await fs.writeFile(`${workingDir}/memory/agents/README.md`, createAgentsReadme(), 'utf8');
|
|
1375
|
-
await fs.writeFile(`${workingDir}/memory/sessions/README.md`, createSessionsReadme(), 'utf8');
|
|
1376
|
-
printSuccess('✓ Initialized memory system');
|
|
1377
|
-
// Initialize memory database with fallback support
|
|
1378
|
-
try {
|
|
1379
|
-
// Import and initialize FallbackMemoryStore to create the database
|
|
1380
|
-
const { FallbackMemoryStore } = await import("../../../memory/fallback-store.js");
|
|
1381
|
-
const memoryStore = new FallbackMemoryStore();
|
|
1382
|
-
await memoryStore.initialize();
|
|
1383
|
-
if (memoryStore.isUsingFallback()) {
|
|
1384
|
-
printSuccess('✓ Initialized memory system (in-memory fallback for npx compatibility)');
|
|
1385
|
-
console.log(' 💡 For persistent storage, install locally: npm install claude-flow@alpha');
|
|
1386
|
-
} else {
|
|
1387
|
-
printSuccess('✓ Initialized memory database (.swarm/memory.db)');
|
|
1388
|
-
}
|
|
1389
|
-
memoryStore.close();
|
|
1390
|
-
} catch (err) {
|
|
1391
|
-
console.log(` ⚠️ Could not initialize memory system: ${err.message}`);
|
|
1392
|
-
console.log(' Memory will be initialized on first use');
|
|
1393
|
-
}
|
|
1394
|
-
// Initialize comprehensive hive-mind system
|
|
1395
|
-
console.log('\n🧠 Initializing Hive Mind System...');
|
|
1396
|
-
try {
|
|
1397
|
-
const hiveMindOptions = {
|
|
1398
|
-
config: {
|
|
1399
|
-
integration: {
|
|
1400
|
-
claudeCode: {
|
|
1401
|
-
enabled: isClaudeCodeInstalled()
|
|
1402
|
-
},
|
|
1403
|
-
mcpTools: {
|
|
1404
|
-
enabled: true
|
|
1405
|
-
}
|
|
1406
|
-
},
|
|
1407
|
-
monitoring: {
|
|
1408
|
-
enabled: flags.monitoring || false
|
|
1409
|
-
}
|
|
1410
|
-
}
|
|
1411
|
-
};
|
|
1412
|
-
const hiveMindResult = await initializeHiveMind(workingDir, hiveMindOptions, dryRun1);
|
|
1413
|
-
if (hiveMindResult.success) {
|
|
1414
|
-
printSuccess(`✓ Hive Mind System initialized with ${hiveMindResult.features.length} features`);
|
|
1415
|
-
// Log individual features
|
|
1416
|
-
hiveMindResult.features.forEach((feature)=>{
|
|
1417
|
-
console.log(` • ${feature}`);
|
|
1418
|
-
});
|
|
1419
|
-
} else {
|
|
1420
|
-
console.log(` ⚠️ Hive Mind initialization failed: ${hiveMindResult.error}`);
|
|
1421
|
-
if (hiveMindResult.rollbackRequired) {
|
|
1422
|
-
console.log(' 🔄 Automatic rollback may be required');
|
|
1423
|
-
}
|
|
1424
|
-
}
|
|
1425
|
-
} catch (err) {
|
|
1426
|
-
console.log(` ⚠️ Could not initialize hive-mind system: ${err.message}`);
|
|
1427
|
-
}
|
|
1607
|
+
printSuccess('✓ Initialized memory database (.swarm/memory.db)');
|
|
1428
1608
|
}
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1609
|
+
|
|
1610
|
+
memoryStore.close();
|
|
1611
|
+
} catch (err) {
|
|
1612
|
+
console.log(` ⚠️ Could not initialize memory system: ${err.message}`);
|
|
1613
|
+
console.log(' Memory will be initialized on first use');
|
|
1614
|
+
}
|
|
1615
|
+
|
|
1616
|
+
// Initialize comprehensive hive-mind system
|
|
1617
|
+
console.log('\n🧠 Initializing Hive Mind System...');
|
|
1618
|
+
try {
|
|
1619
|
+
const hiveMindOptions = {
|
|
1620
|
+
config: {
|
|
1621
|
+
integration: {
|
|
1622
|
+
claudeCode: { enabled: isClaudeCodeInstalled() },
|
|
1623
|
+
mcpTools: { enabled: true },
|
|
1624
|
+
},
|
|
1625
|
+
monitoring: { enabled: flags.monitoring || false },
|
|
1626
|
+
},
|
|
1627
|
+
};
|
|
1628
|
+
|
|
1629
|
+
const hiveMindResult = await initializeHiveMind(workingDir, hiveMindOptions, dryRun);
|
|
1630
|
+
|
|
1631
|
+
if (hiveMindResult.success) {
|
|
1632
|
+
printSuccess(
|
|
1633
|
+
`✓ Hive Mind System initialized with ${hiveMindResult.features.length} features`,
|
|
1634
|
+
);
|
|
1635
|
+
|
|
1636
|
+
// Log individual features
|
|
1637
|
+
hiveMindResult.features.forEach((feature) => {
|
|
1638
|
+
console.log(` • ${feature}`);
|
|
1639
|
+
});
|
|
1437
1640
|
} else {
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
if (initSparc) {
|
|
1443
|
-
console.log('\n🚀 Initializing SPARC development environment...');
|
|
1444
|
-
try {
|
|
1445
|
-
// Run create-sparc
|
|
1446
|
-
console.log(' 🔄 Running: npx -y create-sparc init --force');
|
|
1447
|
-
execSync('npx -y create-sparc init --force', {
|
|
1448
|
-
cwd: workingDir,
|
|
1449
|
-
stdio: 'inherit'
|
|
1450
|
-
});
|
|
1451
|
-
sparcInitialized = true;
|
|
1452
|
-
printSuccess('✅ SPARC environment initialized successfully');
|
|
1453
|
-
} catch (err) {
|
|
1454
|
-
console.log(` ⚠️ Could not run create-sparc: ${err.message}`);
|
|
1455
|
-
console.log(' SPARC features will be limited to basic functionality');
|
|
1456
|
-
}
|
|
1641
|
+
console.log(` ⚠️ Hive Mind initialization failed: ${hiveMindResult.error}`);
|
|
1642
|
+
if (hiveMindResult.rollbackRequired) {
|
|
1643
|
+
console.log(' 🔄 Automatic rollback may be required');
|
|
1644
|
+
}
|
|
1457
1645
|
}
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
}
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1646
|
+
} catch (err) {
|
|
1647
|
+
console.log(` ⚠️ Could not initialize hive-mind system: ${err.message}`);
|
|
1648
|
+
}
|
|
1649
|
+
}
|
|
1650
|
+
|
|
1651
|
+
// Update .gitignore with Claude Flow entries
|
|
1652
|
+
const gitignoreResult = await updateGitignore(workingDir, force, dryRun);
|
|
1653
|
+
if (gitignoreResult.success) {
|
|
1654
|
+
if (!dryRun) {
|
|
1655
|
+
printSuccess(`✓ ${gitignoreResult.message}`);
|
|
1656
|
+
} else {
|
|
1657
|
+
console.log(gitignoreResult.message);
|
|
1658
|
+
}
|
|
1659
|
+
} else {
|
|
1660
|
+
console.log(` ⚠️ ${gitignoreResult.message}`);
|
|
1661
|
+
}
|
|
1662
|
+
|
|
1663
|
+
// SPARC initialization (only with --roo flag)
|
|
1664
|
+
let sparcInitialized = false;
|
|
1665
|
+
if (initSparc) {
|
|
1666
|
+
console.log('\n🚀 Initializing SPARC development environment...');
|
|
1667
|
+
try {
|
|
1668
|
+
// Run create-sparc
|
|
1669
|
+
console.log(' 🔄 Running: npx -y create-sparc init --force');
|
|
1670
|
+
execSync('npx -y create-sparc init --force', {
|
|
1671
|
+
cwd: workingDir,
|
|
1672
|
+
stdio: 'inherit',
|
|
1673
|
+
});
|
|
1674
|
+
sparcInitialized = true;
|
|
1675
|
+
printSuccess('✅ SPARC environment initialized successfully');
|
|
1676
|
+
} catch (err) {
|
|
1677
|
+
console.log(` ⚠️ Could not run create-sparc: ${err.message}`);
|
|
1678
|
+
console.log(' SPARC features will be limited to basic functionality');
|
|
1679
|
+
}
|
|
1680
|
+
}
|
|
1681
|
+
|
|
1682
|
+
// Create Claude slash commands for SPARC
|
|
1683
|
+
if (sparcInitialized && !dryRun) {
|
|
1684
|
+
console.log('\n📝 Creating Claude Code slash commands...');
|
|
1685
|
+
await createClaudeSlashCommands(workingDir);
|
|
1686
|
+
}
|
|
1687
|
+
|
|
1688
|
+
// Check for Claude Code and set up MCP servers (always enabled by default)
|
|
1689
|
+
if (!dryRun && isClaudeCodeInstalled()) {
|
|
1690
|
+
console.log('\n🔍 Claude Code CLI detected!');
|
|
1691
|
+
const skipMcp =
|
|
1692
|
+
(options && options['skip-mcp']) ||
|
|
1693
|
+
(subArgs && subArgs.includes && subArgs.includes('--skip-mcp'));
|
|
1694
|
+
|
|
1695
|
+
if (!skipMcp) {
|
|
1696
|
+
// Use bulletproof MCP setup for enhanced init
|
|
1697
|
+
const mcpSuccess = await setupBulletproofMcp({
|
|
1698
|
+
verbose: true,
|
|
1699
|
+
autoFix: true,
|
|
1700
|
+
dryRun: dryRun
|
|
1701
|
+
});
|
|
1702
|
+
|
|
1703
|
+
if (!mcpSuccess) {
|
|
1704
|
+
console.log(' 💡 If you encounter issues, run: claude mcp remove claude-flow-novice -s local');
|
|
1494
1705
|
}
|
|
1495
|
-
|
|
1496
|
-
console.log('
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
enabled: true,
|
|
1536
|
-
command: "npx claude-flow-novice hooks post-task --task-id \"$TASK_ID\"",
|
|
1537
|
-
description: "Post-task completion hook"
|
|
1538
|
-
}
|
|
1539
|
-
},
|
|
1540
|
-
memory: {
|
|
1541
|
-
enabled: true,
|
|
1542
|
-
persistence: "local",
|
|
1543
|
-
namespace: "claude-flow-novice"
|
|
1544
|
-
}
|
|
1545
|
-
};
|
|
1546
|
-
const hooksConfigPath = `${claudeDir}/hooks.json`;
|
|
1547
|
-
await fs.writeFile(hooksConfigPath, JSON.stringify(hooksConfig, null, 2), 'utf8');
|
|
1548
|
-
console.log('✅ ✓ Hooks system setup complete with automated coordination');
|
|
1706
|
+
} else {
|
|
1707
|
+
console.log(' ℹ️ Skipping MCP setup (--skip-mcp flag used)');
|
|
1708
|
+
console.log('\n 📋 To add MCP servers manually:');
|
|
1709
|
+
console.log(' claude mcp add claude-flow-novice npx claude-flow-novice mcp start');
|
|
1710
|
+
console.log(' claude mcp add ruv-swarm npx ruv-swarm@latest mcp start');
|
|
1711
|
+
// Flow-nexus integration removed
|
|
1712
|
+
console.log('\n 💡 MCP servers are defined in .mcp.json (project scope)');
|
|
1713
|
+
}
|
|
1714
|
+
} else if (!dryRun && !isClaudeCodeInstalled()) {
|
|
1715
|
+
console.log('\n⚠️ Claude Code CLI not detected!');
|
|
1716
|
+
console.log('\n 📥 To install Claude Code:');
|
|
1717
|
+
console.log(' npm install -g @anthropic-ai/claude-code');
|
|
1718
|
+
console.log('\n 📋 After installing, add MCP servers:');
|
|
1719
|
+
console.log(' claude mcp add claude-flow-novice npx claude-flow-novice mcp start');
|
|
1720
|
+
console.log(' claude mcp add ruv-swarm npx ruv-swarm@latest mcp start');
|
|
1721
|
+
// Flow-nexus integration removed
|
|
1722
|
+
console.log('\n 💡 MCP servers are defined in .mcp.json (project scope)');
|
|
1723
|
+
}
|
|
1724
|
+
|
|
1725
|
+
// Create agent directories and copy all agent files
|
|
1726
|
+
console.log('\n🤖 Setting up agent system...');
|
|
1727
|
+
if (!dryRun) {
|
|
1728
|
+
await createAgentDirectories(workingDir, dryRun);
|
|
1729
|
+
const agentResult = await copyAgentFiles(workingDir, {
|
|
1730
|
+
force: force,
|
|
1731
|
+
dryRun: dryRun,
|
|
1732
|
+
});
|
|
1733
|
+
|
|
1734
|
+
if (agentResult.success) {
|
|
1735
|
+
await validateAgentSystem(workingDir);
|
|
1736
|
+
|
|
1737
|
+
// Copy command files including Flow Nexus commands
|
|
1738
|
+
console.log('\n📚 Setting up command system...');
|
|
1739
|
+
const commandResult = await copyCommandFiles(workingDir, {
|
|
1740
|
+
force: force,
|
|
1741
|
+
dryRun: dryRun,
|
|
1742
|
+
});
|
|
1743
|
+
|
|
1744
|
+
if (commandResult.success) {
|
|
1745
|
+
console.log('✅ ✓ Command system setup complete with Flow Nexus integration');
|
|
1549
1746
|
} else {
|
|
1550
|
-
|
|
1551
|
-
console.log(' [DRY RUN] Would create hooks system with automated coordination');
|
|
1747
|
+
console.log('⚠️ Command system setup failed:', commandResult.error);
|
|
1552
1748
|
}
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1749
|
+
|
|
1750
|
+
console.log('✅ ✓ Agent system setup complete with 64 specialized agents');
|
|
1751
|
+
} else {
|
|
1752
|
+
console.log('⚠️ Agent system setup failed:', agentResult.error);
|
|
1753
|
+
}
|
|
1754
|
+
|
|
1755
|
+
// Setup hooks system for novice users
|
|
1756
|
+
console.log('\n🪝 Setting up hooks system...');
|
|
1757
|
+
const hooksConfig = {
|
|
1758
|
+
hooks: {
|
|
1759
|
+
pre_task: {
|
|
1760
|
+
enabled: true,
|
|
1761
|
+
command: "npx claude-flow-novice hooks pre-task --description \"$TASK_DESCRIPTION\"",
|
|
1762
|
+
description: "Pre-task coordination hook"
|
|
1763
|
+
},
|
|
1764
|
+
post_edit: {
|
|
1765
|
+
enabled: true,
|
|
1766
|
+
command: "npx claude-flow-novice hooks post-edit --file \"$FILE_PATH\" --memory-key \"swarm/$AGENT_ID/$STEP\"",
|
|
1767
|
+
description: "Post-edit memory storage hook"
|
|
1768
|
+
},
|
|
1769
|
+
post_task: {
|
|
1770
|
+
enabled: true,
|
|
1771
|
+
command: "npx claude-flow-novice hooks post-task --task-id \"$TASK_ID\"",
|
|
1772
|
+
description: "Post-task completion hook"
|
|
1773
|
+
}
|
|
1774
|
+
},
|
|
1775
|
+
memory: {
|
|
1776
|
+
enabled: true,
|
|
1777
|
+
persistence: "local",
|
|
1778
|
+
namespace: "claude-flow-novice"
|
|
1572
1779
|
}
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1780
|
+
};
|
|
1781
|
+
|
|
1782
|
+
const hooksConfigPath = `${claudeDir}/hooks.json`;
|
|
1783
|
+
await fs.writeFile(hooksConfigPath, JSON.stringify(hooksConfig, null, 2), 'utf8');
|
|
1784
|
+
console.log('✅ ✓ Hooks system setup complete with automated coordination');
|
|
1785
|
+
|
|
1786
|
+
} else {
|
|
1787
|
+
console.log(' [DRY RUN] Would create agent system with 64 specialized agents');
|
|
1788
|
+
console.log(' [DRY RUN] Would create hooks system with automated coordination');
|
|
1789
|
+
}
|
|
1790
|
+
|
|
1791
|
+
// Optional: Setup monitoring and telemetry
|
|
1792
|
+
const enableMonitoring = flags.monitoring || flags['enable-monitoring'];
|
|
1793
|
+
if (enableMonitoring && !dryRun) {
|
|
1794
|
+
console.log('\n📊 Setting up monitoring and telemetry...');
|
|
1795
|
+
await setupMonitoring(workingDir);
|
|
1796
|
+
}
|
|
1797
|
+
|
|
1798
|
+
// Final instructions with hive-mind status
|
|
1799
|
+
console.log('\n🎉 Claude Flow v2.0.0 initialization complete!');
|
|
1800
|
+
|
|
1801
|
+
// Display MCP setup status prominently
|
|
1802
|
+
if (mcpSuccess) {
|
|
1803
|
+
console.log('\n🛡️ Bulletproof MCP Configuration Status:');
|
|
1804
|
+
console.log(' ✅ MCP server successfully configured with auto-recovery');
|
|
1805
|
+
console.log(' ✅ Conflict detection and resolution enabled');
|
|
1806
|
+
console.log(' ✅ Automatic backup and rollback capability active');
|
|
1807
|
+
console.log(' ✅ Project-specific configuration created (.mcp.json)');
|
|
1808
|
+
} else {
|
|
1809
|
+
console.log('\n⚠️ MCP Configuration Status:');
|
|
1810
|
+
console.log(' ⚠️ MCP setup completed with fallback configuration');
|
|
1811
|
+
console.log(' 💡 Run health check: npx claude-flow-novice mcp health');
|
|
1812
|
+
}
|
|
1813
|
+
|
|
1814
|
+
// Display hive-mind status
|
|
1815
|
+
const hiveMindStatus = getHiveMindStatus(workingDir);
|
|
1816
|
+
console.log('\n🧠 Hive Mind System Status:');
|
|
1817
|
+
console.log(` Configuration: ${hiveMindStatus.configured ? '✅ Ready' : '❌ Missing'}`);
|
|
1818
|
+
console.log(
|
|
1819
|
+
` Database: ${hiveMindStatus.database === 'sqlite' ? '✅ SQLite' : hiveMindStatus.database === 'fallback' ? '⚠️ JSON Fallback' : '❌ Not initialized'}`,
|
|
1820
|
+
);
|
|
1821
|
+
console.log(
|
|
1822
|
+
` Directory Structure: ${hiveMindStatus.directories ? '✅ Created' : '❌ Missing'}`,
|
|
1823
|
+
);
|
|
1824
|
+
|
|
1825
|
+
console.log('\n📚 Quick Start:');
|
|
1826
|
+
if (isClaudeCodeInstalled()) {
|
|
1827
|
+
console.log('1. Verify MCP setup: claude mcp list');
|
|
1828
|
+
console.log('2. View available commands: ls .claude/commands/');
|
|
1829
|
+
console.log('3. Start a swarm: npx claude-flow-novice swarm "your objective" --claude');
|
|
1830
|
+
console.log('4. Use hive-mind: npx claude-flow-novice hive-mind spawn "command" --claude');
|
|
1831
|
+
console.log('5. Use enhanced MCP tools in Claude Code for bulletproof coordination');
|
|
1832
|
+
if (hiveMindStatus.configured) {
|
|
1833
|
+
console.log('5. Initialize first swarm: npx claude-flow-novice hive-mind init');
|
|
1834
|
+
}
|
|
1835
|
+
} else {
|
|
1836
|
+
console.log('1. Install Claude Code: npm install -g @anthropic-ai/claude-code');
|
|
1837
|
+
console.log('2. Add MCP servers (see instructions above)');
|
|
1838
|
+
console.log('3. View available commands: ls .claude/commands/');
|
|
1839
|
+
console.log('4. Start a swarm: npx claude-flow-novice swarm "your objective" --claude');
|
|
1840
|
+
console.log('5. Use hive-mind: npx claude-flow-novice hive-mind spawn "command" --claude');
|
|
1841
|
+
if (hiveMindStatus.configured) {
|
|
1842
|
+
console.log('6. Initialize first swarm: npx claude-flow-novice hive-mind init');
|
|
1843
|
+
}
|
|
1844
|
+
}
|
|
1845
|
+
console.log('\n💡 Tips:');
|
|
1846
|
+
console.log('• Check .claude/commands/ for detailed documentation');
|
|
1847
|
+
console.log('• Use --help with any command for options');
|
|
1848
|
+
console.log('• Run commands with --claude flag for best Claude Code integration');
|
|
1849
|
+
if (mcpSuccess) {
|
|
1850
|
+
console.log('• MCP health check: npx claude-flow-novice mcp health');
|
|
1851
|
+
console.log('• Configuration backups are automatically created for safety');
|
|
1852
|
+
console.log('• Project-specific .mcp.json prevents conflicts with other projects');
|
|
1853
|
+
}
|
|
1854
|
+
console.log('• Enable GitHub integration with .claude/helpers/github-setup.sh');
|
|
1855
|
+
console.log('• Git checkpoints are automatically enabled in settings.json');
|
|
1856
|
+
console.log('• Use .claude/helpers/checkpoint-manager.sh for easy rollback');
|
|
1857
|
+
} catch (err) {
|
|
1858
|
+
printError(`Failed to initialize Claude Flow v2.0.0: ${err.message}`);
|
|
1859
|
+
|
|
1860
|
+
// Attempt hive-mind rollback if it was partially initialized
|
|
1861
|
+
try {
|
|
1862
|
+
const hiveMindStatus = getHiveMindStatus(workingDir);
|
|
1863
|
+
if (hiveMindStatus.directories || hiveMindStatus.configured) {
|
|
1864
|
+
console.log('\n🔄 Attempting hive-mind system rollback...');
|
|
1865
|
+
const rollbackResult = await rollbackHiveMindInit(workingDir);
|
|
1866
|
+
if (rollbackResult.success) {
|
|
1867
|
+
console.log(' ✅ Hive-mind rollback completed');
|
|
1589
1868
|
} else {
|
|
1590
|
-
|
|
1591
|
-
console.log('2. Add MCP servers (see instructions above)');
|
|
1592
|
-
console.log('3. View available commands: ls .claude/commands/');
|
|
1593
|
-
console.log('4. Start a swarm: npx claude-flow-novice swarm "your objective" --claude');
|
|
1594
|
-
console.log('5. Use hive-mind: npx claude-flow-novice hive-mind spawn "command" --claude');
|
|
1595
|
-
if (hiveMindStatus.configured) {
|
|
1596
|
-
console.log('6. Initialize first swarm: npx claude-flow-novice hive-mind init');
|
|
1597
|
-
}
|
|
1598
|
-
}
|
|
1599
|
-
console.log('\n💡 Tips:');
|
|
1600
|
-
console.log('• Check .claude/commands/ for detailed documentation');
|
|
1601
|
-
console.log('• Use --help with any command for options');
|
|
1602
|
-
console.log('• Run commands with --claude flag for best Claude Code integration');
|
|
1603
|
-
if (mcpSuccess) {
|
|
1604
|
-
console.log('• MCP health check: npx claude-flow-novice mcp health');
|
|
1605
|
-
console.log('• Configuration backups are automatically created for safety');
|
|
1606
|
-
console.log('• Project-specific .mcp.json prevents conflicts with other projects');
|
|
1607
|
-
}
|
|
1608
|
-
console.log('• Enable GitHub integration with .claude/helpers/github-setup.sh');
|
|
1609
|
-
console.log('• Git checkpoints are automatically enabled in settings.json');
|
|
1610
|
-
console.log('• Use .claude/helpers/checkpoint-manager.sh for easy rollback');
|
|
1611
|
-
} catch (err) {
|
|
1612
|
-
printError(`Failed to initialize Claude Flow v2.0.0: ${err.message}`);
|
|
1613
|
-
// Attempt hive-mind rollback if it was partially initialized
|
|
1614
|
-
try {
|
|
1615
|
-
const hiveMindStatus = getHiveMindStatus(workingDir);
|
|
1616
|
-
if (hiveMindStatus.directories || hiveMindStatus.configured) {
|
|
1617
|
-
console.log('\n🔄 Attempting hive-mind system rollback...');
|
|
1618
|
-
const rollbackResult = await rollbackHiveMindInit(workingDir);
|
|
1619
|
-
if (rollbackResult.success) {
|
|
1620
|
-
console.log(' ✅ Hive-mind rollback completed');
|
|
1621
|
-
} else {
|
|
1622
|
-
console.log(` ⚠️ Hive-mind rollback failed: ${rollbackResult.error}`);
|
|
1623
|
-
}
|
|
1624
|
-
}
|
|
1625
|
-
} catch (rollbackErr) {
|
|
1626
|
-
console.log(` ⚠️ Rollback error: ${rollbackErr.message}`);
|
|
1869
|
+
console.log(` ⚠️ Hive-mind rollback failed: ${rollbackResult.error}`);
|
|
1627
1870
|
}
|
|
1871
|
+
}
|
|
1872
|
+
} catch (rollbackErr) {
|
|
1873
|
+
console.log(` ⚠️ Rollback error: ${rollbackErr.message}`);
|
|
1628
1874
|
}
|
|
1629
|
-
}
|
|
1875
|
+
}
|
|
1876
|
+
}
|
|
1877
|
+
|
|
1878
|
+
// Flow Nexus initialization removed
|