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,371 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tests for swarm command
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { jest } from '@jest/globals';
|
|
6
|
+
import { swarmCommand } from '../swarm.js';
|
|
7
|
+
import fs from 'fs-extra';
|
|
8
|
+
import path from 'path';
|
|
9
|
+
import { spawn } from 'child_process';
|
|
10
|
+
import ora from 'ora';
|
|
11
|
+
|
|
12
|
+
jest.mock('fs-extra');
|
|
13
|
+
jest.mock('child_process');
|
|
14
|
+
jest.mock('ora');
|
|
15
|
+
|
|
16
|
+
describe('Swarm Command', () => {
|
|
17
|
+
let consoleLogSpy;
|
|
18
|
+
let consoleErrorSpy;
|
|
19
|
+
let mockSpinner;
|
|
20
|
+
let mockSpawnProcess;
|
|
21
|
+
|
|
22
|
+
beforeEach(() => {
|
|
23
|
+
consoleLogSpy = jest.spyOn(console, 'log').mockImplementation();
|
|
24
|
+
consoleErrorSpy = jest.spyOn(console, 'error').mockImplementation();
|
|
25
|
+
|
|
26
|
+
mockSpinner = {
|
|
27
|
+
start: jest.fn().mockReturnThis(),
|
|
28
|
+
succeed: jest.fn().mockReturnThis(),
|
|
29
|
+
fail: jest.fn().mockReturnThis(),
|
|
30
|
+
info: jest.fn().mockReturnThis(),
|
|
31
|
+
warn: jest.fn().mockReturnThis(),
|
|
32
|
+
text: '',
|
|
33
|
+
};
|
|
34
|
+
ora.mockReturnValue(mockSpinner);
|
|
35
|
+
|
|
36
|
+
mockSpawnProcess = {
|
|
37
|
+
stdout: { on: jest.fn() },
|
|
38
|
+
stderr: { on: jest.fn() },
|
|
39
|
+
on: jest.fn(),
|
|
40
|
+
};
|
|
41
|
+
spawn.mockReturnValue(mockSpawnProcess);
|
|
42
|
+
|
|
43
|
+
jest.clearAllMocks();
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
afterEach(() => {
|
|
47
|
+
consoleLogSpy.mockRestore();
|
|
48
|
+
consoleErrorSpy.mockRestore();
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
describe('main swarm command', () => {
|
|
52
|
+
test('should initialize swarm with objective', async () => {
|
|
53
|
+
const swarmDir = path.join(process.cwd(), '.claude', 'swarm');
|
|
54
|
+
fs.ensureDir.mockResolvedValue(undefined);
|
|
55
|
+
fs.writeJson.mockResolvedValue(undefined);
|
|
56
|
+
|
|
57
|
+
// Mock spawn process events
|
|
58
|
+
mockSpawnProcess.on.mockImplementation((event, callback) => {
|
|
59
|
+
if (event === 'close') {
|
|
60
|
+
setTimeout(() => callback(0), 100);
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
await swarmCommand(['Build a REST API'], {});
|
|
65
|
+
|
|
66
|
+
expect(mockSpinner.start).toHaveBeenCalledWith('Initializing swarm...');
|
|
67
|
+
expect(fs.ensureDir).toHaveBeenCalledWith(swarmDir);
|
|
68
|
+
|
|
69
|
+
const writeJsonCall = fs.writeJson.mock.calls[0];
|
|
70
|
+
expect(writeJsonCall[0]).toBe(path.join(swarmDir, 'swarm.json'));
|
|
71
|
+
expect(writeJsonCall[1]).toMatchObject({
|
|
72
|
+
objective: 'Build a REST API',
|
|
73
|
+
status: 'initializing',
|
|
74
|
+
topology: 'hierarchical',
|
|
75
|
+
strategy: 'adaptive',
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
test('should handle custom strategy', async () => {
|
|
80
|
+
fs.ensureDir.mockResolvedValue(undefined);
|
|
81
|
+
fs.writeJson.mockResolvedValue(undefined);
|
|
82
|
+
|
|
83
|
+
mockSpawnProcess.on.mockImplementation((event, callback) => {
|
|
84
|
+
if (event === 'close') callback(0);
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
await swarmCommand(['Research task'], { strategy: 'research' });
|
|
88
|
+
|
|
89
|
+
const writeJsonCall = fs.writeJson.mock.calls[0];
|
|
90
|
+
expect(writeJsonCall[1].strategy).toBe('research');
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
test('should handle custom topology mode', async () => {
|
|
94
|
+
fs.ensureDir.mockResolvedValue(undefined);
|
|
95
|
+
fs.writeJson.mockResolvedValue(undefined);
|
|
96
|
+
|
|
97
|
+
mockSpawnProcess.on.mockImplementation((event, callback) => {
|
|
98
|
+
if (event === 'close') callback(0);
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
await swarmCommand(['Task'], { mode: 'mesh' });
|
|
102
|
+
|
|
103
|
+
const writeJsonCall = fs.writeJson.mock.calls[0];
|
|
104
|
+
expect(writeJsonCall[1].topology).toBe('mesh');
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
test('should set max agents', async () => {
|
|
108
|
+
fs.ensureDir.mockResolvedValue(undefined);
|
|
109
|
+
fs.writeJson.mockResolvedValue(undefined);
|
|
110
|
+
|
|
111
|
+
mockSpawnProcess.on.mockImplementation((event, callback) => {
|
|
112
|
+
if (event === 'close') callback(0);
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
await swarmCommand(['Task'], { 'max-agents': '10' });
|
|
116
|
+
|
|
117
|
+
const writeJsonCall = fs.writeJson.mock.calls[0];
|
|
118
|
+
expect(writeJsonCall[1].maxAgents).toBe(10);
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
test('should enable parallel execution', async () => {
|
|
122
|
+
fs.ensureDir.mockResolvedValue(undefined);
|
|
123
|
+
fs.writeJson.mockResolvedValue(undefined);
|
|
124
|
+
|
|
125
|
+
mockSpawnProcess.on.mockImplementation((event, callback) => {
|
|
126
|
+
if (event === 'close') callback(0);
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
await swarmCommand(['Task'], { parallel: true });
|
|
130
|
+
|
|
131
|
+
const writeJsonCall = fs.writeJson.mock.calls[0];
|
|
132
|
+
expect(writeJsonCall[1].parallel).toBe(true);
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
test('should enable monitoring', async () => {
|
|
136
|
+
fs.ensureDir.mockResolvedValue(undefined);
|
|
137
|
+
fs.writeJson.mockResolvedValue(undefined);
|
|
138
|
+
|
|
139
|
+
mockSpawnProcess.on.mockImplementation((event, callback) => {
|
|
140
|
+
if (event === 'close') callback(0);
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
await swarmCommand(['Task'], { monitor: true });
|
|
144
|
+
|
|
145
|
+
expect(spawn).toHaveBeenCalledWith(
|
|
146
|
+
'npx',
|
|
147
|
+
expect.arrayContaining(['--monitor']),
|
|
148
|
+
expect.any(Object),
|
|
149
|
+
);
|
|
150
|
+
});
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
describe('swarm status', () => {
|
|
154
|
+
test('should show swarm status', async () => {
|
|
155
|
+
const mockSwarmData = {
|
|
156
|
+
id: 'swarm-123',
|
|
157
|
+
objective: 'Build API',
|
|
158
|
+
status: 'active',
|
|
159
|
+
topology: 'hierarchical',
|
|
160
|
+
agents: [
|
|
161
|
+
{ id: 'agent-1', type: 'researcher', status: 'active' },
|
|
162
|
+
{ id: 'agent-2', type: 'coder', status: 'working' },
|
|
163
|
+
],
|
|
164
|
+
metrics: {
|
|
165
|
+
startTime: new Date(Date.now() - 300000).toISOString(),
|
|
166
|
+
tasksCompleted: 15,
|
|
167
|
+
tasksInProgress: 3,
|
|
168
|
+
tasksPending: 7,
|
|
169
|
+
},
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
fs.pathExists.mockResolvedValue(true);
|
|
173
|
+
fs.readJson.mockResolvedValue(mockSwarmData);
|
|
174
|
+
|
|
175
|
+
await swarmCommand(['status'], {});
|
|
176
|
+
|
|
177
|
+
const output = consoleLogSpy.mock.calls.flat().join('\n');
|
|
178
|
+
expect(output).toContain('Swarm Status');
|
|
179
|
+
expect(output).toContain('Build API');
|
|
180
|
+
expect(output).toContain('active');
|
|
181
|
+
expect(output).toContain('hierarchical');
|
|
182
|
+
expect(output).toContain('2 agents');
|
|
183
|
+
expect(output).toContain('15 completed');
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
test('should show no active swarm message', async () => {
|
|
187
|
+
fs.pathExists.mockResolvedValue(false);
|
|
188
|
+
|
|
189
|
+
await swarmCommand(['status'], {});
|
|
190
|
+
|
|
191
|
+
expect(consoleLogSpy).toHaveBeenCalledWith(expect.stringContaining('No active swarm found'));
|
|
192
|
+
});
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
describe('swarm stop', () => {
|
|
196
|
+
test('should stop active swarm', async () => {
|
|
197
|
+
const mockSwarmData = {
|
|
198
|
+
id: 'swarm-123',
|
|
199
|
+
status: 'active',
|
|
200
|
+
agents: [{ id: 'agent-1' }, { id: 'agent-2' }],
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
fs.pathExists.mockResolvedValue(true);
|
|
204
|
+
fs.readJson.mockResolvedValue(mockSwarmData);
|
|
205
|
+
fs.writeJson.mockResolvedValue(undefined);
|
|
206
|
+
fs.remove.mockResolvedValue(undefined);
|
|
207
|
+
|
|
208
|
+
await swarmCommand(['stop'], {});
|
|
209
|
+
|
|
210
|
+
expect(mockSpinner.succeed).toHaveBeenCalledWith('Swarm stopped successfully');
|
|
211
|
+
expect(fs.remove).toHaveBeenCalledWith(
|
|
212
|
+
path.join(process.cwd(), '.claude', 'swarm', 'swarm.json'),
|
|
213
|
+
);
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
test('should handle stop with force flag', async () => {
|
|
217
|
+
fs.pathExists.mockResolvedValue(true);
|
|
218
|
+
fs.remove.mockResolvedValue(undefined);
|
|
219
|
+
|
|
220
|
+
await swarmCommand(['stop'], { force: true });
|
|
221
|
+
|
|
222
|
+
expect(fs.remove).toHaveBeenCalled();
|
|
223
|
+
expect(mockSpinner.warn).toHaveBeenCalledWith('Swarm forcefully terminated');
|
|
224
|
+
});
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
describe('swarm pause/resume', () => {
|
|
228
|
+
test('should pause active swarm', async () => {
|
|
229
|
+
const mockSwarmData = {
|
|
230
|
+
id: 'swarm-123',
|
|
231
|
+
status: 'active',
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
fs.pathExists.mockResolvedValue(true);
|
|
235
|
+
fs.readJson.mockResolvedValue(mockSwarmData);
|
|
236
|
+
fs.writeJson.mockResolvedValue(undefined);
|
|
237
|
+
|
|
238
|
+
await swarmCommand(['pause'], {});
|
|
239
|
+
|
|
240
|
+
const writeCall = fs.writeJson.mock.calls[0];
|
|
241
|
+
expect(writeCall[1].status).toBe('paused');
|
|
242
|
+
expect(mockSpinner.succeed).toHaveBeenCalledWith('Swarm paused');
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
test('should resume paused swarm', async () => {
|
|
246
|
+
const mockSwarmData = {
|
|
247
|
+
id: 'swarm-123',
|
|
248
|
+
status: 'paused',
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
fs.pathExists.mockResolvedValue(true);
|
|
252
|
+
fs.readJson.mockResolvedValue(mockSwarmData);
|
|
253
|
+
fs.writeJson.mockResolvedValue(undefined);
|
|
254
|
+
|
|
255
|
+
await swarmCommand(['resume'], {});
|
|
256
|
+
|
|
257
|
+
const writeCall = fs.writeJson.mock.calls[0];
|
|
258
|
+
expect(writeCall[1].status).toBe('active');
|
|
259
|
+
expect(mockSpinner.succeed).toHaveBeenCalledWith('Swarm resumed');
|
|
260
|
+
});
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
describe('swarm logs', () => {
|
|
264
|
+
test('should display swarm logs', async () => {
|
|
265
|
+
const mockLogs = [
|
|
266
|
+
{ timestamp: new Date().toISOString(), level: 'info', message: 'Swarm initialized' },
|
|
267
|
+
{ timestamp: new Date().toISOString(), level: 'info', message: 'Agent spawned' },
|
|
268
|
+
{ timestamp: new Date().toISOString(), level: 'error', message: 'Task failed' },
|
|
269
|
+
];
|
|
270
|
+
|
|
271
|
+
fs.pathExists.mockResolvedValue(true);
|
|
272
|
+
fs.readJson.mockResolvedValue({ logs: mockLogs });
|
|
273
|
+
|
|
274
|
+
await swarmCommand(['logs'], {});
|
|
275
|
+
|
|
276
|
+
const output = consoleLogSpy.mock.calls.flat().join('\n');
|
|
277
|
+
expect(output).toContain('Swarm Logs');
|
|
278
|
+
expect(output).toContain('Swarm initialized');
|
|
279
|
+
expect(output).toContain('Agent spawned');
|
|
280
|
+
expect(output).toContain('Task failed');
|
|
281
|
+
});
|
|
282
|
+
|
|
283
|
+
test('should filter logs by level', async () => {
|
|
284
|
+
const mockLogs = [
|
|
285
|
+
{ timestamp: new Date().toISOString(), level: 'info', message: 'Info message' },
|
|
286
|
+
{ timestamp: new Date().toISOString(), level: 'error', message: 'Error message' },
|
|
287
|
+
{ timestamp: new Date().toISOString(), level: 'debug', message: 'Debug message' },
|
|
288
|
+
];
|
|
289
|
+
|
|
290
|
+
fs.pathExists.mockResolvedValue(true);
|
|
291
|
+
fs.readJson.mockResolvedValue({ logs: mockLogs });
|
|
292
|
+
|
|
293
|
+
await swarmCommand(['logs'], { level: 'error' });
|
|
294
|
+
|
|
295
|
+
const output = consoleLogSpy.mock.calls.flat().join('\n');
|
|
296
|
+
expect(output).toContain('Error message');
|
|
297
|
+
expect(output).not.toContain('Info message');
|
|
298
|
+
expect(output).not.toContain('Debug message');
|
|
299
|
+
});
|
|
300
|
+
|
|
301
|
+
test('should tail logs', async () => {
|
|
302
|
+
const mockLogs = Array.from({ length: 50 }, (_, i) => ({
|
|
303
|
+
timestamp: new Date().toISOString(),
|
|
304
|
+
level: 'info',
|
|
305
|
+
message: `Log entry ${i + 1}`,
|
|
306
|
+
}));
|
|
307
|
+
|
|
308
|
+
fs.pathExists.mockResolvedValue(true);
|
|
309
|
+
fs.readJson.mockResolvedValue({ logs: mockLogs });
|
|
310
|
+
|
|
311
|
+
await swarmCommand(['logs'], { tail: '10' });
|
|
312
|
+
|
|
313
|
+
const output = consoleLogSpy.mock.calls.flat().join('\n');
|
|
314
|
+
expect(output).toContain('Log entry 50');
|
|
315
|
+
expect(output).toContain('Log entry 41');
|
|
316
|
+
expect(output).not.toContain('Log entry 40');
|
|
317
|
+
});
|
|
318
|
+
});
|
|
319
|
+
|
|
320
|
+
describe('error handling', () => {
|
|
321
|
+
test('should handle missing objective', async () => {
|
|
322
|
+
await swarmCommand([], {});
|
|
323
|
+
|
|
324
|
+
expect(consoleErrorSpy).toHaveBeenCalledWith(
|
|
325
|
+
expect.stringContaining('objective is required'),
|
|
326
|
+
);
|
|
327
|
+
});
|
|
328
|
+
|
|
329
|
+
test('should handle invalid strategy', async () => {
|
|
330
|
+
fs.ensureDir.mockResolvedValue(undefined);
|
|
331
|
+
fs.writeJson.mockResolvedValue(undefined);
|
|
332
|
+
|
|
333
|
+
await swarmCommand(['Task'], { strategy: 'invalid-strategy' });
|
|
334
|
+
|
|
335
|
+
expect(consoleErrorSpy).toHaveBeenCalledWith(expect.stringContaining('Invalid strategy'));
|
|
336
|
+
});
|
|
337
|
+
|
|
338
|
+
test('should handle spawn process errors', async () => {
|
|
339
|
+
fs.ensureDir.mockResolvedValue(undefined);
|
|
340
|
+
fs.writeJson.mockResolvedValue(undefined);
|
|
341
|
+
|
|
342
|
+
mockSpawnProcess.on.mockImplementation((event, callback) => {
|
|
343
|
+
if (event === 'error') callback(new Error('Spawn failed'));
|
|
344
|
+
});
|
|
345
|
+
|
|
346
|
+
await swarmCommand(['Task'], {});
|
|
347
|
+
|
|
348
|
+
expect(mockSpinner.fail).toHaveBeenCalledWith(
|
|
349
|
+
expect.stringContaining('Failed to initialize swarm'),
|
|
350
|
+
);
|
|
351
|
+
});
|
|
352
|
+
|
|
353
|
+
test('should handle file system errors', async () => {
|
|
354
|
+
fs.ensureDir.mockRejectedValue(new Error('Permission denied'));
|
|
355
|
+
|
|
356
|
+
await swarmCommand(['Task'], {});
|
|
357
|
+
|
|
358
|
+
expect(consoleErrorSpy).toHaveBeenCalledWith(expect.stringContaining('Error:'));
|
|
359
|
+
});
|
|
360
|
+
});
|
|
361
|
+
|
|
362
|
+
describe('help', () => {
|
|
363
|
+
test('should show help for invalid subcommand', async () => {
|
|
364
|
+
await swarmCommand(['invalid'], {});
|
|
365
|
+
|
|
366
|
+
const output = consoleLogSpy.mock.calls.flat().join('\n');
|
|
367
|
+
expect(output).toContain('Swarm Orchestration');
|
|
368
|
+
expect(output).toContain('USAGE:');
|
|
369
|
+
});
|
|
370
|
+
});
|
|
371
|
+
});
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
// agent.js - Agent management commands
|
|
2
|
+
import { printSuccess, printError, printWarning } from '../utils.js';
|
|
3
|
+
import { onAgentSpawn, onAgentAction } from './performance-hooks.js';
|
|
4
|
+
|
|
5
|
+
export async function agentCommand(subArgs, flags) {
|
|
6
|
+
const agentCmd = subArgs[0];
|
|
7
|
+
|
|
8
|
+
switch (agentCmd) {
|
|
9
|
+
case 'spawn':
|
|
10
|
+
await spawnAgent(subArgs, flags);
|
|
11
|
+
break;
|
|
12
|
+
|
|
13
|
+
case 'list':
|
|
14
|
+
await listAgents(subArgs, flags);
|
|
15
|
+
break;
|
|
16
|
+
|
|
17
|
+
case 'hierarchy':
|
|
18
|
+
await manageHierarchy(subArgs, flags);
|
|
19
|
+
break;
|
|
20
|
+
|
|
21
|
+
case 'network':
|
|
22
|
+
await manageNetwork(subArgs, flags);
|
|
23
|
+
break;
|
|
24
|
+
|
|
25
|
+
case 'ecosystem':
|
|
26
|
+
await manageEcosystem(subArgs, flags);
|
|
27
|
+
break;
|
|
28
|
+
|
|
29
|
+
case 'provision':
|
|
30
|
+
await provisionAgent(subArgs, flags);
|
|
31
|
+
break;
|
|
32
|
+
|
|
33
|
+
case 'terminate':
|
|
34
|
+
await terminateAgent(subArgs, flags);
|
|
35
|
+
break;
|
|
36
|
+
|
|
37
|
+
case 'info':
|
|
38
|
+
await showAgentInfo(subArgs, flags);
|
|
39
|
+
break;
|
|
40
|
+
|
|
41
|
+
default:
|
|
42
|
+
showAgentHelp();
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
async function spawnAgent(subArgs, flags) {
|
|
47
|
+
const agentType = subArgs[1] || 'general';
|
|
48
|
+
const agentName = getFlag(subArgs, '--name') || flags.name || `agent-${Date.now()}`;
|
|
49
|
+
const agentId = `${agentType}-${Date.now()}`;
|
|
50
|
+
|
|
51
|
+
printSuccess(`Spawning ${agentType} agent: ${agentName}`);
|
|
52
|
+
console.log('🤖 Agent would be created with the following configuration:');
|
|
53
|
+
console.log(` Type: ${agentType}`);
|
|
54
|
+
console.log(` Name: ${agentName}`);
|
|
55
|
+
console.log(' Capabilities: Research, Analysis, Code Generation');
|
|
56
|
+
console.log(' Status: Ready');
|
|
57
|
+
console.log('\n📋 Note: Full agent spawning requires orchestrator to be running');
|
|
58
|
+
|
|
59
|
+
// Track agent spawn for performance metrics
|
|
60
|
+
await onAgentSpawn(agentId, agentType, { name: agentName });
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
async function listAgents(subArgs, flags) {
|
|
64
|
+
printSuccess('Active agents:');
|
|
65
|
+
console.log('📋 No agents currently active (orchestrator not running)');
|
|
66
|
+
console.log('\nTo create agents:');
|
|
67
|
+
console.log(' claude-flow agent spawn researcher --name "ResearchBot"');
|
|
68
|
+
console.log(' claude-flow agent spawn coder --name "CodeBot"');
|
|
69
|
+
console.log(' claude-flow agent spawn analyst --name "DataBot"');
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
async function manageHierarchy(subArgs, flags) {
|
|
73
|
+
const hierarchyCmd = subArgs[1];
|
|
74
|
+
|
|
75
|
+
switch (hierarchyCmd) {
|
|
76
|
+
case 'create':
|
|
77
|
+
const hierarchyType = subArgs[2] || 'basic';
|
|
78
|
+
printSuccess(`Creating ${hierarchyType} agent hierarchy`);
|
|
79
|
+
console.log('🏗️ Hierarchy structure would include:');
|
|
80
|
+
console.log(' - Coordinator Agent (manages workflow)');
|
|
81
|
+
console.log(' - Specialist Agents (domain-specific tasks)');
|
|
82
|
+
console.log(' - Worker Agents (execution tasks)');
|
|
83
|
+
break;
|
|
84
|
+
|
|
85
|
+
case 'show':
|
|
86
|
+
printSuccess('Current agent hierarchy:');
|
|
87
|
+
console.log('📊 No hierarchy configured (orchestrator not running)');
|
|
88
|
+
break;
|
|
89
|
+
|
|
90
|
+
default:
|
|
91
|
+
console.log('Hierarchy commands: create, show');
|
|
92
|
+
console.log('Examples:');
|
|
93
|
+
console.log(' claude-flow agent hierarchy create enterprise');
|
|
94
|
+
console.log(' claude-flow agent hierarchy show');
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
async function manageNetwork(subArgs, flags) {
|
|
99
|
+
const networkCmd = subArgs[1];
|
|
100
|
+
|
|
101
|
+
switch (networkCmd) {
|
|
102
|
+
case 'topology':
|
|
103
|
+
printSuccess('Agent network topology:');
|
|
104
|
+
console.log('🌐 Network visualization would show agent connections');
|
|
105
|
+
break;
|
|
106
|
+
|
|
107
|
+
case 'metrics':
|
|
108
|
+
printSuccess('Network performance metrics:');
|
|
109
|
+
console.log('📈 Communication latency, throughput, reliability stats');
|
|
110
|
+
break;
|
|
111
|
+
|
|
112
|
+
default:
|
|
113
|
+
console.log('Network commands: topology, metrics');
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
async function manageEcosystem(subArgs, flags) {
|
|
118
|
+
const ecosystemCmd = subArgs[1];
|
|
119
|
+
|
|
120
|
+
switch (ecosystemCmd) {
|
|
121
|
+
case 'status':
|
|
122
|
+
printSuccess('Agent ecosystem status:');
|
|
123
|
+
console.log('🌱 Ecosystem health: Not running');
|
|
124
|
+
console.log(' Active Agents: 0');
|
|
125
|
+
console.log(' Resource Usage: 0%');
|
|
126
|
+
console.log(' Task Queue: Empty');
|
|
127
|
+
break;
|
|
128
|
+
|
|
129
|
+
case 'optimize':
|
|
130
|
+
printSuccess('Optimizing agent ecosystem...');
|
|
131
|
+
console.log('⚡ Optimization would include:');
|
|
132
|
+
console.log(' - Load balancing across agents');
|
|
133
|
+
console.log(' - Resource allocation optimization');
|
|
134
|
+
console.log(' - Communication path optimization');
|
|
135
|
+
break;
|
|
136
|
+
|
|
137
|
+
default:
|
|
138
|
+
console.log('Ecosystem commands: status, optimize');
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
async function provisionAgent(subArgs, flags) {
|
|
143
|
+
const provision = subArgs[1];
|
|
144
|
+
|
|
145
|
+
if (!provision) {
|
|
146
|
+
printError('Usage: agent provision <count>');
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
const count = parseInt(provision);
|
|
151
|
+
if (isNaN(count) || count < 1) {
|
|
152
|
+
printError('Count must be a positive number');
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
printSuccess(`Provisioning ${count} agents...`);
|
|
157
|
+
console.log('🚀 Auto-provisioning would create:');
|
|
158
|
+
for (let i = 1; i <= count; i++) {
|
|
159
|
+
console.log(` Agent ${i}: Type=general, Status=provisioning`);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
async function terminateAgent(subArgs, flags) {
|
|
164
|
+
const agentId = subArgs[1];
|
|
165
|
+
|
|
166
|
+
if (!agentId) {
|
|
167
|
+
printError('Usage: agent terminate <agent-id>');
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
printSuccess(`Terminating agent: ${agentId}`);
|
|
172
|
+
console.log('🛑 Agent would be gracefully shut down');
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
async function showAgentInfo(subArgs, flags) {
|
|
176
|
+
const agentId = subArgs[1];
|
|
177
|
+
|
|
178
|
+
if (!agentId) {
|
|
179
|
+
printError('Usage: agent info <agent-id>');
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
printSuccess(`Agent information: ${agentId}`);
|
|
184
|
+
console.log('📊 Agent details would include:');
|
|
185
|
+
console.log(' Status, capabilities, current tasks, performance metrics');
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
function getFlag(args, flagName) {
|
|
189
|
+
const index = args.indexOf(flagName);
|
|
190
|
+
return index !== -1 && index + 1 < args.length ? args[index + 1] : null;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
function showAgentHelp() {
|
|
194
|
+
console.log('Agent commands:');
|
|
195
|
+
console.log(' spawn <type> [--name <name>] Create new agent');
|
|
196
|
+
console.log(' list [--verbose] List active agents');
|
|
197
|
+
console.log(' terminate <id> Stop specific agent');
|
|
198
|
+
console.log(' info <id> Show agent details');
|
|
199
|
+
console.log(' hierarchy <create|show> Manage agent hierarchies');
|
|
200
|
+
console.log(' network <topology|metrics> Agent network operations');
|
|
201
|
+
console.log(' ecosystem <status|optimize> Ecosystem management');
|
|
202
|
+
console.log(' provision <count> Auto-provision agents');
|
|
203
|
+
console.log();
|
|
204
|
+
console.log('Agent Types:');
|
|
205
|
+
console.log(' researcher Research and information gathering');
|
|
206
|
+
console.log(' coder Code development and analysis');
|
|
207
|
+
console.log(' analyst Data analysis and insights');
|
|
208
|
+
console.log(' coordinator Task coordination and management');
|
|
209
|
+
console.log(' general Multi-purpose agent');
|
|
210
|
+
console.log();
|
|
211
|
+
console.log('Examples:');
|
|
212
|
+
console.log(' claude-flow agent spawn researcher --name "DataBot"');
|
|
213
|
+
console.log(' claude-flow agent list --verbose');
|
|
214
|
+
console.log(' claude-flow agent hierarchy create enterprise');
|
|
215
|
+
console.log(' claude-flow agent ecosystem status');
|
|
216
|
+
}
|