claude-flow-novice 2.0.3 → 2.0.4
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 +487 -668
- package/dist/src/cli/commands/index-validate.js +18 -29
- package/dist/src/cli/commands/mcp-troubleshoot.js +230 -282
- package/dist/src/cli/commands/neural-goal-init.js +92 -125
- package/dist/src/cli/commands/swarm-exec.js +317 -393
- package/dist/src/cli/commands/swarm.js +1 -1
- package/dist/src/cli/commands/validate-framework.js +983 -1100
- package/dist/src/cli/commands/validate.js +144 -223
- package/dist/src/cli/simple-commands/__tests__/agent.test.js +265 -277
- package/dist/src/cli/simple-commands/__tests__/memory.test.js +6 -7
- package/dist/src/cli/simple-commands/__tests__/swarm.test.js +373 -356
- package/dist/src/cli/simple-commands/__tests__/task.test.js +6 -7
- package/dist/src/cli/simple-commands/agent.js +157 -193
- package/dist/src/cli/simple-commands/analysis.js +336 -446
- package/dist/src/cli/simple-commands/automation-executor.js +1095 -1339
- package/dist/src/cli/simple-commands/automation.js +481 -469
- package/dist/src/cli/simple-commands/batch-manager.js +261 -313
- package/dist/src/cli/simple-commands/claude-telemetry.js +241 -267
- package/dist/src/cli/simple-commands/claude-track.js +68 -90
- package/dist/src/cli/simple-commands/concurrent-display.js +266 -320
- package/dist/src/cli/simple-commands/config.js +245 -290
- package/dist/src/cli/simple-commands/coordination.js +182 -234
- package/dist/src/cli/simple-commands/enhanced-ui-views.js +812 -615
- package/dist/src/cli/simple-commands/enhanced-webui-complete.js +922 -981
- package/dist/src/cli/simple-commands/fix-hook-variables.js +274 -294
- package/dist/src/cli/simple-commands/github/gh-coordinator.js +378 -457
- package/dist/src/cli/simple-commands/github/github-api.js +535 -574
- package/dist/src/cli/simple-commands/github/init.js +276 -303
- package/dist/src/cli/simple-commands/github.js +222 -247
- package/dist/src/cli/simple-commands/goal.js +51 -63
- package/dist/src/cli/simple-commands/hive-mind/auto-save-middleware.js +208 -278
- package/dist/src/cli/simple-commands/hive-mind/communication.js +601 -696
- package/dist/src/cli/simple-commands/hive-mind/core.js +907 -979
- package/dist/src/cli/simple-commands/hive-mind/db-optimizer.js +406 -655
- package/dist/src/cli/simple-commands/hive-mind/mcp-wrapper.js +1125 -1245
- package/dist/src/cli/simple-commands/hive-mind/memory.js +854 -1090
- package/dist/src/cli/simple-commands/hive-mind/performance-optimizer.js +459 -574
- package/dist/src/cli/simple-commands/hive-mind/performance-test.js +263 -347
- package/dist/src/cli/simple-commands/hive-mind/queen.js +727 -768
- package/dist/src/cli/simple-commands/hive-mind/session-manager.js +745 -1049
- package/dist/src/cli/simple-commands/hive-mind-optimize.js +227 -283
- package/dist/src/cli/simple-commands/hive-mind-wizard.js +174 -217
- package/dist/src/cli/simple-commands/hive-mind.js +1842 -2283
- package/dist/src/cli/simple-commands/hive.js +90 -79
- package/dist/src/cli/simple-commands/hook-safety.js +431 -521
- package/dist/src/cli/simple-commands/hooks/session-start-soul.js +203 -254
- package/dist/src/cli/simple-commands/hooks.js +1064 -1204
- package/dist/src/cli/simple-commands/init/agent-copier.js +294 -319
- package/dist/src/cli/simple-commands/init/batch-init.js +496 -562
- package/dist/src/cli/simple-commands/init/claude-commands/claude-flow-commands.js +13 -19
- package/dist/src/cli/simple-commands/init/claude-commands/optimized-claude-flow-commands.js +13 -19
- package/dist/src/cli/simple-commands/init/claude-commands/optimized-slash-commands.js +61 -88
- package/dist/src/cli/simple-commands/init/claude-commands/optimized-sparc-commands.js +125 -150
- package/dist/src/cli/simple-commands/init/claude-commands/slash-commands.js +42 -49
- package/dist/src/cli/simple-commands/init/claude-commands/sparc-commands.js +43 -61
- package/dist/src/cli/simple-commands/init/copy-revised-templates.js +141 -147
- package/dist/src/cli/simple-commands/init/executable-wrapper.js +31 -44
- package/dist/src/cli/simple-commands/init/gitignore-updater.js +64 -90
- package/dist/src/cli/simple-commands/init/help.js +104 -107
- package/dist/src/cli/simple-commands/init/hive-mind-init.js +509 -528
- package/dist/src/cli/simple-commands/init/index.js +1510 -1759
- package/dist/src/cli/simple-commands/init/performance-monitor.js +234 -317
- package/dist/src/cli/simple-commands/init/rollback/backup-manager.js +441 -504
- package/dist/src/cli/simple-commands/init/rollback/index.js +289 -364
- package/dist/src/cli/simple-commands/init/rollback/recovery-manager.js +652 -728
- package/dist/src/cli/simple-commands/init/rollback/rollback-executor.js +416 -481
- package/dist/src/cli/simple-commands/init/rollback/state-tracker.js +369 -448
- package/dist/src/cli/simple-commands/init/sparc/roo-readme.js +1 -2
- package/dist/src/cli/simple-commands/init/sparc/roomodes-config.js +122 -99
- package/dist/src/cli/simple-commands/init/sparc/workflows.js +32 -37
- package/dist/src/cli/simple-commands/init/sparc-structure.js +55 -62
- package/dist/src/cli/simple-commands/init/template-copier.js +421 -533
- package/dist/src/cli/simple-commands/init/templates/coordination-md.js +3 -6
- package/dist/src/cli/simple-commands/init/templates/enhanced-templates.js +344 -318
- package/dist/src/cli/simple-commands/init/templates/github-safe-enhanced.js +173 -218
- package/dist/src/cli/simple-commands/init/templates/github-safe.js +65 -75
- package/dist/src/cli/simple-commands/init/templates/memory-bank-md.js +3 -6
- package/dist/src/cli/simple-commands/init/templates/readme-files.js +2 -4
- package/dist/src/cli/simple-commands/init/templates/safe-hook-patterns.js +187 -230
- package/dist/src/cli/simple-commands/init/templates/sparc-modes.js +53 -80
- package/dist/src/cli/simple-commands/init/templates/verification-claude-md.js +101 -85
- package/dist/src/cli/simple-commands/init/validation/config-validator.js +283 -330
- package/dist/src/cli/simple-commands/init/validation/health-checker.js +495 -561
- package/dist/src/cli/simple-commands/init/validation/index.js +302 -358
- package/dist/src/cli/simple-commands/init/validation/mode-validator.js +308 -359
- package/dist/src/cli/simple-commands/init/validation/post-init-validator.js +389 -366
- package/dist/src/cli/simple-commands/init/validation/pre-init-validator.js +270 -268
- package/dist/src/cli/simple-commands/init/validation/test-runner.js +427 -447
- package/dist/src/cli/simple-commands/init.js +1 -2
- package/dist/src/cli/simple-commands/mcp-health.js +131 -158
- package/dist/src/cli/simple-commands/mcp-integration-layer.js +533 -634
- package/dist/src/cli/simple-commands/mcp.js +345 -400
- package/dist/src/cli/simple-commands/memory-consolidation.js +426 -537
- package/dist/src/cli/simple-commands/memory.js +247 -311
- package/dist/src/cli/simple-commands/migrate-hooks.js +39 -46
- package/dist/src/cli/simple-commands/monitor.js +294 -363
- package/dist/src/cli/simple-commands/neural.js +51 -65
- package/dist/src/cli/simple-commands/pair-autofix-only.js +538 -662
- package/dist/src/cli/simple-commands/pair-basic.js +528 -656
- package/dist/src/cli/simple-commands/pair-old.js +430 -543
- package/dist/src/cli/simple-commands/pair-working.js +615 -751
- package/dist/src/cli/simple-commands/pair.js +615 -751
- package/dist/src/cli/simple-commands/performance-hooks.js +83 -111
- package/dist/src/cli/simple-commands/performance-metrics.js +348 -433
- package/dist/src/cli/simple-commands/process-ui-enhanced.js +708 -787
- package/dist/src/cli/simple-commands/process-ui.js +230 -254
- package/dist/src/cli/simple-commands/realtime-update-system.js +525 -611
- package/dist/src/cli/simple-commands/sparc/architecture.js +1704 -1530
- package/dist/src/cli/simple-commands/sparc/commands.js +438 -516
- package/dist/src/cli/simple-commands/sparc/completion.js +1224 -1481
- package/dist/src/cli/simple-commands/sparc/coordinator.js +913 -978
- package/dist/src/cli/simple-commands/sparc/index.js +241 -298
- package/dist/src/cli/simple-commands/sparc/phase-base.js +314 -390
- package/dist/src/cli/simple-commands/sparc/pseudocode.js +965 -869
- package/dist/src/cli/simple-commands/sparc/refinement.js +980 -1273
- package/dist/src/cli/simple-commands/sparc/specification.js +559 -645
- 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 +47 -55
- 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 +101 -87
- 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 +465 -493
- package/dist/src/cli/simple-commands/start-ui.js +108 -132
- package/dist/src/cli/simple-commands/start-wrapper.js +240 -268
- package/dist/src/cli/simple-commands/start.js +1 -1
- package/dist/src/cli/simple-commands/status.js +254 -275
- package/dist/src/cli/simple-commands/stream-chain-clean.js +128 -171
- package/dist/src/cli/simple-commands/stream-chain-fixed.js +61 -82
- package/dist/src/cli/simple-commands/stream-chain-real.js +267 -331
- package/dist/src/cli/simple-commands/stream-chain-working.js +211 -263
- package/dist/src/cli/simple-commands/stream-chain.js +260 -318
- package/dist/src/cli/simple-commands/stream-processor.js +290 -315
- package/dist/src/cli/simple-commands/swarm-executor.js +189 -222
- package/dist/src/cli/simple-commands/swarm-metrics-integration.js +208 -300
- package/dist/src/cli/simple-commands/swarm-ui.js +623 -703
- package/dist/src/cli/simple-commands/swarm-webui-integration.js +258 -286
- package/dist/src/cli/simple-commands/swarm.js +887 -1082
- package/dist/src/cli/simple-commands/task.js +161 -206
- package/dist/src/cli/simple-commands/timestamp-fix.js +59 -89
- package/dist/src/cli/simple-commands/token-tracker.js +258 -316
- package/dist/src/cli/simple-commands/tool-execution-framework.js +433 -519
- package/dist/src/cli/simple-commands/train-and-stream.js +275 -331
- package/dist/src/cli/simple-commands/training-pipeline.js +619 -725
- package/dist/src/cli/simple-commands/training.js +170 -227
- package/dist/src/cli/simple-commands/verification-hooks.js +261 -284
- package/dist/src/cli/simple-commands/verification-integration.js +389 -417
- package/dist/src/cli/simple-commands/verification-training-integration.js +486 -606
- package/dist/src/cli/simple-commands/verification.js +493 -513
- package/dist/src/cli/simple-commands/web-server.js +766 -836
- package/dist/src/cli/simple-commands/webui-validator.js +106 -124
- package/dist/src/coordination/event-bus/demo-wasm-integration.js +212 -251
- package/dist/src/coordination/event-bus/qe-event-bus.js +608 -748
- package/dist/src/coordination/event-bus/qe-event-bus.test.js +379 -454
- package/dist/src/coordination/iteration-tracker.js +363 -454
- package/dist/src/enterprise/analytics-manager.js +1135 -0
- package/dist/src/enterprise/audit-manager.js +1115 -0
- package/dist/src/enterprise/cloud-manager.js +891 -0
- package/dist/src/enterprise/deployment-manager.js +966 -0
- package/dist/src/enterprise/index.js +6 -0
- package/dist/src/enterprise/project-manager.js +584 -0
- package/dist/src/enterprise/security-manager.js +991 -0
- package/dist/src/index.js +1 -1
- package/dist/src/mcp/DEPRECATED.js +46 -60
- package/dist/src/mcp/fixes/mcp-error-fixes.js +115 -134
- package/dist/src/mcp/implementations/agent-tracker.js +114 -128
- package/dist/src/mcp/implementations/daa-tools.js +292 -350
- package/dist/src/mcp/implementations/workflow-tools.js +329 -361
- package/dist/src/mcp/mcp-config-manager.js +1183 -1331
- package/dist/src/mcp/mcp-server-novice-simplified.js +11 -17
- package/dist/src/mcp/mcp-server-novice.js +11 -17
- package/dist/src/mcp/mcp-server-sdk.js +11 -17
- package/dist/src/mcp/mcp-server.js +1620 -1484
- package/dist/src/mcp/ruv-swarm-wrapper.js +209 -239
- package/dist/src/memory/advanced-serializer.js +609 -589
- package/dist/src/memory/enhanced-examples.js +220 -305
- package/dist/src/memory/enhanced-memory.js +295 -336
- package/dist/src/memory/enhanced-session-serializer.js +408 -492
- package/dist/src/memory/fallback-memory-system.js +900 -1021
- package/dist/src/memory/fallback-store.js +93 -131
- package/dist/src/memory/high-performance-serialization.js +592 -730
- package/dist/src/memory/in-memory-store.js +161 -213
- package/dist/src/memory/index.js +123 -157
- package/dist/src/memory/lock-free-structures.js +578 -764
- package/dist/src/memory/memory-mapped-persistence.js +585 -766
- package/dist/src/memory/memory-pressure-manager.js +569 -707
- package/dist/src/memory/migration.js +358 -445
- package/dist/src/memory/shared-memory.js +641 -768
- package/dist/src/memory/sqlite-store.js +245 -325
- package/dist/src/memory/sqlite-wrapper.js +122 -151
- package/dist/src/memory/swarm-memory.js +470 -603
- package/dist/src/memory/test-example.js +126 -134
- package/dist/src/memory/ultra-fast-memory-store.js +622 -821
- package/dist/src/memory/unified-memory-manager.js +356 -437
- package/dist/src/migration/index.js +92 -0
- package/dist/src/migration/logger.js +121 -0
- package/dist/src/migration/migration-analyzer.js +268 -0
- package/dist/src/migration/migration-runner.js +522 -0
- package/dist/src/migration/migration-validator.js +285 -0
- package/dist/src/migration/progress-reporter.js +150 -0
- package/dist/src/migration/rollback-manager.js +321 -0
- package/dist/src/migration/tests/migration-system.test.js +7 -0
- package/dist/src/migration/types.js +3 -0
- package/dist/src/swarm/CodeRefactoringSwarm.js +777 -952
- package/dist/src/swarm/__tests__/integration.test.js +227 -0
- package/dist/src/swarm/__tests__/prompt-copier.test.js +344 -0
- package/dist/src/swarm/advanced-orchestrator.js +1095 -0
- package/dist/src/swarm/claude-code-interface.js +961 -0
- package/dist/src/swarm/claude-flow-executor.js +229 -0
- package/dist/src/swarm/consensus-coordinator.js +475 -0
- package/dist/src/swarm/coordinator.js +2993 -0
- package/dist/src/swarm/direct-executor.js +1180 -0
- package/dist/src/swarm/error-recovery/advanced-error-detection.js +691 -0
- package/dist/src/swarm/error-recovery/automated-recovery-workflows.js +998 -0
- package/dist/src/swarm/error-recovery/error-recovery-coordinator.js +1197 -0
- package/dist/src/swarm/error-recovery/recovery-monitoring.js +772 -0
- package/dist/src/swarm/error-recovery/resilience-architecture.js +714 -0
- package/dist/src/swarm/error-recovery/self-healing-mechanisms.js +1319 -0
- package/dist/src/swarm/error-recovery/test-error-recovery-effectiveness.js +808 -0
- package/dist/src/swarm/executor-v2.js +322 -0
- package/dist/src/swarm/executor.js +815 -0
- package/dist/src/swarm/hive-mind-integration.js +703 -0
- package/dist/src/swarm/index.js +41 -0
- package/dist/src/swarm/json-output-aggregator.js +267 -0
- package/dist/src/swarm/large-scale-coordinator.js +542 -0
- package/dist/src/swarm/mcp-integration-wrapper.js +628 -0
- package/dist/src/swarm/memory.js +1117 -0
- package/dist/src/swarm/optimizations/__tests__/optimization.test.js +348 -0
- package/dist/src/swarm/optimizations/async-file-manager.js +285 -0
- package/dist/src/swarm/optimizations/circular-buffer.js +162 -0
- package/dist/src/swarm/optimizations/connection-pool.js +244 -0
- package/dist/src/swarm/optimizations/index.js +28 -0
- package/dist/src/swarm/optimizations/optimized-executor.js +320 -0
- package/dist/src/swarm/optimizations/ttl-map.js +234 -0
- package/dist/src/swarm/prompt-cli.js +200 -0
- package/dist/src/swarm/prompt-copier-enhanced.js +202 -0
- package/dist/src/swarm/prompt-copier.js +381 -0
- package/dist/src/swarm/prompt-manager.js +295 -0
- package/dist/src/swarm/prompt-utils.js +310 -0
- package/dist/src/swarm/result-aggregator.js +718 -0
- package/dist/src/swarm/sparc-executor.js +1568 -0
- package/dist/src/swarm/strategies/auto.js +758 -0
- package/dist/src/swarm/strategies/base.js +128 -0
- package/dist/src/swarm/strategies/research.js +914 -0
- package/dist/src/swarm/strategies/strategy-metrics-patch.js +2 -0
- package/dist/src/swarm/types.js +52 -0
- package/dist/src/swarm/workers/copy-worker.js +56 -0
- package/dist/src/utils/__tests__/github-cli-safety-wrapper.test.js +332 -400
- package/dist/src/utils/github-cli-safe.js +56 -64
- package/dist/src/utils/github-cli-safety-wrapper.js +451 -546
- package/dist/src/utils/npx-isolated-cache.js +104 -119
- package/dist/src/utils/preference-manager.js +622 -652
- package/dist/src/utils/timezone-utils.js +86 -105
- package/dist/src/validators/epic-config-schema.js +214 -0
- package/dist/src/validators/index.js +10 -0
- package/dist/src/validators/swarm-init-validator.js +259 -0
- package/dist/src/validators/todowrite-batching-validator.js +215 -0
- package/dist/src/validators/todowrite-integration.js +187 -0
- package/package.json +2 -2
|
@@ -1,154 +1,134 @@
|
|
|
1
1
|
// batch-init.js - Batch initialization features with parallel processing
|
|
2
|
-
import { printSuccess, printError, printWarning
|
|
3
|
-
import { promises as fs } from
|
|
4
|
-
import { cwd
|
|
5
|
-
import process from
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
} from
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import { createClaudeSlashCommands } from './claude-commands/slash-commands.js';
|
|
14
|
-
import {
|
|
15
|
-
createSparcClaudeMd,
|
|
16
|
-
createFullClaudeMd,
|
|
17
|
-
createMinimalClaudeMd,
|
|
18
|
-
} from './templates/claude-md.js';
|
|
19
|
-
import { createFullMemoryBankMd, createMinimalMemoryBankMd } from './templates/memory-bank-md.js';
|
|
20
|
-
import {
|
|
21
|
-
createFullCoordinationMd,
|
|
22
|
-
createMinimalCoordinationMd,
|
|
23
|
-
} from './templates/coordination-md.js';
|
|
24
|
-
import { createAgentsReadme, createSessionsReadme } from './templates/readme-files.js';
|
|
25
|
-
|
|
2
|
+
import { printSuccess, printError, printWarning } from "../../utils.js";
|
|
3
|
+
import { promises as fs } from "fs";
|
|
4
|
+
import { cwd } from "../../node-compat.js";
|
|
5
|
+
import process from "process";
|
|
6
|
+
import { PerformanceMonitor, ResourceThresholdMonitor, BatchOptimizer } from "./performance-monitor.js";
|
|
7
|
+
import { createSparcStructureManually } from "./sparc-structure.js";
|
|
8
|
+
import { createClaudeSlashCommands } from "./claude-commands/slash-commands.js";
|
|
9
|
+
import { createSparcClaudeMd, createFullClaudeMd, createMinimalClaudeMd } from "./templates/claude-md.js";
|
|
10
|
+
import { createFullMemoryBankMd, createMinimalMemoryBankMd } from "./templates/memory-bank-md.js";
|
|
11
|
+
import { createFullCoordinationMd, createMinimalCoordinationMd } from "./templates/coordination-md.js";
|
|
12
|
+
import { createAgentsReadme, createSessionsReadme } from "./templates/readme-files.js";
|
|
26
13
|
// Progress tracking for batch operations
|
|
27
|
-
class BatchProgressTracker {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
this.failed = 0;
|
|
32
|
-
this.inProgress = new Map();
|
|
33
|
-
this.startTime = Date.now();
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
startProject(projectName) {
|
|
37
|
-
this.inProgress.set(projectName, Date.now());
|
|
38
|
-
this.updateDisplay();
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
completeProject(projectName, success = true) {
|
|
42
|
-
this.inProgress.delete(projectName);
|
|
43
|
-
if (success) {
|
|
44
|
-
this.completed++;
|
|
45
|
-
} else {
|
|
46
|
-
this.failed++;
|
|
14
|
+
let BatchProgressTracker = class BatchProgressTracker {
|
|
15
|
+
startProject(projectName) {
|
|
16
|
+
this.inProgress.set(projectName, Date.now());
|
|
17
|
+
this.updateDisplay();
|
|
47
18
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
console.log('🚀 Batch Initialization Progress');
|
|
57
|
-
console.log('================================');
|
|
58
|
-
console.log(`Total Projects: ${this.totalProjects}`);
|
|
59
|
-
console.log(`Completed: ${this.completed} ✅`);
|
|
60
|
-
console.log(`Failed: ${this.failed} ❌`);
|
|
61
|
-
console.log(`In Progress: ${this.inProgress.size} 🔄`);
|
|
62
|
-
console.log(`Progress: ${progress}% [${this.getProgressBar(progress)}]`);
|
|
63
|
-
console.log(`Elapsed Time: ${elapsed}s`);
|
|
64
|
-
|
|
65
|
-
if (this.inProgress.size > 0) {
|
|
66
|
-
console.log('\nActive Projects:');
|
|
67
|
-
for (const [project, startTime] of this.inProgress) {
|
|
68
|
-
const projectElapsed = Math.floor((Date.now() - startTime) / 1000);
|
|
69
|
-
console.log(` - ${project} (${projectElapsed}s)`);
|
|
70
|
-
}
|
|
19
|
+
completeProject(projectName, success = true) {
|
|
20
|
+
this.inProgress.delete(projectName);
|
|
21
|
+
if (success) {
|
|
22
|
+
this.completed++;
|
|
23
|
+
} else {
|
|
24
|
+
this.failed++;
|
|
25
|
+
}
|
|
26
|
+
this.updateDisplay();
|
|
71
27
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}
|
|
92
|
-
|
|
28
|
+
updateDisplay() {
|
|
29
|
+
const elapsed = Math.floor((Date.now() - this.startTime) / 1000);
|
|
30
|
+
const progress = Math.floor((this.completed + this.failed) / this.totalProjects * 100);
|
|
31
|
+
console.clear();
|
|
32
|
+
console.log('🚀 Batch Initialization Progress');
|
|
33
|
+
console.log('================================');
|
|
34
|
+
console.log(`Total Projects: ${this.totalProjects}`);
|
|
35
|
+
console.log(`Completed: ${this.completed} ✅`);
|
|
36
|
+
console.log(`Failed: ${this.failed} ❌`);
|
|
37
|
+
console.log(`In Progress: ${this.inProgress.size} 🔄`);
|
|
38
|
+
console.log(`Progress: ${progress}% [${this.getProgressBar(progress)}]`);
|
|
39
|
+
console.log(`Elapsed Time: ${elapsed}s`);
|
|
40
|
+
if (this.inProgress.size > 0) {
|
|
41
|
+
console.log('\nActive Projects:');
|
|
42
|
+
for (const [project, startTime] of this.inProgress){
|
|
43
|
+
const projectElapsed = Math.floor((Date.now() - startTime) / 1000);
|
|
44
|
+
console.log(` - ${project} (${projectElapsed}s)`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
getProgressBar(progress) {
|
|
49
|
+
const filled = Math.floor(progress / 5);
|
|
50
|
+
const empty = 20 - filled;
|
|
51
|
+
return '█'.repeat(filled) + '░'.repeat(empty);
|
|
52
|
+
}
|
|
53
|
+
getReport() {
|
|
54
|
+
const elapsed = Math.floor((Date.now() - this.startTime) / 1000);
|
|
55
|
+
return {
|
|
56
|
+
total: this.totalProjects,
|
|
57
|
+
completed: this.completed,
|
|
58
|
+
failed: this.failed,
|
|
59
|
+
elapsedTime: elapsed,
|
|
60
|
+
successRate: this.totalProjects > 0 ? (this.completed / this.totalProjects * 100).toFixed(1) : 0
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
constructor(totalProjects){
|
|
64
|
+
this.totalProjects = totalProjects;
|
|
65
|
+
this.completed = 0;
|
|
66
|
+
this.failed = 0;
|
|
67
|
+
this.inProgress = new Map();
|
|
68
|
+
this.startTime = Date.now();
|
|
69
|
+
}
|
|
70
|
+
};
|
|
93
71
|
// Resource management to prevent overload
|
|
94
|
-
class ResourceManager {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
async acquire() {
|
|
103
|
-
while (this.currentTasks >= this.maxConcurrency) {
|
|
104
|
-
await new Promise((resolve) => {
|
|
105
|
-
this.queue.push(resolve);
|
|
106
|
-
});
|
|
72
|
+
let ResourceManager = class ResourceManager {
|
|
73
|
+
async acquire() {
|
|
74
|
+
while(this.currentTasks >= this.maxConcurrency){
|
|
75
|
+
await new Promise((resolve)=>{
|
|
76
|
+
this.queue.push(resolve);
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
this.currentTasks++;
|
|
107
80
|
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
const resolve = this.queue.shift();
|
|
115
|
-
resolve();
|
|
81
|
+
release() {
|
|
82
|
+
this.currentTasks--;
|
|
83
|
+
if (this.queue.length > 0) {
|
|
84
|
+
const resolve = this.queue.shift();
|
|
85
|
+
resolve();
|
|
86
|
+
}
|
|
116
87
|
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
this.release();
|
|
88
|
+
async withResource(fn) {
|
|
89
|
+
await this.acquire();
|
|
90
|
+
try {
|
|
91
|
+
return await fn();
|
|
92
|
+
} finally{
|
|
93
|
+
this.release();
|
|
94
|
+
}
|
|
125
95
|
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
96
|
+
constructor(maxConcurrency = 5, maxMemoryMB = 1024){
|
|
97
|
+
this.maxConcurrency = maxConcurrency;
|
|
98
|
+
this.maxMemoryMB = maxMemoryMB;
|
|
99
|
+
this.currentTasks = 0;
|
|
100
|
+
this.queue = [];
|
|
101
|
+
}
|
|
102
|
+
};
|
|
129
103
|
// Project template definitions
|
|
130
104
|
const PROJECT_TEMPLATES = {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
105
|
+
'web-api': {
|
|
106
|
+
name: 'Web API',
|
|
107
|
+
description: 'RESTful API with Express.js',
|
|
108
|
+
extraDirs: [
|
|
109
|
+
'src',
|
|
110
|
+
'src/controllers',
|
|
111
|
+
'src/models',
|
|
112
|
+
'src/routes',
|
|
113
|
+
'tests'
|
|
114
|
+
],
|
|
115
|
+
extraFiles: {
|
|
116
|
+
'package.json': {
|
|
117
|
+
name: '{{PROJECT_NAME}}',
|
|
118
|
+
version: '1.0.0',
|
|
119
|
+
type: 'module',
|
|
120
|
+
scripts: {
|
|
121
|
+
start: 'node src/index.js',
|
|
122
|
+
dev: 'nodemon src/index.js',
|
|
123
|
+
test: 'jest'
|
|
124
|
+
},
|
|
125
|
+
dependencies: {
|
|
126
|
+
express: '^4.18.0',
|
|
127
|
+
cors: '^2.8.5',
|
|
128
|
+
dotenv: '^16.0.0'
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
'src/index.js': `import express from 'express';
|
|
152
132
|
import cors from 'cors';
|
|
153
133
|
|
|
154
134
|
const app = express();
|
|
@@ -164,51 +144,65 @@ app.get('/', (req, res) => {
|
|
|
164
144
|
app.listen(PORT, () => {
|
|
165
145
|
console.log(\`Server running on port \${PORT}\`);
|
|
166
146
|
});
|
|
167
|
-
|
|
147
|
+
`
|
|
148
|
+
}
|
|
168
149
|
},
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
150
|
+
'react-app': {
|
|
151
|
+
name: 'React Application',
|
|
152
|
+
description: 'Modern React app with TypeScript',
|
|
153
|
+
extraDirs: [
|
|
154
|
+
'src',
|
|
155
|
+
'src/components',
|
|
156
|
+
'src/hooks',
|
|
157
|
+
'src/services',
|
|
158
|
+
'public'
|
|
159
|
+
],
|
|
160
|
+
extraFiles: {
|
|
161
|
+
'package.json': {
|
|
162
|
+
name: '{{PROJECT_NAME}}',
|
|
163
|
+
version: '0.1.0',
|
|
164
|
+
private: true,
|
|
165
|
+
dependencies: {
|
|
166
|
+
react: '^18.2.0',
|
|
167
|
+
'react-dom': '^18.2.0',
|
|
168
|
+
'react-scripts': '5.0.1',
|
|
169
|
+
typescript: '^4.9.5'
|
|
170
|
+
},
|
|
171
|
+
scripts: {
|
|
172
|
+
start: 'react-scripts start',
|
|
173
|
+
build: 'react-scripts build',
|
|
174
|
+
test: 'react-scripts test'
|
|
175
|
+
}
|
|
176
|
+
},
|
|
177
|
+
'tsconfig.json': {
|
|
178
|
+
compilerOptions: {
|
|
179
|
+
target: 'es5',
|
|
180
|
+
lib: [
|
|
181
|
+
'dom',
|
|
182
|
+
'es2015'
|
|
183
|
+
],
|
|
184
|
+
jsx: 'react-jsx',
|
|
185
|
+
module: 'esnext',
|
|
186
|
+
moduleResolution: 'node',
|
|
187
|
+
strict: true,
|
|
188
|
+
esModuleInterop: true,
|
|
189
|
+
skipLibCheck: true,
|
|
190
|
+
forceConsistentCasingInFileNames: true
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
204
194
|
},
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
195
|
+
microservice: {
|
|
196
|
+
name: 'Microservice',
|
|
197
|
+
description: 'Containerized microservice with Docker',
|
|
198
|
+
extraDirs: [
|
|
199
|
+
'src',
|
|
200
|
+
'config',
|
|
201
|
+
'tests',
|
|
202
|
+
'scripts'
|
|
203
|
+
],
|
|
204
|
+
extraFiles: {
|
|
205
|
+
Dockerfile: `FROM node:18-alpine
|
|
212
206
|
WORKDIR /app
|
|
213
207
|
COPY package*.json ./
|
|
214
208
|
RUN npm ci --only=production
|
|
@@ -216,7 +210,7 @@ COPY . .
|
|
|
216
210
|
EXPOSE 8080
|
|
217
211
|
CMD ["node", "src/index.js"]
|
|
218
212
|
`,
|
|
219
|
-
|
|
213
|
+
'docker-compose.yml': `version: '3.8'
|
|
220
214
|
services:
|
|
221
215
|
{{PROJECT_NAME}}:
|
|
222
216
|
build: .
|
|
@@ -227,7 +221,7 @@ services:
|
|
|
227
221
|
- PORT=8080
|
|
228
222
|
restart: unless-stopped
|
|
229
223
|
`,
|
|
230
|
-
|
|
224
|
+
'.dockerignore': `node_modules
|
|
231
225
|
npm-debug.log
|
|
232
226
|
.env
|
|
233
227
|
.git
|
|
@@ -236,27 +230,32 @@ README.md
|
|
|
236
230
|
.DS_Store
|
|
237
231
|
coverage
|
|
238
232
|
.nyc_output
|
|
239
|
-
|
|
233
|
+
`
|
|
234
|
+
}
|
|
240
235
|
},
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
236
|
+
'cli-tool': {
|
|
237
|
+
name: 'CLI Tool',
|
|
238
|
+
description: 'Command-line interface tool',
|
|
239
|
+
extraDirs: [
|
|
240
|
+
'src',
|
|
241
|
+
'src/commands',
|
|
242
|
+
'src/utils',
|
|
243
|
+
'tests'
|
|
244
|
+
],
|
|
245
|
+
extraFiles: {
|
|
246
|
+
'package.json': {
|
|
247
|
+
name: '{{PROJECT_NAME}}',
|
|
248
|
+
version: '1.0.0',
|
|
249
|
+
type: 'module',
|
|
250
|
+
bin: {
|
|
251
|
+
'{{PROJECT_NAME}}': './src/cli.js'
|
|
252
|
+
},
|
|
253
|
+
scripts: {
|
|
254
|
+
test: 'jest',
|
|
255
|
+
lint: 'eslint src/'
|
|
256
|
+
}
|
|
257
|
+
},
|
|
258
|
+
'src/cli.js': `#!/usr/bin/env node
|
|
260
259
|
import { Command } from 'commander';
|
|
261
260
|
|
|
262
261
|
const program = new Command();
|
|
@@ -275,389 +274,324 @@ program
|
|
|
275
274
|
});
|
|
276
275
|
|
|
277
276
|
program.parse();
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
277
|
+
`
|
|
278
|
+
}
|
|
279
|
+
}
|
|
281
280
|
};
|
|
282
|
-
|
|
283
281
|
// Environment configurations
|
|
284
282
|
const ENVIRONMENT_CONFIGS = {
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
config: {
|
|
298
|
-
NODE_ENV: 'staging',
|
|
299
|
-
DEBUG: 'false',
|
|
300
|
-
LOG_LEVEL: 'info',
|
|
283
|
+
dev: {
|
|
284
|
+
name: 'development',
|
|
285
|
+
features: [
|
|
286
|
+
'debug',
|
|
287
|
+
'hot-reload',
|
|
288
|
+
'verbose-logging'
|
|
289
|
+
],
|
|
290
|
+
config: {
|
|
291
|
+
NODE_ENV: 'development',
|
|
292
|
+
DEBUG: 'true',
|
|
293
|
+
LOG_LEVEL: 'debug'
|
|
294
|
+
}
|
|
301
295
|
},
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
296
|
+
staging: {
|
|
297
|
+
name: 'staging',
|
|
298
|
+
features: [
|
|
299
|
+
'testing',
|
|
300
|
+
'monitoring'
|
|
301
|
+
],
|
|
302
|
+
config: {
|
|
303
|
+
NODE_ENV: 'staging',
|
|
304
|
+
DEBUG: 'false',
|
|
305
|
+
LOG_LEVEL: 'info'
|
|
306
|
+
}
|
|
310
307
|
},
|
|
311
|
-
|
|
308
|
+
prod: {
|
|
309
|
+
name: 'production',
|
|
310
|
+
features: [
|
|
311
|
+
'optimization',
|
|
312
|
+
'security',
|
|
313
|
+
'monitoring'
|
|
314
|
+
],
|
|
315
|
+
config: {
|
|
316
|
+
NODE_ENV: 'production',
|
|
317
|
+
DEBUG: 'false',
|
|
318
|
+
LOG_LEVEL: 'error'
|
|
319
|
+
}
|
|
320
|
+
}
|
|
312
321
|
};
|
|
313
|
-
|
|
314
322
|
// Initialize a single project with options
|
|
315
323
|
async function initializeProject(projectPath, options = {}) {
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
'.claude',
|
|
349
|
-
'.claude/commands',
|
|
350
|
-
'.claude/commands/sparc',
|
|
351
|
-
'.claude/logs',
|
|
352
|
-
];
|
|
353
|
-
|
|
354
|
-
// Add template-specific directories
|
|
355
|
-
if (template && PROJECT_TEMPLATES[template]) {
|
|
356
|
-
const templateConfig = PROJECT_TEMPLATES[template];
|
|
357
|
-
if (templateConfig.extraDirs) {
|
|
358
|
-
directories.push(...templateConfig.extraDirs);
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
// Create all directories in parallel
|
|
363
|
-
await Promise.all(directories.map((dir) => fs.mkdir(dir, { recursive: true }).catch(() => {})));
|
|
364
|
-
|
|
365
|
-
// Create configuration files in parallel
|
|
366
|
-
const fileCreationTasks = [];
|
|
367
|
-
|
|
368
|
-
// CLAUDE.md
|
|
369
|
-
const claudeMd = sparc
|
|
370
|
-
? createSparcClaudeMd()
|
|
371
|
-
: minimal
|
|
372
|
-
? createMinimalClaudeMd()
|
|
373
|
-
: createFullClaudeMd();
|
|
374
|
-
fileCreationTasks.push(fs.writeFile('CLAUDE.md', claudeMd));
|
|
375
|
-
|
|
376
|
-
// memory-bank.md
|
|
377
|
-
const memoryBankMd = minimal ? createMinimalMemoryBankMd() : createFullMemoryBankMd();
|
|
378
|
-
fileCreationTasks.push(fs.writeFile('memory-bank.md', memoryBankMd));
|
|
379
|
-
|
|
380
|
-
// coordination.md
|
|
381
|
-
const coordinationMd = minimal ? createMinimalCoordinationMd() : createFullCoordinationMd();
|
|
382
|
-
fileCreationTasks.push(fs.writeFile('coordination.md', coordinationMd));
|
|
383
|
-
|
|
384
|
-
// README files
|
|
385
|
-
fileCreationTasks.push(
|
|
386
|
-
fs.writeFile('memory/agents/README.md', createAgentsReadme()),
|
|
387
|
-
fs.writeFile('memory/sessions/README.md', createSessionsReadme()),
|
|
388
|
-
);
|
|
389
|
-
|
|
390
|
-
// Persistence database
|
|
391
|
-
const initialData = {
|
|
392
|
-
agents: [],
|
|
393
|
-
tasks: [],
|
|
394
|
-
environment: environment,
|
|
395
|
-
template: template,
|
|
396
|
-
customConfig: customConfig,
|
|
397
|
-
lastUpdated: Date.now(),
|
|
398
|
-
};
|
|
399
|
-
fileCreationTasks.push(
|
|
400
|
-
fs.writeFile('memory/claude-flow-data.json', JSON.stringify(initialData, null, 2)),
|
|
401
|
-
);
|
|
402
|
-
|
|
403
|
-
// Environment configuration
|
|
404
|
-
if (ENVIRONMENT_CONFIGS[environment]) {
|
|
405
|
-
const envConfig = ENVIRONMENT_CONFIGS[environment];
|
|
406
|
-
const envContent = Object.entries(envConfig.config)
|
|
407
|
-
.map(([key, value]) => `${key}=${value}`)
|
|
408
|
-
.join('\n');
|
|
409
|
-
fileCreationTasks.push(fs.writeFile('.env', envContent));
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
// Template-specific files
|
|
413
|
-
if (template && PROJECT_TEMPLATES[template]) {
|
|
414
|
-
const templateConfig = PROJECT_TEMPLATES[template];
|
|
415
|
-
if (templateConfig.extraFiles) {
|
|
416
|
-
for (const [filePath, content] of Object.entries(templateConfig.extraFiles)) {
|
|
417
|
-
let fileContent =
|
|
418
|
-
typeof content === 'object' ? JSON.stringify(content, null, 2) : content;
|
|
419
|
-
|
|
420
|
-
// Replace template variables
|
|
421
|
-
fileContent = fileContent
|
|
422
|
-
.replace(/{{PROJECT_NAME}}/g, projectPath.split('/').pop())
|
|
423
|
-
.replace(/{{PROJECT_DESCRIPTION}}/g, templateConfig.description)
|
|
424
|
-
.replace(/{{ENVIRONMENT}}/g, environment);
|
|
425
|
-
|
|
426
|
-
fileCreationTasks.push(fs.writeFile(filePath, fileContent));
|
|
324
|
+
const { template = null, environment = 'dev', sparc = false, minimal = false, force = false, customConfig = {} } = options;
|
|
325
|
+
try {
|
|
326
|
+
// Get absolute project path
|
|
327
|
+
const currentDir = cwd();
|
|
328
|
+
const absoluteProjectPath = projectPath.startsWith('/') ? projectPath : `${currentDir}/${projectPath}`;
|
|
329
|
+
// Create project directory
|
|
330
|
+
await fs.mkdir(absoluteProjectPath, {
|
|
331
|
+
recursive: true
|
|
332
|
+
});
|
|
333
|
+
// Change to project directory
|
|
334
|
+
const originalDir = cwd();
|
|
335
|
+
process.chdir(absoluteProjectPath);
|
|
336
|
+
// Initialize base structure
|
|
337
|
+
const directories = [
|
|
338
|
+
'memory',
|
|
339
|
+
'memory/agents',
|
|
340
|
+
'memory/sessions',
|
|
341
|
+
'coordination',
|
|
342
|
+
'coordination/memory_bank',
|
|
343
|
+
'coordination/subtasks',
|
|
344
|
+
'coordination/orchestration',
|
|
345
|
+
'.claude',
|
|
346
|
+
'.claude/commands',
|
|
347
|
+
'.claude/commands/sparc',
|
|
348
|
+
'.claude/logs'
|
|
349
|
+
];
|
|
350
|
+
// Add template-specific directories
|
|
351
|
+
if (template && PROJECT_TEMPLATES[template]) {
|
|
352
|
+
const templateConfig = PROJECT_TEMPLATES[template];
|
|
353
|
+
if (templateConfig.extraDirs) {
|
|
354
|
+
directories.push(...templateConfig.extraDirs);
|
|
355
|
+
}
|
|
427
356
|
}
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
357
|
+
// Create all directories in parallel
|
|
358
|
+
await Promise.all(directories.map((dir)=>fs.mkdir(dir, {
|
|
359
|
+
recursive: true
|
|
360
|
+
}).catch(()=>{})));
|
|
361
|
+
// Create configuration files in parallel
|
|
362
|
+
const fileCreationTasks = [];
|
|
363
|
+
// CLAUDE.md
|
|
364
|
+
const claudeMd = sparc ? createSparcClaudeMd() : minimal ? createMinimalClaudeMd() : createFullClaudeMd();
|
|
365
|
+
fileCreationTasks.push(fs.writeFile('CLAUDE.md', claudeMd));
|
|
366
|
+
// memory-bank.md
|
|
367
|
+
const memoryBankMd = minimal ? createMinimalMemoryBankMd() : createFullMemoryBankMd();
|
|
368
|
+
fileCreationTasks.push(fs.writeFile('memory-bank.md', memoryBankMd));
|
|
369
|
+
// coordination.md
|
|
370
|
+
const coordinationMd = minimal ? createMinimalCoordinationMd() : createFullCoordinationMd();
|
|
371
|
+
fileCreationTasks.push(fs.writeFile('coordination.md', coordinationMd));
|
|
372
|
+
// README files
|
|
373
|
+
fileCreationTasks.push(fs.writeFile('memory/agents/README.md', createAgentsReadme()), fs.writeFile('memory/sessions/README.md', createSessionsReadme()));
|
|
374
|
+
// Persistence database
|
|
375
|
+
const initialData = {
|
|
376
|
+
agents: [],
|
|
377
|
+
tasks: [],
|
|
378
|
+
environment: environment,
|
|
379
|
+
template: template,
|
|
380
|
+
customConfig: customConfig,
|
|
381
|
+
lastUpdated: Date.now()
|
|
382
|
+
};
|
|
383
|
+
fileCreationTasks.push(fs.writeFile('memory/claude-flow-data.json', JSON.stringify(initialData, null, 2)));
|
|
384
|
+
// Environment configuration
|
|
385
|
+
if (ENVIRONMENT_CONFIGS[environment]) {
|
|
386
|
+
const envConfig = ENVIRONMENT_CONFIGS[environment];
|
|
387
|
+
const envContent = Object.entries(envConfig.config).map(([key, value])=>`${key}=${value}`).join('\n');
|
|
388
|
+
fileCreationTasks.push(fs.writeFile('.env', envContent));
|
|
389
|
+
}
|
|
390
|
+
// Template-specific files
|
|
391
|
+
if (template && PROJECT_TEMPLATES[template]) {
|
|
392
|
+
const templateConfig = PROJECT_TEMPLATES[template];
|
|
393
|
+
if (templateConfig.extraFiles) {
|
|
394
|
+
for (const [filePath, content] of Object.entries(templateConfig.extraFiles)){
|
|
395
|
+
let fileContent = typeof content === 'object' ? JSON.stringify(content, null, 2) : content;
|
|
396
|
+
// Replace template variables
|
|
397
|
+
fileContent = fileContent.replace(/{{PROJECT_NAME}}/g, projectPath.split('/').pop()).replace(/{{PROJECT_DESCRIPTION}}/g, templateConfig.description).replace(/{{ENVIRONMENT}}/g, environment);
|
|
398
|
+
fileCreationTasks.push(fs.writeFile(filePath, fileContent));
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
// Execute all file creation tasks in parallel
|
|
403
|
+
await Promise.all(fileCreationTasks);
|
|
404
|
+
// SPARC initialization if requested
|
|
405
|
+
if (sparc) {
|
|
406
|
+
await createSparcStructureManually();
|
|
407
|
+
await createClaudeSlashCommands(projectPath);
|
|
408
|
+
}
|
|
409
|
+
// Change back to original directory
|
|
410
|
+
process.chdir(originalDir);
|
|
411
|
+
return {
|
|
412
|
+
success: true,
|
|
413
|
+
projectPath: absoluteProjectPath
|
|
414
|
+
};
|
|
415
|
+
} catch (error) {
|
|
416
|
+
return {
|
|
417
|
+
success: false,
|
|
418
|
+
projectPath,
|
|
419
|
+
error: error.message
|
|
420
|
+
};
|
|
438
421
|
}
|
|
439
|
-
|
|
440
|
-
// Change back to original directory
|
|
441
|
-
process.chdir(originalDir);
|
|
442
|
-
|
|
443
|
-
return { success: true, projectPath: absoluteProjectPath };
|
|
444
|
-
} catch (error) {
|
|
445
|
-
return { success: false, projectPath, error: error.message };
|
|
446
|
-
}
|
|
447
422
|
}
|
|
448
|
-
|
|
449
423
|
// Batch initialization with parallel processing
|
|
450
424
|
export async function batchInitCommand(projects, options = {}) {
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
force,
|
|
524
|
-
});
|
|
525
|
-
});
|
|
526
|
-
|
|
527
|
-
if (result.success) {
|
|
528
|
-
perfMonitor.recordOperation('project-init-success', { projectPath });
|
|
529
|
-
} else {
|
|
530
|
-
perfMonitor.recordError(result.error, { projectPath, template, environment: env });
|
|
425
|
+
const { parallel = true, maxConcurrency = 5, template = null, environments = [
|
|
426
|
+
'dev'
|
|
427
|
+
], sparc = false, minimal = false, force = false, progressTracking = true, performanceMonitoring = true } = options;
|
|
428
|
+
if (!projects || projects.length === 0) {
|
|
429
|
+
printError('No projects specified for batch initialization');
|
|
430
|
+
return;
|
|
431
|
+
}
|
|
432
|
+
const totalProjects = projects.length * environments.length;
|
|
433
|
+
const tracker = progressTracking ? new BatchProgressTracker(totalProjects) : null;
|
|
434
|
+
const resourceManager = new ResourceManager(parallel ? maxConcurrency : 1);
|
|
435
|
+
// Initialize performance monitoring
|
|
436
|
+
const perfMonitor = new PerformanceMonitor({
|
|
437
|
+
enabled: performanceMonitoring,
|
|
438
|
+
logLevel: 'info'
|
|
439
|
+
});
|
|
440
|
+
const resourceMonitor = new ResourceThresholdMonitor({
|
|
441
|
+
maxMemoryMB: 2048,
|
|
442
|
+
...ResourceThresholdMonitor.createDefaultCallbacks()
|
|
443
|
+
});
|
|
444
|
+
// Calculate optimal settings
|
|
445
|
+
const optimalConcurrency = BatchOptimizer.calculateOptimalConcurrency(totalProjects);
|
|
446
|
+
const timeEstimate = BatchOptimizer.estimateCompletionTime(totalProjects, options);
|
|
447
|
+
const recommendations = BatchOptimizer.generateRecommendations(totalProjects, options);
|
|
448
|
+
if (maxConcurrency > optimalConcurrency) {
|
|
449
|
+
printWarning(`Concurrency ${maxConcurrency} may be too high. Optimal: ${optimalConcurrency}`);
|
|
450
|
+
}
|
|
451
|
+
perfMonitor.start();
|
|
452
|
+
resourceMonitor.start();
|
|
453
|
+
printSuccess(`Starting batch initialization for ${projects.length} projects across ${environments.length} environments`);
|
|
454
|
+
console.log(`Template: ${template || 'default'}`);
|
|
455
|
+
console.log(`Parallelism: ${parallel ? `Yes (max ${maxConcurrency} concurrent)` : 'No'}`);
|
|
456
|
+
console.log(`SPARC: ${sparc ? 'Enabled' : 'Disabled'}\n`);
|
|
457
|
+
const results = [];
|
|
458
|
+
const initTasks = [];
|
|
459
|
+
for (const project of projects){
|
|
460
|
+
for (const env of environments){
|
|
461
|
+
const projectPath = environments.length > 1 ? `${project}-${env}` : project;
|
|
462
|
+
const initTask = async ()=>{
|
|
463
|
+
if (tracker) tracker.startProject(projectPath);
|
|
464
|
+
perfMonitor.recordOperation('project-init-start', {
|
|
465
|
+
projectPath,
|
|
466
|
+
template,
|
|
467
|
+
environment: env
|
|
468
|
+
});
|
|
469
|
+
const result = await resourceManager.withResource(async ()=>{
|
|
470
|
+
return await initializeProject(projectPath, {
|
|
471
|
+
template,
|
|
472
|
+
environment: env,
|
|
473
|
+
sparc,
|
|
474
|
+
minimal,
|
|
475
|
+
force
|
|
476
|
+
});
|
|
477
|
+
});
|
|
478
|
+
if (result.success) {
|
|
479
|
+
perfMonitor.recordOperation('project-init-success', {
|
|
480
|
+
projectPath
|
|
481
|
+
});
|
|
482
|
+
} else {
|
|
483
|
+
perfMonitor.recordError(result.error, {
|
|
484
|
+
projectPath,
|
|
485
|
+
template,
|
|
486
|
+
environment: env
|
|
487
|
+
});
|
|
488
|
+
}
|
|
489
|
+
if (tracker) tracker.completeProject(projectPath, result.success);
|
|
490
|
+
results.push(result);
|
|
491
|
+
};
|
|
492
|
+
if (parallel) {
|
|
493
|
+
initTasks.push(initTask());
|
|
494
|
+
} else {
|
|
495
|
+
await initTask();
|
|
496
|
+
}
|
|
531
497
|
}
|
|
532
|
-
|
|
533
|
-
if (tracker) tracker.completeProject(projectPath, result.success);
|
|
534
|
-
results.push(result);
|
|
535
|
-
};
|
|
536
|
-
|
|
537
|
-
if (parallel) {
|
|
538
|
-
initTasks.push(initTask());
|
|
539
|
-
} else {
|
|
540
|
-
await initTask();
|
|
541
|
-
}
|
|
542
498
|
}
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
if (parallel) {
|
|
546
|
-
await Promise.all(initTasks);
|
|
547
|
-
}
|
|
548
|
-
|
|
549
|
-
// Final report
|
|
550
|
-
console.log('\n\n📊 Batch Initialization Report');
|
|
551
|
-
console.log('================================');
|
|
552
|
-
|
|
553
|
-
if (tracker) {
|
|
554
|
-
const report = tracker.getReport();
|
|
555
|
-
console.log(`Total Projects: ${report.total}`);
|
|
556
|
-
console.log(`Successful: ${report.completed} ✅`);
|
|
557
|
-
console.log(`Failed: ${report.failed} ❌`);
|
|
558
|
-
console.log(`Success Rate: ${report.successRate}%`);
|
|
559
|
-
console.log(`Total Time: ${report.elapsedTime}s`);
|
|
560
|
-
console.log(`Average Time per Project: ${(report.elapsedTime / report.total).toFixed(1)}s`);
|
|
561
|
-
}
|
|
562
|
-
|
|
563
|
-
// List successful projects
|
|
564
|
-
const successful = results.filter((r) => r.success);
|
|
565
|
-
if (successful.length > 0) {
|
|
566
|
-
console.log('\n✅ Successfully initialized:');
|
|
567
|
-
successful.forEach((r) => console.log(` - ${r.projectPath}`));
|
|
568
|
-
}
|
|
569
|
-
|
|
570
|
-
// List failed projects
|
|
571
|
-
const failed = results.filter((r) => !r.success);
|
|
572
|
-
if (failed.length > 0) {
|
|
573
|
-
console.log('\n❌ Failed to initialize:');
|
|
574
|
-
failed.forEach((r) => console.log(` - ${r.projectPath}: ${r.error}`));
|
|
575
|
-
}
|
|
576
|
-
|
|
577
|
-
// Stop monitoring and generate performance report
|
|
578
|
-
perfMonitor.stop();
|
|
579
|
-
resourceMonitor.stop();
|
|
580
|
-
|
|
581
|
-
if (performanceMonitoring) {
|
|
582
|
-
console.log(perfMonitor.generateReport());
|
|
583
|
-
|
|
584
|
-
// Show recommendations
|
|
585
|
-
if (recommendations.length > 0) {
|
|
586
|
-
console.log('\n💡 Recommendations:');
|
|
587
|
-
recommendations.forEach((rec) => console.log(` • ${rec}`));
|
|
499
|
+
if (parallel) {
|
|
500
|
+
await Promise.all(initTasks);
|
|
588
501
|
}
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
502
|
+
// Final report
|
|
503
|
+
console.log('\n\n📊 Batch Initialization Report');
|
|
504
|
+
console.log('================================');
|
|
505
|
+
if (tracker) {
|
|
506
|
+
const report = tracker.getReport();
|
|
507
|
+
console.log(`Total Projects: ${report.total}`);
|
|
508
|
+
console.log(`Successful: ${report.completed} ✅`);
|
|
509
|
+
console.log(`Failed: ${report.failed} ❌`);
|
|
510
|
+
console.log(`Success Rate: ${report.successRate}%`);
|
|
511
|
+
console.log(`Total Time: ${report.elapsedTime}s`);
|
|
512
|
+
console.log(`Average Time per Project: ${(report.elapsedTime / report.total).toFixed(1)}s`);
|
|
513
|
+
}
|
|
514
|
+
// List successful projects
|
|
515
|
+
const successful = results.filter((r)=>r.success);
|
|
516
|
+
if (successful.length > 0) {
|
|
517
|
+
console.log('\n✅ Successfully initialized:');
|
|
518
|
+
successful.forEach((r)=>console.log(` - ${r.projectPath}`));
|
|
519
|
+
}
|
|
520
|
+
// List failed projects
|
|
521
|
+
const failed = results.filter((r)=>!r.success);
|
|
522
|
+
if (failed.length > 0) {
|
|
523
|
+
console.log('\n❌ Failed to initialize:');
|
|
524
|
+
failed.forEach((r)=>console.log(` - ${r.projectPath}: ${r.error}`));
|
|
525
|
+
}
|
|
526
|
+
// Stop monitoring and generate performance report
|
|
527
|
+
perfMonitor.stop();
|
|
528
|
+
resourceMonitor.stop();
|
|
529
|
+
if (performanceMonitoring) {
|
|
530
|
+
console.log(perfMonitor.generateReport());
|
|
531
|
+
// Show recommendations
|
|
532
|
+
if (recommendations.length > 0) {
|
|
533
|
+
console.log('\n💡 Recommendations:');
|
|
534
|
+
recommendations.forEach((rec)=>console.log(` • ${rec}`));
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
return results;
|
|
592
538
|
}
|
|
593
|
-
|
|
594
539
|
// Parse batch initialization config from file
|
|
595
540
|
export async function parseBatchConfig(configFile) {
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
541
|
+
try {
|
|
542
|
+
const content = await fs.readFile(configFile, 'utf8');
|
|
543
|
+
return JSON.parse(content);
|
|
544
|
+
} catch (error) {
|
|
545
|
+
printError(`Failed to read batch config file: ${error.message}`);
|
|
546
|
+
return null;
|
|
547
|
+
}
|
|
603
548
|
}
|
|
604
|
-
|
|
605
549
|
// Create batch initialization from config file
|
|
606
550
|
export async function batchInitFromConfig(configFile, options = {}) {
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
551
|
+
const config = await parseBatchConfig(configFile);
|
|
552
|
+
if (!config) return;
|
|
553
|
+
const { projects = [], baseOptions = {}, projectConfigs = {} } = config;
|
|
554
|
+
// Merge options with config
|
|
555
|
+
const mergedOptions = {
|
|
556
|
+
...baseOptions,
|
|
557
|
+
...options
|
|
558
|
+
};
|
|
559
|
+
// If projectConfigs are specified, use them for individual project customization
|
|
560
|
+
if (Object.keys(projectConfigs).length > 0) {
|
|
561
|
+
const results = [];
|
|
562
|
+
const resourceManager = new ResourceManager(mergedOptions.maxConcurrency || 5);
|
|
563
|
+
for (const [projectName, projectConfig] of Object.entries(projectConfigs)){
|
|
564
|
+
const projectOptions = {
|
|
565
|
+
...mergedOptions,
|
|
566
|
+
...projectConfig
|
|
567
|
+
};
|
|
568
|
+
const result = await resourceManager.withResource(async ()=>{
|
|
569
|
+
return await initializeProject(projectName, projectOptions);
|
|
570
|
+
});
|
|
571
|
+
results.push(result);
|
|
572
|
+
}
|
|
573
|
+
return results;
|
|
626
574
|
}
|
|
627
|
-
|
|
628
|
-
return
|
|
629
|
-
}
|
|
630
|
-
|
|
631
|
-
// Otherwise, use standard batch init
|
|
632
|
-
return await batchInitCommand(projects, mergedOptions);
|
|
575
|
+
// Otherwise, use standard batch init
|
|
576
|
+
return await batchInitCommand(projects, mergedOptions);
|
|
633
577
|
}
|
|
634
|
-
|
|
635
578
|
// Validation for batch operations
|
|
636
579
|
export function validateBatchOptions(options) {
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
errors.push('maxConcurrency must be between 1 and 20');
|
|
641
|
-
}
|
|
642
|
-
|
|
643
|
-
if (options.template && !PROJECT_TEMPLATES[options.template]) {
|
|
644
|
-
errors.push(
|
|
645
|
-
`Unknown template: ${options.template}. Available: ${Object.keys(PROJECT_TEMPLATES).join(', ')}`,
|
|
646
|
-
);
|
|
647
|
-
}
|
|
648
|
-
|
|
649
|
-
if (options.environments) {
|
|
650
|
-
for (const env of options.environments) {
|
|
651
|
-
if (!ENVIRONMENT_CONFIGS[env]) {
|
|
652
|
-
errors.push(
|
|
653
|
-
`Unknown environment: ${env}. Available: ${Object.keys(ENVIRONMENT_CONFIGS).join(', ')}`,
|
|
654
|
-
);
|
|
655
|
-
}
|
|
580
|
+
const errors = [];
|
|
581
|
+
if (options.maxConcurrency && (options.maxConcurrency < 1 || options.maxConcurrency > 20)) {
|
|
582
|
+
errors.push('maxConcurrency must be between 1 and 20');
|
|
656
583
|
}
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
584
|
+
if (options.template && !PROJECT_TEMPLATES[options.template]) {
|
|
585
|
+
errors.push(`Unknown template: ${options.template}. Available: ${Object.keys(PROJECT_TEMPLATES).join(', ')}`);
|
|
586
|
+
}
|
|
587
|
+
if (options.environments) {
|
|
588
|
+
for (const env of options.environments){
|
|
589
|
+
if (!ENVIRONMENT_CONFIGS[env]) {
|
|
590
|
+
errors.push(`Unknown environment: ${env}. Available: ${Object.keys(ENVIRONMENT_CONFIGS).join(', ')}`);
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
return errors;
|
|
660
595
|
}
|
|
661
|
-
|
|
662
596
|
// Export template and environment configurations for external use
|
|
663
597
|
export { PROJECT_TEMPLATES, ENVIRONMENT_CONFIGS };
|