claude-flow-novice 1.3.0 ā 1.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-flow-novice/preferences/generation.json +147 -0
- package/.claude-flow-novice/preferences/language-configs/javascript.json +51 -0
- package/.claude-flow-novice/preferences/language-configs/python.json +50 -0
- package/.claude-flow-novice/preferences/language-configs/rust.json +237 -0
- package/.claude-flow-novice/preferences/language-configs/typescript.json +54 -0
- package/.claude-flow-novice/preferences/project-local.json +91 -0
- package/.claude-flow-novice/preferences/resource-delegation.json +120 -0
- package/.claude-flow-novice/preferences/team-shared.json +195 -0
- package/.claude-flow-novice/preferences/user-global.json +247 -0
- package/.claude-flow-novice/templates/claude-md-templates/CLAUDE-JAVASCRIPT.md +769 -0
- package/.claude-flow-novice/templates/claude-md-templates/CLAUDE-PYTHON.md +1214 -0
- package/.claude-flow-novice/templates/claude-md-templates/CLAUDE-RUST.md +475 -0
- package/.claude-flow-novice/templates/claude-md-templates/CLAUDE-TYPESCRIPT.md +851 -0
- package/.claude-flow-novice/templates/claude-md-templates/README.md +263 -0
- package/CLAUDE.md +81 -0
- package/README-NPM.md +0 -0
- package/package.json +11 -7
- package/scripts/build/README.md +167 -0
- package/scripts/build/build-config.js +27 -0
- package/scripts/build/build-prompt-copier.sh +30 -0
- package/scripts/build/performance-monitor.js +869 -0
- package/scripts/build/prepare-publish.js +150 -0
- package/scripts/build/typescript-fixer.js +621 -0
- package/scripts/build/unified-builder.sh +428 -0
- package/scripts/build/update-bin-version.js +32 -0
- package/scripts/dev/README.md +264 -0
- package/scripts/dev/claude-flow-wrapper.sh +35 -0
- package/scripts/dev/claude-monitor.py +419 -0
- package/scripts/dev/claude-sparc.sh +562 -0
- package/scripts/dev/claude-wrapper.sh +17 -0
- package/scripts/dev/demo-phase3-compliance.js +172 -0
- package/scripts/dev/demo-task-system.ts +224 -0
- package/scripts/dev/deployment-validator.js +315 -0
- package/scripts/dev/spawn-claude-terminal.sh +32 -0
- package/scripts/dev/start-portal.sh +506 -0
- package/scripts/dev/start-web-ui.js +15 -0
- package/scripts/dev/stop-portal.sh +311 -0
- package/scripts/dev/validate-examples.ts +288 -0
- package/scripts/dev/validate-phase2.cjs +451 -0
- package/scripts/dev/validate-phase2.js +785 -0
- package/scripts/dev/validate-phase3.cjs +208 -0
- package/scripts/dev/validate-security-remediation.js +1 -0
- package/scripts/legacy/README.md +272 -0
- package/scripts/legacy/batch-fix-ts.sh +54 -0
- package/scripts/legacy/build-migration.sh +105 -0
- package/scripts/legacy/build-monitor.js +209 -0
- package/scripts/legacy/build-with-filter.sh +84 -0
- package/scripts/legacy/build-workaround.sh +71 -0
- package/scripts/legacy/fix-ts-advanced.js +358 -0
- package/scripts/legacy/fix-ts-final.sh +50 -0
- package/scripts/legacy/fix-ts-targeted.sh +49 -0
- package/scripts/legacy/fix-typescript-errors.js +305 -0
- package/scripts/legacy/force-build.sh +63 -0
- package/scripts/legacy/optimize-performance.js +400 -0
- package/scripts/legacy/performance-monitor.js +263 -0
- package/scripts/legacy/performance-monitoring.js +532 -0
- package/scripts/legacy/performance-test-runner.js +645 -0
- package/scripts/legacy/quick-fix-ts.js +281 -0
- package/scripts/legacy/safe-build.sh +63 -0
- package/scripts/migration/README.md +434 -0
- package/scripts/migration/install-arm64.js +78 -0
- package/scripts/migration/install.js +83 -0
- package/scripts/migration/migrate-hooks.js +173 -0
- package/scripts/migration/migration-examples.ts +318 -0
- package/scripts/optimization/build-optimizer.js +438 -0
- package/scripts/optimization/config-validator.js +761 -0
- package/scripts/optimization/test-optimization.js +432 -0
- package/scripts/optimization/unified-activation.js +839 -0
- package/scripts/performance/ACTIVATION_COMMANDS.md +292 -0
- package/scripts/performance/sqlite-enhanced-activation.sh +583 -0
- package/scripts/performance/test-enhanced-backend.sh +504 -0
- package/scripts/performance-test-runner.js +698 -0
- package/scripts/security/README.md +339 -0
- package/scripts/security/install-git-hooks.sh +132 -0
- package/scripts/security/ruv-swarm-safe.js +74 -0
- package/scripts/test/README.md +236 -0
- package/scripts/test/check-links.ts +274 -0
- package/scripts/test/check-performance-regression.ts +168 -0
- package/scripts/test/coverage-report.ts +692 -0
- package/scripts/test/generate-swarm-tests.js +633 -0
- package/scripts/test/integration-test-validation.cjs +253 -0
- package/scripts/test/load-test-swarm.js +576 -0
- package/scripts/test/run-phase3-compliance-tests.js +427 -0
- package/scripts/test/test-batch-tasks.ts +29 -0
- package/scripts/test/test-byzantine-resolution.js +246 -0
- package/scripts/test/test-claude-spawn-options.sh +63 -0
- package/scripts/test/test-cli-wizard.js +331 -0
- package/scripts/test/test-comprehensive.js +401 -0
- package/scripts/test/test-coordination-features.ts +238 -0
- package/scripts/test/test-fallback-systems.js +276 -0
- package/scripts/test/test-init-command.ts +302 -0
- package/scripts/test/test-mcp.ts +251 -0
- package/scripts/test/test-runner.ts +568 -0
- package/scripts/test/test-swarm-integration.sh +92 -0
- package/scripts/test/test-swarm.ts +142 -0
- package/scripts/test/validation-summary.ts +408 -0
- package/scripts/utils/README.md +261 -0
- package/scripts/utils/clean-build-artifacts.sh +94 -0
- package/scripts/utils/cleanup-root.sh +69 -0
- package/scripts/utils/fix-cliffy-imports.js +307 -0
- package/scripts/utils/fix-duplicate-imports.js +114 -0
- package/scripts/utils/fix-error-handling.cjs +70 -0
- package/scripts/utils/fix-import-paths.js +104 -0
- package/scripts/utils/fix-imports.js +116 -0
- package/scripts/utils/fix-shebang.js +78 -0
- package/scripts/utils/fix-test-modules.js +27 -0
- package/scripts/utils/fix-timezone-issue-246.js +200 -0
- package/scripts/utils/fix-ts-comprehensive.py +182 -0
- package/scripts/utils/fix-ts-targeted-batch.js +250 -0
- package/scripts/utils/remove-benchmark-conflicts.sh +140 -0
- package/scripts/utils/simple-test-fixer.js +190 -0
- package/scripts/utils/validate-metrics-structure.cjs +144 -0
- package/scripts/verify-mcp-server.js +86 -0
- package/src/cli/simple-commands/__tests__/agent.test.js +291 -0
- package/src/cli/simple-commands/__tests__/memory.test.js +8 -0
- package/src/cli/simple-commands/__tests__/swarm.test.js +371 -0
- package/src/cli/simple-commands/__tests__/task.test.js +8 -0
- package/src/cli/simple-commands/agent.js +216 -0
- package/src/cli/simple-commands/analysis.js +570 -0
- package/src/cli/simple-commands/automation-executor.js +1603 -0
- package/src/cli/simple-commands/automation.js +627 -0
- package/src/cli/simple-commands/batch-manager.js +338 -0
- package/src/cli/simple-commands/claude-telemetry.js +311 -0
- package/src/cli/simple-commands/claude-track.js +102 -0
- package/src/cli/simple-commands/concurrent-display.js +348 -0
- package/src/cli/simple-commands/config.js +319 -0
- package/src/cli/simple-commands/coordination.js +307 -0
- package/src/cli/simple-commands/enhanced-ui-views.js +654 -0
- package/src/cli/simple-commands/enhanced-webui-complete.js +1038 -0
- package/src/cli/simple-commands/fix-hook-variables.js +363 -0
- package/src/cli/simple-commands/github/gh-coordinator.js +605 -0
- package/src/cli/simple-commands/github/github-api.js +624 -0
- package/src/cli/simple-commands/github/init.js +543 -0
- package/src/cli/simple-commands/github.js +377 -0
- package/src/cli/simple-commands/goal.js +145 -0
- package/src/cli/simple-commands/hive-mind/auto-save-middleware.js +311 -0
- package/src/cli/simple-commands/hive-mind/communication.js +740 -0
- package/src/cli/simple-commands/hive-mind/core.js +1031 -0
- package/src/cli/simple-commands/hive-mind/db-optimizer.js +872 -0
- package/src/cli/simple-commands/hive-mind/mcp-wrapper.js +1364 -0
- package/src/cli/simple-commands/hive-mind/memory.js +1292 -0
- package/src/cli/simple-commands/hive-mind/performance-optimizer.js +618 -0
- package/src/cli/simple-commands/hive-mind/performance-test.js +373 -0
- package/src/cli/simple-commands/hive-mind/queen.js +809 -0
- package/src/cli/simple-commands/hive-mind/session-manager.js +1223 -0
- package/src/cli/simple-commands/hive-mind-optimize.js +361 -0
- package/src/cli/simple-commands/hive-mind-wizard.js +281 -0
- package/src/cli/simple-commands/hive-mind.js +3112 -0
- package/src/cli/simple-commands/hive.js +140 -0
- package/src/cli/simple-commands/hook-safety.js +671 -0
- package/src/cli/simple-commands/hooks.js +1268 -0
- package/src/cli/simple-commands/init/.claude/checkpoints/1756224542.json +7 -0
- package/src/cli/simple-commands/init/.claude/checkpoints/1756224544.json +8 -0
- package/src/cli/simple-commands/init/README.md +106 -0
- package/src/cli/simple-commands/init/VALIDATION_ROLLBACK.md +488 -0
- package/src/cli/simple-commands/init/agent-copier.js +347 -0
- package/src/cli/simple-commands/init/batch-init.js +663 -0
- package/src/cli/simple-commands/init/claude-commands/claude-flow-commands.js +438 -0
- package/src/cli/simple-commands/init/claude-commands/optimized-claude-flow-commands.js +876 -0
- package/src/cli/simple-commands/init/claude-commands/optimized-slash-commands.js +356 -0
- package/src/cli/simple-commands/init/claude-commands/optimized-sparc-commands.js +501 -0
- package/src/cli/simple-commands/init/claude-commands/slash-commands.js +57 -0
- package/src/cli/simple-commands/init/claude-commands/sparc-commands.js +296 -0
- package/src/cli/simple-commands/init/copy-revised-templates.js +175 -0
- package/src/cli/simple-commands/init/executable-wrapper.js +122 -0
- package/src/cli/simple-commands/init/gitignore-updater.js +137 -0
- package/src/cli/simple-commands/init/help.js +110 -0
- package/src/cli/simple-commands/init/hive-mind-init.js +749 -0
- package/src/cli/simple-commands/init/index.js +1953 -0
- package/src/cli/simple-commands/init/performance-monitor.js +344 -0
- package/src/cli/simple-commands/init/rollback/backup-manager.js +542 -0
- package/src/cli/simple-commands/init/rollback/index.js +399 -0
- package/src/cli/simple-commands/init/rollback/recovery-manager.js +778 -0
- package/src/cli/simple-commands/init/rollback/rollback-executor.js +521 -0
- package/src/cli/simple-commands/init/rollback/state-tracker.js +486 -0
- package/src/cli/simple-commands/init/sparc/roo-readme.js +61 -0
- package/src/cli/simple-commands/init/sparc/roomodes-config.js +102 -0
- package/src/cli/simple-commands/init/sparc/workflows.js +40 -0
- package/src/cli/simple-commands/init/sparc-structure.js +68 -0
- package/src/cli/simple-commands/init/template-copier.js +640 -0
- package/src/cli/simple-commands/init/templates/CLAUDE.md +1185 -0
- package/src/cli/simple-commands/init/templates/CLAUDE.md.optimized +265 -0
- package/src/cli/simple-commands/init/templates/claude-flow-universal +81 -0
- package/src/cli/simple-commands/init/templates/claude-flow.bat +18 -0
- package/src/cli/simple-commands/init/templates/claude-flow.ps1 +24 -0
- package/src/cli/simple-commands/init/templates/claude-md.js +1101 -0
- package/src/cli/simple-commands/init/templates/commands/analysis/bottleneck-detect.md +162 -0
- package/src/cli/simple-commands/init/templates/commands/automation/auto-agent.md +122 -0
- package/src/cli/simple-commands/init/templates/commands/coordination/swarm-init.md +85 -0
- package/src/cli/simple-commands/init/templates/commands/github/github-swarm.md +121 -0
- package/src/cli/simple-commands/init/templates/commands/helpers/standard-checkpoint-hooks.sh +179 -0
- package/src/cli/simple-commands/init/templates/commands/hooks/notification.md +113 -0
- package/src/cli/simple-commands/init/templates/commands/hooks/post-command.md +116 -0
- package/src/cli/simple-commands/init/templates/commands/hooks/post-edit.md +117 -0
- package/src/cli/simple-commands/init/templates/commands/hooks/post-task.md +112 -0
- package/src/cli/simple-commands/init/templates/commands/hooks/pre-command.md +113 -0
- package/src/cli/simple-commands/init/templates/commands/hooks/pre-edit.md +113 -0
- package/src/cli/simple-commands/init/templates/commands/hooks/pre-search.md +112 -0
- package/src/cli/simple-commands/init/templates/commands/hooks/pre-task.md +111 -0
- package/src/cli/simple-commands/init/templates/commands/hooks/session-end.md +118 -0
- package/src/cli/simple-commands/init/templates/commands/hooks/session-restore.md +118 -0
- package/src/cli/simple-commands/init/templates/commands/hooks/session-start.md +117 -0
- package/src/cli/simple-commands/init/templates/coordination-md.js +340 -0
- package/src/cli/simple-commands/init/templates/coordination.md +16 -0
- package/src/cli/simple-commands/init/templates/enhanced-templates.js +2347 -0
- package/src/cli/simple-commands/init/templates/github-safe-enhanced.js +331 -0
- package/src/cli/simple-commands/init/templates/github-safe.js +106 -0
- package/src/cli/simple-commands/init/templates/memory-bank-md.js +259 -0
- package/src/cli/simple-commands/init/templates/memory-bank.md +16 -0
- package/src/cli/simple-commands/init/templates/readme-files.js +72 -0
- package/src/cli/simple-commands/init/templates/safe-hook-patterns.js +430 -0
- package/src/cli/simple-commands/init/templates/settings.json +109 -0
- package/src/cli/simple-commands/init/templates/settings.json.enhanced +35 -0
- package/src/cli/simple-commands/init/templates/sparc-modes.js +1401 -0
- package/src/cli/simple-commands/init/templates/verification-claude-md.js +432 -0
- package/src/cli/simple-commands/init/validation/config-validator.js +354 -0
- package/src/cli/simple-commands/init/validation/health-checker.js +599 -0
- package/src/cli/simple-commands/init/validation/index.js +388 -0
- package/src/cli/simple-commands/init/validation/mode-validator.js +387 -0
- package/src/cli/simple-commands/init/validation/post-init-validator.js +390 -0
- package/src/cli/simple-commands/init/validation/pre-init-validator.js +290 -0
- package/src/cli/simple-commands/init/validation/test-runner.js +488 -0
- package/src/cli/simple-commands/init.js +4 -0
- package/src/cli/simple-commands/mcp-health.js +163 -0
- package/src/cli/simple-commands/mcp-integration-layer.js +689 -0
- package/src/cli/simple-commands/mcp.js +420 -0
- package/src/cli/simple-commands/memory-consolidation.js +631 -0
- package/src/cli/simple-commands/memory.js +345 -0
- package/src/cli/simple-commands/migrate-hooks.js +63 -0
- package/src/cli/simple-commands/monitor.js +417 -0
- package/src/cli/simple-commands/neural.js +148 -0
- package/src/cli/simple-commands/pair-autofix-only.js +755 -0
- package/src/cli/simple-commands/pair-basic.js +751 -0
- package/src/cli/simple-commands/pair-old.js +623 -0
- package/src/cli/simple-commands/pair-working.js +849 -0
- package/src/cli/simple-commands/pair.js +849 -0
- package/src/cli/simple-commands/performance-hooks.js +149 -0
- package/src/cli/simple-commands/performance-metrics.js +601 -0
- package/src/cli/simple-commands/process-ui-enhanced.js +821 -0
- package/src/cli/simple-commands/process-ui.js +274 -0
- package/src/cli/simple-commands/realtime-update-system.js +659 -0
- package/src/cli/simple-commands/sparc/architecture.js +1750 -0
- package/src/cli/simple-commands/sparc/commands.js +575 -0
- package/src/cli/simple-commands/sparc/completion.js +1831 -0
- package/src/cli/simple-commands/sparc/coordinator.js +1045 -0
- package/src/cli/simple-commands/sparc/index.js +321 -0
- package/src/cli/simple-commands/sparc/phase-base.js +430 -0
- package/src/cli/simple-commands/sparc/pseudocode.js +984 -0
- package/src/cli/simple-commands/sparc/refinement.js +1856 -0
- package/src/cli/simple-commands/sparc/specification.js +736 -0
- package/src/cli/simple-commands/sparc-modes/architect.js +125 -0
- package/src/cli/simple-commands/sparc-modes/ask.js +126 -0
- package/src/cli/simple-commands/sparc-modes/code.js +148 -0
- package/src/cli/simple-commands/sparc-modes/debug.js +112 -0
- package/src/cli/simple-commands/sparc-modes/devops.js +137 -0
- package/src/cli/simple-commands/sparc-modes/docs-writer.js +38 -0
- package/src/cli/simple-commands/sparc-modes/generic.js +34 -0
- package/src/cli/simple-commands/sparc-modes/index.js +201 -0
- package/src/cli/simple-commands/sparc-modes/integration.js +55 -0
- package/src/cli/simple-commands/sparc-modes/mcp.js +38 -0
- package/src/cli/simple-commands/sparc-modes/monitoring.js +38 -0
- package/src/cli/simple-commands/sparc-modes/optimization.js +38 -0
- package/src/cli/simple-commands/sparc-modes/security-review.js +130 -0
- package/src/cli/simple-commands/sparc-modes/sparc-orchestrator.js +167 -0
- package/src/cli/simple-commands/sparc-modes/spec-pseudocode.js +38 -0
- package/src/cli/simple-commands/sparc-modes/supabase-admin.js +149 -0
- package/src/cli/simple-commands/sparc-modes/swarm.js +436 -0
- package/src/cli/simple-commands/sparc-modes/tdd.js +112 -0
- package/src/cli/simple-commands/sparc-modes/tutorial.js +277 -0
- package/src/cli/simple-commands/sparc.js +530 -0
- package/src/cli/simple-commands/start-ui.js +147 -0
- package/src/cli/simple-commands/start-wrapper.js +285 -0
- package/src/cli/simple-commands/start.js +2 -0
- package/src/cli/simple-commands/status.js +303 -0
- package/src/cli/simple-commands/stream-chain-clean.js +221 -0
- package/src/cli/simple-commands/stream-chain-fixed.js +89 -0
- package/src/cli/simple-commands/stream-chain-real.js +408 -0
- package/src/cli/simple-commands/stream-chain-working.js +323 -0
- package/src/cli/simple-commands/stream-chain.js +491 -0
- package/src/cli/simple-commands/stream-processor.js +340 -0
- package/src/cli/simple-commands/swarm-executor.js +253 -0
- package/src/cli/simple-commands/swarm-metrics-integration.js +371 -0
- package/src/cli/simple-commands/swarm-ui.js +741 -0
- package/src/cli/simple-commands/swarm-webui-integration.js +311 -0
- package/src/cli/simple-commands/swarm.js +2277 -0
- package/src/cli/simple-commands/task.js +228 -0
- package/src/cli/simple-commands/templates/mle-star-workflow.json +294 -0
- package/src/cli/simple-commands/timestamp-fix.js +104 -0
- package/src/cli/simple-commands/token-tracker.js +372 -0
- package/src/cli/simple-commands/tool-execution-framework.js +555 -0
- package/src/cli/simple-commands/train-and-stream.js +354 -0
- package/src/cli/simple-commands/training-pipeline.js +874 -0
- package/src/cli/simple-commands/training.js +288 -0
- package/src/cli/simple-commands/verification-hooks.js +336 -0
- package/src/cli/simple-commands/verification-integration.js +464 -0
- package/src/cli/simple-commands/verification-training-integration.js +646 -0
- package/src/cli/simple-commands/verification.js +551 -0
- package/src/cli/simple-commands/web-server.js +929 -0
- package/src/cli/simple-commands/webui-validator.js +136 -0
- package/src/language/README.md +503 -0
- package/src/language/claude-md-generator.js +618 -0
- package/src/language/cli.js +422 -0
- package/src/language/example.js +347 -0
- package/src/language/integration-system.js +619 -0
- package/src/language/language-detector.js +581 -0
|
@@ -0,0 +1,663 @@
|
|
|
1
|
+
// batch-init.js - Batch initialization features with parallel processing
|
|
2
|
+
import { printSuccess, printError, printWarning, printInfo } from '../../utils.js';
|
|
3
|
+
import { promises as fs } from 'fs';
|
|
4
|
+
import { cwd, exit, existsSync } from '../../node-compat.js';
|
|
5
|
+
import process from 'process';
|
|
6
|
+
import {
|
|
7
|
+
PerformanceMonitor,
|
|
8
|
+
ResourceThresholdMonitor,
|
|
9
|
+
BatchOptimizer,
|
|
10
|
+
} from './performance-monitor.js';
|
|
11
|
+
import { initCommand } from './index.js';
|
|
12
|
+
import { createSparcStructureManually } from './sparc-structure.js';
|
|
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
|
+
|
|
26
|
+
// Progress tracking for batch operations
|
|
27
|
+
class BatchProgressTracker {
|
|
28
|
+
constructor(totalProjects) {
|
|
29
|
+
this.totalProjects = totalProjects;
|
|
30
|
+
this.completed = 0;
|
|
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++;
|
|
47
|
+
}
|
|
48
|
+
this.updateDisplay();
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
updateDisplay() {
|
|
52
|
+
const elapsed = Math.floor((Date.now() - this.startTime) / 1000);
|
|
53
|
+
const progress = Math.floor(((this.completed + this.failed) / this.totalProjects) * 100);
|
|
54
|
+
|
|
55
|
+
console.clear();
|
|
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
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
getProgressBar(progress) {
|
|
75
|
+
const filled = Math.floor(progress / 5);
|
|
76
|
+
const empty = 20 - filled;
|
|
77
|
+
return 'ā'.repeat(filled) + 'ā'.repeat(empty);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
getReport() {
|
|
81
|
+
const elapsed = Math.floor((Date.now() - this.startTime) / 1000);
|
|
82
|
+
return {
|
|
83
|
+
total: this.totalProjects,
|
|
84
|
+
completed: this.completed,
|
|
85
|
+
failed: this.failed,
|
|
86
|
+
elapsedTime: elapsed,
|
|
87
|
+
successRate:
|
|
88
|
+
this.totalProjects > 0 ? ((this.completed / this.totalProjects) * 100).toFixed(1) : 0,
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// Resource management to prevent overload
|
|
94
|
+
class ResourceManager {
|
|
95
|
+
constructor(maxConcurrency = 5, maxMemoryMB = 1024) {
|
|
96
|
+
this.maxConcurrency = maxConcurrency;
|
|
97
|
+
this.maxMemoryMB = maxMemoryMB;
|
|
98
|
+
this.currentTasks = 0;
|
|
99
|
+
this.queue = [];
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
async acquire() {
|
|
103
|
+
while (this.currentTasks >= this.maxConcurrency) {
|
|
104
|
+
await new Promise((resolve) => {
|
|
105
|
+
this.queue.push(resolve);
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
this.currentTasks++;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
release() {
|
|
112
|
+
this.currentTasks--;
|
|
113
|
+
if (this.queue.length > 0) {
|
|
114
|
+
const resolve = this.queue.shift();
|
|
115
|
+
resolve();
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
async withResource(fn) {
|
|
120
|
+
await this.acquire();
|
|
121
|
+
try {
|
|
122
|
+
return await fn();
|
|
123
|
+
} finally {
|
|
124
|
+
this.release();
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// Project template definitions
|
|
130
|
+
const PROJECT_TEMPLATES = {
|
|
131
|
+
'web-api': {
|
|
132
|
+
name: 'Web API',
|
|
133
|
+
description: 'RESTful API with Express.js',
|
|
134
|
+
extraDirs: ['src', 'src/controllers', 'src/models', 'src/routes', 'tests'],
|
|
135
|
+
extraFiles: {
|
|
136
|
+
'package.json': {
|
|
137
|
+
name: '{{PROJECT_NAME}}',
|
|
138
|
+
version: '1.0.0',
|
|
139
|
+
type: 'module',
|
|
140
|
+
scripts: {
|
|
141
|
+
start: 'node src/index.js',
|
|
142
|
+
dev: 'nodemon src/index.js',
|
|
143
|
+
test: 'jest',
|
|
144
|
+
},
|
|
145
|
+
dependencies: {
|
|
146
|
+
express: '^4.18.0',
|
|
147
|
+
cors: '^2.8.5',
|
|
148
|
+
dotenv: '^16.0.0',
|
|
149
|
+
},
|
|
150
|
+
},
|
|
151
|
+
'src/index.js': `import express from 'express';
|
|
152
|
+
import cors from 'cors';
|
|
153
|
+
|
|
154
|
+
const app = express();
|
|
155
|
+
const PORT = process.env.PORT || 3000;
|
|
156
|
+
|
|
157
|
+
app.use(cors());
|
|
158
|
+
app.use(express.json());
|
|
159
|
+
|
|
160
|
+
app.get('/', (req, res) => {
|
|
161
|
+
res.json({ message: 'Welcome to {{PROJECT_NAME}} API' });
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
app.listen(PORT, () => {
|
|
165
|
+
console.log(\`Server running on port \${PORT}\`);
|
|
166
|
+
});
|
|
167
|
+
`,
|
|
168
|
+
},
|
|
169
|
+
},
|
|
170
|
+
'react-app': {
|
|
171
|
+
name: 'React Application',
|
|
172
|
+
description: 'Modern React app with TypeScript',
|
|
173
|
+
extraDirs: ['src', 'src/components', 'src/hooks', 'src/services', 'public'],
|
|
174
|
+
extraFiles: {
|
|
175
|
+
'package.json': {
|
|
176
|
+
name: '{{PROJECT_NAME}}',
|
|
177
|
+
version: '0.1.0',
|
|
178
|
+
private: true,
|
|
179
|
+
dependencies: {
|
|
180
|
+
react: '^18.2.0',
|
|
181
|
+
'react-dom': '^18.2.0',
|
|
182
|
+
'react-scripts': '5.0.1',
|
|
183
|
+
typescript: '^4.9.5',
|
|
184
|
+
},
|
|
185
|
+
scripts: {
|
|
186
|
+
start: 'react-scripts start',
|
|
187
|
+
build: 'react-scripts build',
|
|
188
|
+
test: 'react-scripts test',
|
|
189
|
+
},
|
|
190
|
+
},
|
|
191
|
+
'tsconfig.json': {
|
|
192
|
+
compilerOptions: {
|
|
193
|
+
target: 'es5',
|
|
194
|
+
lib: ['dom', 'es2015'],
|
|
195
|
+
jsx: 'react-jsx',
|
|
196
|
+
module: 'esnext',
|
|
197
|
+
moduleResolution: 'node',
|
|
198
|
+
strict: true,
|
|
199
|
+
esModuleInterop: true,
|
|
200
|
+
skipLibCheck: true,
|
|
201
|
+
forceConsistentCasingInFileNames: true,
|
|
202
|
+
},
|
|
203
|
+
},
|
|
204
|
+
},
|
|
205
|
+
},
|
|
206
|
+
microservice: {
|
|
207
|
+
name: 'Microservice',
|
|
208
|
+
description: 'Containerized microservice with Docker',
|
|
209
|
+
extraDirs: ['src', 'config', 'tests', 'scripts'],
|
|
210
|
+
extraFiles: {
|
|
211
|
+
Dockerfile: `FROM node:18-alpine
|
|
212
|
+
WORKDIR /app
|
|
213
|
+
COPY package*.json ./
|
|
214
|
+
RUN npm ci --only=production
|
|
215
|
+
COPY . .
|
|
216
|
+
EXPOSE 8080
|
|
217
|
+
CMD ["node", "src/index.js"]
|
|
218
|
+
`,
|
|
219
|
+
'docker-compose.yml': `version: '3.8'
|
|
220
|
+
services:
|
|
221
|
+
{{PROJECT_NAME}}:
|
|
222
|
+
build: .
|
|
223
|
+
ports:
|
|
224
|
+
- "8080:8080"
|
|
225
|
+
environment:
|
|
226
|
+
- NODE_ENV={{ENVIRONMENT}}
|
|
227
|
+
- PORT=8080
|
|
228
|
+
restart: unless-stopped
|
|
229
|
+
`,
|
|
230
|
+
'.dockerignore': `node_modules
|
|
231
|
+
npm-debug.log
|
|
232
|
+
.env
|
|
233
|
+
.git
|
|
234
|
+
.gitignore
|
|
235
|
+
README.md
|
|
236
|
+
.DS_Store
|
|
237
|
+
coverage
|
|
238
|
+
.nyc_output
|
|
239
|
+
`,
|
|
240
|
+
},
|
|
241
|
+
},
|
|
242
|
+
'cli-tool': {
|
|
243
|
+
name: 'CLI Tool',
|
|
244
|
+
description: 'Command-line interface tool',
|
|
245
|
+
extraDirs: ['src', 'src/commands', 'src/utils', 'tests'],
|
|
246
|
+
extraFiles: {
|
|
247
|
+
'package.json': {
|
|
248
|
+
name: '{{PROJECT_NAME}}',
|
|
249
|
+
version: '1.0.0',
|
|
250
|
+
type: 'module',
|
|
251
|
+
bin: {
|
|
252
|
+
'{{PROJECT_NAME}}': './src/cli.js',
|
|
253
|
+
},
|
|
254
|
+
scripts: {
|
|
255
|
+
test: 'jest',
|
|
256
|
+
lint: 'eslint src/',
|
|
257
|
+
},
|
|
258
|
+
},
|
|
259
|
+
'src/cli.js': `#!/usr/bin/env node
|
|
260
|
+
import { Command } from 'commander';
|
|
261
|
+
|
|
262
|
+
const program = new Command();
|
|
263
|
+
|
|
264
|
+
program
|
|
265
|
+
.name('{{PROJECT_NAME}}')
|
|
266
|
+
.description('{{PROJECT_DESCRIPTION}}')
|
|
267
|
+
.version('1.0.0');
|
|
268
|
+
|
|
269
|
+
program
|
|
270
|
+
.command('hello')
|
|
271
|
+
.description('Say hello')
|
|
272
|
+
.option('-n, --name <name>', 'name to greet', 'World')
|
|
273
|
+
.action((options) => {
|
|
274
|
+
console.log(\`Hello, \${options.name}!\`);
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
program.parse();
|
|
278
|
+
`,
|
|
279
|
+
},
|
|
280
|
+
},
|
|
281
|
+
};
|
|
282
|
+
|
|
283
|
+
// Environment configurations
|
|
284
|
+
const ENVIRONMENT_CONFIGS = {
|
|
285
|
+
dev: {
|
|
286
|
+
name: 'development',
|
|
287
|
+
features: ['debug', 'hot-reload', 'verbose-logging'],
|
|
288
|
+
config: {
|
|
289
|
+
NODE_ENV: 'development',
|
|
290
|
+
DEBUG: 'true',
|
|
291
|
+
LOG_LEVEL: 'debug',
|
|
292
|
+
},
|
|
293
|
+
},
|
|
294
|
+
staging: {
|
|
295
|
+
name: 'staging',
|
|
296
|
+
features: ['testing', 'monitoring'],
|
|
297
|
+
config: {
|
|
298
|
+
NODE_ENV: 'staging',
|
|
299
|
+
DEBUG: 'false',
|
|
300
|
+
LOG_LEVEL: 'info',
|
|
301
|
+
},
|
|
302
|
+
},
|
|
303
|
+
prod: {
|
|
304
|
+
name: 'production',
|
|
305
|
+
features: ['optimization', 'security', 'monitoring'],
|
|
306
|
+
config: {
|
|
307
|
+
NODE_ENV: 'production',
|
|
308
|
+
DEBUG: 'false',
|
|
309
|
+
LOG_LEVEL: 'error',
|
|
310
|
+
},
|
|
311
|
+
},
|
|
312
|
+
};
|
|
313
|
+
|
|
314
|
+
// Initialize a single project with options
|
|
315
|
+
async function initializeProject(projectPath, options = {}) {
|
|
316
|
+
const {
|
|
317
|
+
template = null,
|
|
318
|
+
environment = 'dev',
|
|
319
|
+
sparc = false,
|
|
320
|
+
minimal = false,
|
|
321
|
+
force = false,
|
|
322
|
+
customConfig = {},
|
|
323
|
+
} = options;
|
|
324
|
+
|
|
325
|
+
try {
|
|
326
|
+
// Get absolute project path
|
|
327
|
+
const currentDir = cwd();
|
|
328
|
+
const absoluteProjectPath = projectPath.startsWith('/')
|
|
329
|
+
? projectPath
|
|
330
|
+
: `${currentDir}/${projectPath}`;
|
|
331
|
+
|
|
332
|
+
// Create project directory
|
|
333
|
+
await fs.mkdir(absoluteProjectPath, { recursive: true });
|
|
334
|
+
|
|
335
|
+
// Change to project directory
|
|
336
|
+
const originalDir = cwd();
|
|
337
|
+
process.chdir(absoluteProjectPath);
|
|
338
|
+
|
|
339
|
+
// Initialize base structure
|
|
340
|
+
const directories = [
|
|
341
|
+
'memory',
|
|
342
|
+
'memory/agents',
|
|
343
|
+
'memory/sessions',
|
|
344
|
+
'coordination',
|
|
345
|
+
'coordination/memory_bank',
|
|
346
|
+
'coordination/subtasks',
|
|
347
|
+
'coordination/orchestration',
|
|
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));
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
// Execute all file creation tasks in parallel
|
|
432
|
+
await Promise.all(fileCreationTasks);
|
|
433
|
+
|
|
434
|
+
// SPARC initialization if requested
|
|
435
|
+
if (sparc) {
|
|
436
|
+
await createSparcStructureManually();
|
|
437
|
+
await createClaudeSlashCommands(projectPath);
|
|
438
|
+
}
|
|
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
|
+
}
|
|
448
|
+
|
|
449
|
+
// Batch initialization with parallel processing
|
|
450
|
+
export async function batchInitCommand(projects, options = {}) {
|
|
451
|
+
const {
|
|
452
|
+
parallel = true,
|
|
453
|
+
maxConcurrency = 5,
|
|
454
|
+
template = null,
|
|
455
|
+
environments = ['dev'],
|
|
456
|
+
sparc = false,
|
|
457
|
+
minimal = false,
|
|
458
|
+
force = false,
|
|
459
|
+
progressTracking = true,
|
|
460
|
+
performanceMonitoring = true,
|
|
461
|
+
} = options;
|
|
462
|
+
|
|
463
|
+
if (!projects || projects.length === 0) {
|
|
464
|
+
printError('No projects specified for batch initialization');
|
|
465
|
+
return;
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
const totalProjects = projects.length * environments.length;
|
|
469
|
+
const tracker = progressTracking ? new BatchProgressTracker(totalProjects) : null;
|
|
470
|
+
const resourceManager = new ResourceManager(parallel ? maxConcurrency : 1);
|
|
471
|
+
|
|
472
|
+
// Initialize performance monitoring
|
|
473
|
+
const perfMonitor = new PerformanceMonitor({
|
|
474
|
+
enabled: performanceMonitoring,
|
|
475
|
+
logLevel: 'info',
|
|
476
|
+
});
|
|
477
|
+
|
|
478
|
+
const resourceMonitor = new ResourceThresholdMonitor({
|
|
479
|
+
maxMemoryMB: 2048,
|
|
480
|
+
...ResourceThresholdMonitor.createDefaultCallbacks(),
|
|
481
|
+
});
|
|
482
|
+
|
|
483
|
+
// Calculate optimal settings
|
|
484
|
+
const optimalConcurrency = BatchOptimizer.calculateOptimalConcurrency(totalProjects);
|
|
485
|
+
const timeEstimate = BatchOptimizer.estimateCompletionTime(totalProjects, options);
|
|
486
|
+
const recommendations = BatchOptimizer.generateRecommendations(totalProjects, options);
|
|
487
|
+
|
|
488
|
+
if (maxConcurrency > optimalConcurrency) {
|
|
489
|
+
printWarning(`Concurrency ${maxConcurrency} may be too high. Optimal: ${optimalConcurrency}`);
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
perfMonitor.start();
|
|
493
|
+
resourceMonitor.start();
|
|
494
|
+
|
|
495
|
+
printSuccess(
|
|
496
|
+
`Starting batch initialization for ${projects.length} projects across ${environments.length} environments`,
|
|
497
|
+
);
|
|
498
|
+
console.log(`Template: ${template || 'default'}`);
|
|
499
|
+
console.log(`Parallelism: ${parallel ? `Yes (max ${maxConcurrency} concurrent)` : 'No'}`);
|
|
500
|
+
console.log(`SPARC: ${sparc ? 'Enabled' : 'Disabled'}\n`);
|
|
501
|
+
|
|
502
|
+
const results = [];
|
|
503
|
+
const initTasks = [];
|
|
504
|
+
|
|
505
|
+
for (const project of projects) {
|
|
506
|
+
for (const env of environments) {
|
|
507
|
+
const projectPath = environments.length > 1 ? `${project}-${env}` : project;
|
|
508
|
+
|
|
509
|
+
const initTask = async () => {
|
|
510
|
+
if (tracker) tracker.startProject(projectPath);
|
|
511
|
+
perfMonitor.recordOperation('project-init-start', {
|
|
512
|
+
projectPath,
|
|
513
|
+
template,
|
|
514
|
+
environment: env,
|
|
515
|
+
});
|
|
516
|
+
|
|
517
|
+
const result = await resourceManager.withResource(async () => {
|
|
518
|
+
return await initializeProject(projectPath, {
|
|
519
|
+
template,
|
|
520
|
+
environment: env,
|
|
521
|
+
sparc,
|
|
522
|
+
minimal,
|
|
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 });
|
|
531
|
+
}
|
|
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
|
+
}
|
|
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}`));
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
return results;
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
// Parse batch initialization config from file
|
|
595
|
+
export async function parseBatchConfig(configFile) {
|
|
596
|
+
try {
|
|
597
|
+
const content = await fs.readFile(configFile, 'utf8');
|
|
598
|
+
return JSON.parse(content);
|
|
599
|
+
} catch (error) {
|
|
600
|
+
printError(`Failed to read batch config file: ${error.message}`);
|
|
601
|
+
return null;
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
// Create batch initialization from config file
|
|
606
|
+
export async function batchInitFromConfig(configFile, options = {}) {
|
|
607
|
+
const config = await parseBatchConfig(configFile);
|
|
608
|
+
if (!config) return;
|
|
609
|
+
|
|
610
|
+
const { projects = [], baseOptions = {}, projectConfigs = {} } = config;
|
|
611
|
+
|
|
612
|
+
// Merge options with config
|
|
613
|
+
const mergedOptions = { ...baseOptions, ...options };
|
|
614
|
+
|
|
615
|
+
// If projectConfigs are specified, use them for individual project customization
|
|
616
|
+
if (Object.keys(projectConfigs).length > 0) {
|
|
617
|
+
const results = [];
|
|
618
|
+
const resourceManager = new ResourceManager(mergedOptions.maxConcurrency || 5);
|
|
619
|
+
|
|
620
|
+
for (const [projectName, projectConfig] of Object.entries(projectConfigs)) {
|
|
621
|
+
const projectOptions = { ...mergedOptions, ...projectConfig };
|
|
622
|
+
const result = await resourceManager.withResource(async () => {
|
|
623
|
+
return await initializeProject(projectName, projectOptions);
|
|
624
|
+
});
|
|
625
|
+
results.push(result);
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
return results;
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
// Otherwise, use standard batch init
|
|
632
|
+
return await batchInitCommand(projects, mergedOptions);
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
// Validation for batch operations
|
|
636
|
+
export function validateBatchOptions(options) {
|
|
637
|
+
const errors = [];
|
|
638
|
+
|
|
639
|
+
if (options.maxConcurrency && (options.maxConcurrency < 1 || options.maxConcurrency > 20)) {
|
|
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
|
+
}
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
return errors;
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
// Export template and environment configurations for external use
|
|
663
|
+
export { PROJECT_TEMPLATES, ENVIRONMENT_CONFIGS };
|