claude-flow-novice 1.1.9 → 1.2.0
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/SLASH-COMMANDS-READY.md +53 -0
- package/.claude/WORKING-SETUP.md +67 -0
- package/.claude/commands/README.md +157 -0
- package/.claude/commands/claude-md.js +237 -0
- package/.claude/commands/claude-md.md +64 -0
- package/.claude/commands/claude-soul.js +562 -0
- package/.claude/commands/claude-soul.md +22 -0
- package/.claude/commands/cli-integration.js +216 -0
- package/.claude/commands/dependency-recommendations.md +171 -0
- package/.claude/commands/github.js +638 -0
- package/.claude/commands/github.md +221 -0
- package/.claude/commands/hooks.js +648 -0
- package/.claude/commands/hooks.md +38 -0
- package/.claude/commands/index.js +115 -0
- package/.claude/commands/neural.js +572 -0
- package/.claude/commands/neural.md +39 -0
- package/.claude/commands/performance.js +582 -0
- package/.claude/commands/performance.md +41 -0
- package/.claude/commands/register-all-commands.js +314 -0
- package/.claude/commands/register-claude-md.js +82 -0
- package/.claude/commands/register-claude-soul.js +80 -0
- package/.claude/commands/sparc.js +110 -0
- package/.claude/commands/sparc.md +46 -0
- package/.claude/commands/suggest-improvements.md +95 -0
- package/.claude/commands/suggest-templates.md +147 -0
- package/.claude/commands/swarm.js +423 -0
- package/.claude/commands/swarm.md +24 -0
- package/.claude/commands/validate-commands.js +223 -0
- package/.claude/commands/workflow.js +606 -0
- package/.claude/commands/workflow.md +295 -0
- package/.claude/core/agent-manager.js +80 -0
- package/.claude/core/agent-manager.js.map +1 -0
- package/.claude/core/config.js +1221 -0
- package/.claude/core/config.js.map +1 -0
- package/.claude/core/event-bus.js +136 -0
- package/.claude/core/event-bus.js.map +1 -0
- package/.claude/core/index.js +6 -0
- package/.claude/core/index.js.map +1 -0
- package/.claude/core/json-persistence.js +112 -0
- package/.claude/core/json-persistence.js.map +1 -0
- package/.claude/core/logger.js +245 -0
- package/.claude/core/logger.js.map +1 -0
- package/.claude/core/orchestrator-fixed.js +236 -0
- package/.claude/core/orchestrator-fixed.js.map +1 -0
- package/.claude/core/orchestrator.js +1136 -0
- package/.claude/core/orchestrator.js.map +1 -0
- package/.claude/core/persistence.js +185 -0
- package/.claude/core/persistence.js.map +1 -0
- package/.claude/core/project-manager.js +80 -0
- package/.claude/core/project-manager.js.map +1 -0
- package/.claude/core/slash-command.js +24 -0
- package/.claude/core/version.js +35 -0
- package/.claude/core/version.js.map +1 -0
- package/.claude/slash-commands.json +92 -0
- package/dist/mcp/mcp-server-novice.js +14 -2
- package/dist/mcp/mcp-server-sdk.js +649 -0
- package/dist/mcp/mcp-server-with-slash-commands.js +776 -0
- package/dist/src/slash-commands/mcp-slash-integration.js +146 -0
- package/package.json +17 -5
- package/src/slash-commands/mcp-slash-integration.js +146 -0
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: "AI-powered project analysis with prioritized improvement recommendations"
|
|
3
|
+
argument-hint: "[--focus=<area>|--quick|--detailed|--security]"
|
|
4
|
+
allowed-tools: ["Read", "Bash", "Glob", "Grep", "mcp__claude-flow__language_detect", "mcp__claude-flow__framework_detect", "mcp__claude-flow__dependency_analyze", "mcp__claude-flow__rust_quality_analyze", "mcp__claude-flow__typescript_validate", "mcp__claude-flow__memory_usage", "mcp__claude-flow__agent_spawn"]
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# AI Project Analysis & Improvement Suggestions
|
|
8
|
+
|
|
9
|
+
Provide intelligent, prioritized recommendations for improving your codebase based on AI analysis.
|
|
10
|
+
|
|
11
|
+
**Focus Area**: $ARGUMENTS
|
|
12
|
+
|
|
13
|
+
## Analysis Options
|
|
14
|
+
|
|
15
|
+
- `--focus=security` - Focus on security vulnerabilities and best practices
|
|
16
|
+
- `--focus=performance` - Analyze performance bottlenecks and optimizations
|
|
17
|
+
- `--focus=maintainability` - Code quality, readability, and maintainability
|
|
18
|
+
- `--focus=testing` - Test coverage, quality, and missing test scenarios
|
|
19
|
+
- `--quick` - Fast analysis with top 3-5 recommendations
|
|
20
|
+
- `--detailed` - Comprehensive analysis with implementation guides
|
|
21
|
+
- `--security` - Security-focused analysis with CVE scanning
|
|
22
|
+
|
|
23
|
+
## What This Command Does
|
|
24
|
+
|
|
25
|
+
### 🔍 Intelligent Codebase Analysis
|
|
26
|
+
- **Framework-Aware**: Leverages 98.5% accurate framework detection
|
|
27
|
+
- **Language-Specific**: Tailored recommendations for detected languages
|
|
28
|
+
- **Context-Aware**: Understands project structure and patterns
|
|
29
|
+
- **Risk Assessment**: Prioritizes improvements by impact and effort
|
|
30
|
+
|
|
31
|
+
### 🎦 Analysis Categories
|
|
32
|
+
|
|
33
|
+
#### Security Analysis
|
|
34
|
+
- Dependency vulnerability scanning
|
|
35
|
+
- Code security pattern detection
|
|
36
|
+
- Authentication/authorization review
|
|
37
|
+
- Input validation and sanitization
|
|
38
|
+
|
|
39
|
+
#### Performance Analysis
|
|
40
|
+
- Bundle size optimization opportunities
|
|
41
|
+
- Database query optimization
|
|
42
|
+
- Caching strategy improvements
|
|
43
|
+
- Resource usage patterns
|
|
44
|
+
|
|
45
|
+
#### Code Quality Analysis
|
|
46
|
+
- Design pattern recommendations
|
|
47
|
+
- Refactoring opportunities
|
|
48
|
+
- Documentation gaps
|
|
49
|
+
- Type safety improvements
|
|
50
|
+
|
|
51
|
+
#### Testing Analysis
|
|
52
|
+
- Coverage gap identification
|
|
53
|
+
- Missing test scenarios
|
|
54
|
+
- Test quality assessment
|
|
55
|
+
- E2E testing opportunities
|
|
56
|
+
|
|
57
|
+
## Sample Output
|
|
58
|
+
|
|
59
|
+
```markdown
|
|
60
|
+
## 🚨 High Priority (Security)
|
|
61
|
+
1. **Update lodash dependency** - CVE-2021-23337 (Risk: High)
|
|
62
|
+
Command: `npm update lodash@^4.17.21`
|
|
63
|
+
|
|
64
|
+
2. **Add input validation** - Missing sanitization in user routes
|
|
65
|
+
Files: `src/routes/user.js`
|
|
66
|
+
|
|
67
|
+
## 🚀 Medium Priority (Performance)
|
|
68
|
+
1. **Implement code splitting** - Bundle size: 2.3MB
|
|
69
|
+
Framework: React with dynamic imports
|
|
70
|
+
|
|
71
|
+
2. **Add Redis caching** - Database queries: 150ms avg
|
|
72
|
+
Impact: 60% performance improvement
|
|
73
|
+
|
|
74
|
+
## 🛠️ Low Priority (Maintenance)
|
|
75
|
+
1. **Add TypeScript** - 89% of codebase would benefit
|
|
76
|
+
2. **Update documentation** - API docs outdated
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Educational Focus
|
|
80
|
+
|
|
81
|
+
Every recommendation includes:
|
|
82
|
+
- **Why**: Explanation of the problem/opportunity
|
|
83
|
+
- **Impact**: Expected improvement metrics
|
|
84
|
+
- **How**: Specific implementation steps
|
|
85
|
+
- **Resources**: Links to best practices and tutorials
|
|
86
|
+
|
|
87
|
+
## Framework-Specific Recommendations
|
|
88
|
+
|
|
89
|
+
- **Rust**: Clippy suggestions, unsafe code review, performance optimization
|
|
90
|
+
- **JavaScript/Node.js**: NPM audit, bundle analysis, async/await patterns
|
|
91
|
+
- **TypeScript**: Type coverage, strict mode opportunities
|
|
92
|
+
- **Python**: Virtual environment setup, type hints, security scanning
|
|
93
|
+
- **React**: Component optimization, state management, accessibility
|
|
94
|
+
|
|
95
|
+
Get actionable, prioritized recommendations to improve your project's security, performance, and maintainability.
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: "Contextual code templates based on detected project patterns and frameworks"
|
|
3
|
+
argument-hint: "[<component-type>|--list|--search=<pattern>|--category=<type>]"
|
|
4
|
+
allowed-tools: ["Read", "Write", "Bash", "Glob", "Grep", "mcp__claude-flow__language_detect", "mcp__claude-flow__framework_detect", "mcp__claude-flow__memory_usage", "mcp__shadcn_mcp__generate_component"]
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Contextual Code Templates
|
|
8
|
+
|
|
9
|
+
Generate relevant code templates based on your project's detected frameworks, patterns, and current context.
|
|
10
|
+
|
|
11
|
+
**Template Type**: $ARGUMENTS
|
|
12
|
+
|
|
13
|
+
## Template Options
|
|
14
|
+
|
|
15
|
+
- `--list` - Show all available templates for detected framework
|
|
16
|
+
- `--search=<pattern>` - Search templates by keyword or pattern
|
|
17
|
+
- `--category=<type>` - Filter by category (component, service, test, config)
|
|
18
|
+
- `<component-type>` - Generate specific component (e.g., "api-route", "react-component")
|
|
19
|
+
|
|
20
|
+
## What This Command Does
|
|
21
|
+
|
|
22
|
+
### 🎯 Smart Template Selection
|
|
23
|
+
- **Framework Detection**: Automatically detects React, Express, FastAPI, Axum, etc.
|
|
24
|
+
- **Pattern Recognition**: Analyzes existing code patterns and conventions
|
|
25
|
+
- **Context-Aware**: Suggests templates relevant to current file/directory
|
|
26
|
+
- **Best Practices**: Templates follow industry standards and conventions
|
|
27
|
+
|
|
28
|
+
### 📋 Template Categories
|
|
29
|
+
|
|
30
|
+
#### Frontend Templates
|
|
31
|
+
- **React Components**: Functional components, hooks, context providers
|
|
32
|
+
- **Vue Components**: Composition API, reactive patterns
|
|
33
|
+
- **Angular Components**: Services, modules, guards
|
|
34
|
+
- **Styling**: CSS modules, styled-components, Tailwind patterns
|
|
35
|
+
|
|
36
|
+
#### Backend Templates
|
|
37
|
+
- **REST APIs**: Express routes, FastAPI endpoints, Axum handlers
|
|
38
|
+
- **Database**: Models, migrations, queries, repositories
|
|
39
|
+
- **Authentication**: JWT middleware, OAuth flows, session management
|
|
40
|
+
- **Testing**: Unit tests, integration tests, mocks
|
|
41
|
+
|
|
42
|
+
#### Configuration Templates
|
|
43
|
+
- **Build Tools**: Webpack, Vite, Rollup configurations
|
|
44
|
+
- **CI/CD**: GitHub Actions, Docker, deployment scripts
|
|
45
|
+
- **Environment**: .env templates, config management
|
|
46
|
+
- **Documentation**: README patterns, API docs, changelogs
|
|
47
|
+
|
|
48
|
+
## Framework-Specific Examples
|
|
49
|
+
|
|
50
|
+
### React Project Detected
|
|
51
|
+
```bash
|
|
52
|
+
# Available templates:
|
|
53
|
+
/suggest-templates --list
|
|
54
|
+
# Output: react-component, react-hook, context-provider, test-component
|
|
55
|
+
|
|
56
|
+
# Generate a React component
|
|
57
|
+
/suggest-templates react-component
|
|
58
|
+
# Creates: functional component with TypeScript, props interface, styling
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Express.js Project Detected
|
|
62
|
+
```bash
|
|
63
|
+
# Generate API route template
|
|
64
|
+
/suggest-templates api-route
|
|
65
|
+
# Creates: Express route with validation, error handling, documentation
|
|
66
|
+
|
|
67
|
+
# Generate middleware template
|
|
68
|
+
/suggest-templates middleware
|
|
69
|
+
# Creates: Express middleware with proper error handling and logging
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Rust Project Detected
|
|
73
|
+
```bash
|
|
74
|
+
# Generate Axum handler
|
|
75
|
+
/suggest-templates axum-handler
|
|
76
|
+
# Creates: Async handler with proper error handling and serialization
|
|
77
|
+
|
|
78
|
+
# Generate test module
|
|
79
|
+
/suggest-templates rust-test
|
|
80
|
+
# Creates: Test module with common test patterns and mocks
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Template Features
|
|
84
|
+
|
|
85
|
+
### 🛠️ Smart Generation
|
|
86
|
+
- **Project Conventions**: Follows your existing naming and structure patterns
|
|
87
|
+
- **Dependency Integration**: Uses libraries already in your project
|
|
88
|
+
- **Type Safety**: Generates TypeScript/Rust types when applicable
|
|
89
|
+
- **Error Handling**: Includes proper error handling patterns
|
|
90
|
+
|
|
91
|
+
### 📚 Educational Comments
|
|
92
|
+
- **Best Practice Explanations**: Comments explain why patterns are used
|
|
93
|
+
- **Common Pitfalls**: Warnings about potential issues
|
|
94
|
+
- **Extension Points**: Suggestions for how to extend the template
|
|
95
|
+
- **Performance Tips**: Optimization recommendations
|
|
96
|
+
|
|
97
|
+
### 🔄 Template Customization
|
|
98
|
+
- **Variable Substitution**: Replaces placeholders with project-specific values
|
|
99
|
+
- **Conditional Sections**: Includes/excludes code based on project setup
|
|
100
|
+
- **Style Matching**: Matches your existing code style (spaces/tabs, naming)
|
|
101
|
+
|
|
102
|
+
## Sample Template Output
|
|
103
|
+
|
|
104
|
+
```typescript
|
|
105
|
+
// React Functional Component Template
|
|
106
|
+
import React, { useState, useEffect } from 'react';
|
|
107
|
+
import styles from './MyComponent.module.css';
|
|
108
|
+
|
|
109
|
+
interface MyComponentProps {
|
|
110
|
+
// TODO: Define your props here
|
|
111
|
+
title?: string;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* MyComponent - Brief description
|
|
116
|
+
*
|
|
117
|
+
* Best Practices:
|
|
118
|
+
* - Use functional components with hooks
|
|
119
|
+
* - Keep components small and focused
|
|
120
|
+
* - Extract custom hooks for complex logic
|
|
121
|
+
*/
|
|
122
|
+
const MyComponent: React.FC<MyComponentProps> = ({ title = 'Default Title' }) => {
|
|
123
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
124
|
+
|
|
125
|
+
useEffect(() => {
|
|
126
|
+
// TODO: Add your effect logic here
|
|
127
|
+
}, []);
|
|
128
|
+
|
|
129
|
+
return (
|
|
130
|
+
<div className={styles.container}>
|
|
131
|
+
<h2>{title}</h2>
|
|
132
|
+
{/* TODO: Add your component content */}
|
|
133
|
+
</div>
|
|
134
|
+
);
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
export default MyComponent;
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
## Integration with Tools
|
|
141
|
+
|
|
142
|
+
- **shadcn/ui Integration**: Generate beautiful UI components when shadcn is detected
|
|
143
|
+
- **Testing Framework**: Include appropriate test templates (Jest, Vitest, pytest)
|
|
144
|
+
- **Documentation**: Generate component documentation and usage examples
|
|
145
|
+
- **Storybook**: Include Storybook stories when detected
|
|
146
|
+
|
|
147
|
+
Get contextual, educational code templates that follow your project's patterns and best practices.
|
|
@@ -0,0 +1,423 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Swarm Management Slash Command
|
|
5
|
+
* Usage: /swarm <action> [options]
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { SlashCommand } from '../core/slash-command.js';
|
|
9
|
+
|
|
10
|
+
export class SwarmCommand extends SlashCommand {
|
|
11
|
+
constructor() {
|
|
12
|
+
super('swarm', 'Manage AI agent swarms with various topologies and coordination patterns');
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
getUsage() {
|
|
16
|
+
return '/swarm <action> [options]';
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
getExamples() {
|
|
20
|
+
return [
|
|
21
|
+
'/swarm init mesh 8 - Initialize mesh topology with 8 agents',
|
|
22
|
+
'/swarm status - Get current swarm status',
|
|
23
|
+
'/swarm spawn researcher - Spawn a researcher agent',
|
|
24
|
+
'/swarm orchestrate "Build REST API" - Orchestrate a task',
|
|
25
|
+
'/swarm monitor - Monitor swarm activity',
|
|
26
|
+
'/swarm scale 12 - Scale swarm to 12 agents',
|
|
27
|
+
'/swarm destroy - Gracefully shutdown swarm'
|
|
28
|
+
];
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
async execute(args, context) {
|
|
32
|
+
const [action, ...params] = args;
|
|
33
|
+
|
|
34
|
+
if (!action) {
|
|
35
|
+
return this.formatResponse({
|
|
36
|
+
success: false,
|
|
37
|
+
error: 'Action required',
|
|
38
|
+
usage: this.getUsage(),
|
|
39
|
+
availableActions: [
|
|
40
|
+
'init', 'status', 'spawn', 'orchestrate', 'monitor', 'scale', 'destroy'
|
|
41
|
+
]
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
try {
|
|
46
|
+
let result;
|
|
47
|
+
|
|
48
|
+
switch (action.toLowerCase()) {
|
|
49
|
+
case 'init':
|
|
50
|
+
result = await this.initSwarm(params);
|
|
51
|
+
break;
|
|
52
|
+
|
|
53
|
+
case 'status':
|
|
54
|
+
result = await this.getStatus(params);
|
|
55
|
+
break;
|
|
56
|
+
|
|
57
|
+
case 'spawn':
|
|
58
|
+
result = await this.spawnAgent(params);
|
|
59
|
+
break;
|
|
60
|
+
|
|
61
|
+
case 'orchestrate':
|
|
62
|
+
result = await this.orchestrateTask(params);
|
|
63
|
+
break;
|
|
64
|
+
|
|
65
|
+
case 'monitor':
|
|
66
|
+
result = await this.monitorSwarm(params);
|
|
67
|
+
break;
|
|
68
|
+
|
|
69
|
+
case 'scale':
|
|
70
|
+
result = await this.scaleSwarm(params);
|
|
71
|
+
break;
|
|
72
|
+
|
|
73
|
+
case 'destroy':
|
|
74
|
+
result = await this.destroySwarm(params);
|
|
75
|
+
break;
|
|
76
|
+
|
|
77
|
+
default:
|
|
78
|
+
result = {
|
|
79
|
+
success: false,
|
|
80
|
+
error: `Unknown action: ${action}`,
|
|
81
|
+
availableActions: [
|
|
82
|
+
'init', 'status', 'spawn', 'orchestrate', 'monitor', 'scale', 'destroy'
|
|
83
|
+
]
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return this.formatResponse(result);
|
|
88
|
+
} catch (error) {
|
|
89
|
+
return this.formatResponse({
|
|
90
|
+
success: false,
|
|
91
|
+
error: error.message,
|
|
92
|
+
action: action
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
async initSwarm(params) {
|
|
98
|
+
const [topology = 'mesh', maxAgents = '8', strategy = 'balanced'] = params;
|
|
99
|
+
|
|
100
|
+
const validTopologies = ['mesh', 'hierarchical', 'ring', 'star'];
|
|
101
|
+
if (!validTopologies.includes(topology)) {
|
|
102
|
+
return {
|
|
103
|
+
success: false,
|
|
104
|
+
error: `Invalid topology. Valid options: ${validTopologies.join(', ')}`
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const agentCount = parseInt(maxAgents);
|
|
109
|
+
if (isNaN(agentCount) || agentCount < 1 || agentCount > 100) {
|
|
110
|
+
return {
|
|
111
|
+
success: false,
|
|
112
|
+
error: 'Agent count must be between 1 and 100'
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
console.log(`🚀 Initializing ${topology} swarm with ${agentCount} agents...`);
|
|
117
|
+
|
|
118
|
+
const prompt = `
|
|
119
|
+
🚀 **SWARM INITIALIZATION**
|
|
120
|
+
|
|
121
|
+
**Configuration:**
|
|
122
|
+
- Topology: ${topology}
|
|
123
|
+
- Max Agents: ${agentCount}
|
|
124
|
+
- Strategy: ${strategy}
|
|
125
|
+
|
|
126
|
+
**Initialize the swarm with MCP tools:**
|
|
127
|
+
|
|
128
|
+
\`\`\`javascript
|
|
129
|
+
// Step 1: Initialize swarm coordination
|
|
130
|
+
mcp__claude-flow__swarm_init({
|
|
131
|
+
topology: "${topology}",
|
|
132
|
+
maxAgents: ${agentCount},
|
|
133
|
+
strategy: "${strategy}"
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
// Step 2: Set up agent coordination patterns
|
|
137
|
+
mcp__claude-flow__coordination_sync({ swarmId: "swarm-${Date.now()}" });
|
|
138
|
+
\`\`\`
|
|
139
|
+
|
|
140
|
+
**Then use Claude Code's Task tool to spawn actual working agents:**
|
|
141
|
+
\`\`\`javascript
|
|
142
|
+
Task("Coordinator Agent", "Coordinate swarm activities and task distribution", "coordinator")
|
|
143
|
+
Task("Research Agent", "Analyze requirements and gather information", "researcher")
|
|
144
|
+
Task("Coder Agent", "Implement code and solutions", "coder")
|
|
145
|
+
Task("Tester Agent", "Create and run comprehensive tests", "tester")
|
|
146
|
+
\`\`\`
|
|
147
|
+
|
|
148
|
+
**Execute this swarm initialization now**:
|
|
149
|
+
`;
|
|
150
|
+
|
|
151
|
+
return {
|
|
152
|
+
success: true,
|
|
153
|
+
prompt: prompt,
|
|
154
|
+
topology: topology,
|
|
155
|
+
maxAgents: agentCount,
|
|
156
|
+
strategy: strategy,
|
|
157
|
+
swarmId: `swarm-${Date.now()}`
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
async getStatus(params) {
|
|
162
|
+
const [verbose = 'false'] = params;
|
|
163
|
+
const isVerbose = verbose.toLowerCase() === 'true';
|
|
164
|
+
|
|
165
|
+
console.log('📊 Getting swarm status...');
|
|
166
|
+
|
|
167
|
+
const prompt = `
|
|
168
|
+
📊 **SWARM STATUS CHECK**
|
|
169
|
+
|
|
170
|
+
**Get current swarm information:**
|
|
171
|
+
|
|
172
|
+
\`\`\`javascript
|
|
173
|
+
// Check swarm status with MCP tools
|
|
174
|
+
mcp__claude-flow__swarm_status({ verbose: ${isVerbose} });
|
|
175
|
+
|
|
176
|
+
// Get agent metrics
|
|
177
|
+
mcp__claude-flow__agent_metrics({ metric: "all" });
|
|
178
|
+
|
|
179
|
+
// Check active tasks
|
|
180
|
+
mcp__claude-flow__task_status({ detailed: ${isVerbose} });
|
|
181
|
+
\`\`\`
|
|
182
|
+
|
|
183
|
+
**Execute this status check now**:
|
|
184
|
+
`;
|
|
185
|
+
|
|
186
|
+
return {
|
|
187
|
+
success: true,
|
|
188
|
+
prompt: prompt,
|
|
189
|
+
verbose: isVerbose
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
async spawnAgent(params) {
|
|
194
|
+
const [type, ...nameParams] = params;
|
|
195
|
+
const name = nameParams.join(' ');
|
|
196
|
+
|
|
197
|
+
if (!type) {
|
|
198
|
+
return {
|
|
199
|
+
success: false,
|
|
200
|
+
error: 'Agent type required',
|
|
201
|
+
availableTypes: [
|
|
202
|
+
'researcher', 'coder', 'analyst', 'optimizer', 'coordinator',
|
|
203
|
+
'tester', 'reviewer', 'architect', 'documenter'
|
|
204
|
+
]
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
console.log(`🤖 Spawning ${type} agent${name ? ` named "${name}"` : ''}...`);
|
|
209
|
+
|
|
210
|
+
const prompt = `
|
|
211
|
+
🤖 **SPAWN AGENT**
|
|
212
|
+
|
|
213
|
+
**Agent Configuration:**
|
|
214
|
+
- Type: ${type}
|
|
215
|
+
- Name: ${name || `${type}-${Date.now()}`}
|
|
216
|
+
|
|
217
|
+
**Use both MCP coordination and Claude Code execution:**
|
|
218
|
+
|
|
219
|
+
\`\`\`javascript
|
|
220
|
+
// Step 1: Register agent with MCP coordination
|
|
221
|
+
mcp__claude-flow__agent_spawn({
|
|
222
|
+
type: "${type}",
|
|
223
|
+
name: "${name || `${type}-${Date.now()}`}",
|
|
224
|
+
capabilities: ["${type}-specific-capabilities"]
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
// Step 2: Spawn actual working agent with Claude Code's Task tool
|
|
228
|
+
Task("${name || `${type} Agent`}", "Execute ${type} tasks with coordination hooks", "${type}")
|
|
229
|
+
\`\`\`
|
|
230
|
+
|
|
231
|
+
**Agent Instructions:**
|
|
232
|
+
The agent should use hooks for coordination:
|
|
233
|
+
- Pre-task: \`npx claude-flow@alpha hooks pre-task\`
|
|
234
|
+
- Post-edit: \`npx claude-flow@alpha hooks post-edit\`
|
|
235
|
+
- Post-task: \`npx claude-flow@alpha hooks post-task\`
|
|
236
|
+
|
|
237
|
+
**Execute this agent spawn now**:
|
|
238
|
+
`;
|
|
239
|
+
|
|
240
|
+
return {
|
|
241
|
+
success: true,
|
|
242
|
+
prompt: prompt,
|
|
243
|
+
agentType: type,
|
|
244
|
+
agentName: name || `${type}-${Date.now()}`
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
async orchestrateTask(params) {
|
|
249
|
+
const task = params.join(' ');
|
|
250
|
+
|
|
251
|
+
if (!task) {
|
|
252
|
+
return {
|
|
253
|
+
success: false,
|
|
254
|
+
error: 'Task description required'
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
console.log(`🎯 Orchestrating task: ${task}`);
|
|
259
|
+
|
|
260
|
+
const prompt = `
|
|
261
|
+
🎯 **TASK ORCHESTRATION**
|
|
262
|
+
|
|
263
|
+
**Task:** ${task}
|
|
264
|
+
|
|
265
|
+
**Orchestrate with coordinated agents:**
|
|
266
|
+
|
|
267
|
+
\`\`\`javascript
|
|
268
|
+
// Step 1: Set up task orchestration
|
|
269
|
+
mcp__claude-flow__task_orchestrate({
|
|
270
|
+
task: "${task}",
|
|
271
|
+
strategy: "adaptive",
|
|
272
|
+
priority: "high"
|
|
273
|
+
});
|
|
274
|
+
|
|
275
|
+
// Step 2: Spawn coordinated agents with Claude Code's Task tool
|
|
276
|
+
Task("Task Coordinator", "Break down and coordinate: ${task}", "coordinator")
|
|
277
|
+
Task("Implementation Agent", "Execute main implementation for: ${task}", "coder")
|
|
278
|
+
Task("Quality Agent", "Ensure quality and testing for: ${task}", "tester")
|
|
279
|
+
Task("Review Agent", "Review and validate: ${task}", "reviewer")
|
|
280
|
+
\`\`\`
|
|
281
|
+
|
|
282
|
+
**Coordination Protocol:**
|
|
283
|
+
1. Each agent uses hooks for coordination
|
|
284
|
+
2. Shared memory for context and progress
|
|
285
|
+
3. Automatic load balancing and optimization
|
|
286
|
+
|
|
287
|
+
**Execute this task orchestration now**:
|
|
288
|
+
`;
|
|
289
|
+
|
|
290
|
+
return {
|
|
291
|
+
success: true,
|
|
292
|
+
prompt: prompt,
|
|
293
|
+
task: task,
|
|
294
|
+
taskId: `task-${Date.now()}`
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
async monitorSwarm(params) {
|
|
299
|
+
const [duration = '30'] = params;
|
|
300
|
+
const monitorDuration = parseInt(duration);
|
|
301
|
+
|
|
302
|
+
console.log(`👁️ Monitoring swarm for ${monitorDuration} seconds...`);
|
|
303
|
+
|
|
304
|
+
const prompt = `
|
|
305
|
+
👁️ **SWARM MONITORING**
|
|
306
|
+
|
|
307
|
+
**Monitor swarm activity:**
|
|
308
|
+
|
|
309
|
+
\`\`\`javascript
|
|
310
|
+
// Real-time swarm monitoring
|
|
311
|
+
mcp__claude-flow__swarm_monitor({
|
|
312
|
+
interval: 5,
|
|
313
|
+
duration: ${monitorDuration}
|
|
314
|
+
});
|
|
315
|
+
|
|
316
|
+
// Performance metrics
|
|
317
|
+
mcp__claude-flow__performance_report({ format: "detailed" });
|
|
318
|
+
|
|
319
|
+
// Agent performance
|
|
320
|
+
mcp__claude-flow__agent_metrics({ metric: "performance" });
|
|
321
|
+
\`\`\`
|
|
322
|
+
|
|
323
|
+
**Monitoring Dashboard:**
|
|
324
|
+
- Agent status and performance
|
|
325
|
+
- Task progress and completion
|
|
326
|
+
- Resource utilization
|
|
327
|
+
- Coordination efficiency
|
|
328
|
+
|
|
329
|
+
**Execute this monitoring now**:
|
|
330
|
+
`;
|
|
331
|
+
|
|
332
|
+
return {
|
|
333
|
+
success: true,
|
|
334
|
+
prompt: prompt,
|
|
335
|
+
duration: monitorDuration
|
|
336
|
+
};
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
async scaleSwarm(params) {
|
|
340
|
+
const [targetSize] = params;
|
|
341
|
+
const newSize = parseInt(targetSize);
|
|
342
|
+
|
|
343
|
+
if (isNaN(newSize) || newSize < 1 || newSize > 100) {
|
|
344
|
+
return {
|
|
345
|
+
success: false,
|
|
346
|
+
error: 'Target size must be between 1 and 100'
|
|
347
|
+
};
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
console.log(`📈 Scaling swarm to ${newSize} agents...`);
|
|
351
|
+
|
|
352
|
+
const prompt = `
|
|
353
|
+
📈 **SWARM SCALING**
|
|
354
|
+
|
|
355
|
+
**Scale to ${newSize} agents:**
|
|
356
|
+
|
|
357
|
+
\`\`\`javascript
|
|
358
|
+
// Auto-scale swarm
|
|
359
|
+
mcp__claude-flow__swarm_scale({
|
|
360
|
+
targetSize: ${newSize}
|
|
361
|
+
});
|
|
362
|
+
|
|
363
|
+
// Optimize topology for new size
|
|
364
|
+
mcp__claude-flow__topology_optimize();
|
|
365
|
+
|
|
366
|
+
// Rebalance tasks
|
|
367
|
+
mcp__claude-flow__load_balance({ tasks: ["current-tasks"] });
|
|
368
|
+
\`\`\`
|
|
369
|
+
|
|
370
|
+
**Scaling Strategy:**
|
|
371
|
+
- Graceful addition/removal of agents
|
|
372
|
+
- Automatic task redistribution
|
|
373
|
+
- Topology optimization
|
|
374
|
+
- Performance monitoring
|
|
375
|
+
|
|
376
|
+
**Execute this scaling now**:
|
|
377
|
+
`;
|
|
378
|
+
|
|
379
|
+
return {
|
|
380
|
+
success: true,
|
|
381
|
+
prompt: prompt,
|
|
382
|
+
targetSize: newSize
|
|
383
|
+
};
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
async destroySwarm(params) {
|
|
387
|
+
console.log('🛑 Destroying swarm...');
|
|
388
|
+
|
|
389
|
+
const prompt = `
|
|
390
|
+
🛑 **SWARM DESTRUCTION**
|
|
391
|
+
|
|
392
|
+
**Gracefully shutdown swarm:**
|
|
393
|
+
|
|
394
|
+
\`\`\`javascript
|
|
395
|
+
// Step 1: Complete current tasks
|
|
396
|
+
mcp__claude-flow__task_status({ detailed: true });
|
|
397
|
+
|
|
398
|
+
// Step 2: Save state and metrics
|
|
399
|
+
mcp__claude-flow__state_snapshot({ name: "final-state" });
|
|
400
|
+
|
|
401
|
+
// Step 3: Destroy swarm
|
|
402
|
+
mcp__claude-flow__swarm_destroy();
|
|
403
|
+
\`\`\`
|
|
404
|
+
|
|
405
|
+
**Shutdown Checklist:**
|
|
406
|
+
- ✅ Complete active tasks
|
|
407
|
+
- ✅ Save coordination state
|
|
408
|
+
- ✅ Export performance metrics
|
|
409
|
+
- ✅ Clean up resources
|
|
410
|
+
- ✅ Graceful agent termination
|
|
411
|
+
|
|
412
|
+
**Execute this shutdown now**:
|
|
413
|
+
`;
|
|
414
|
+
|
|
415
|
+
return {
|
|
416
|
+
success: true,
|
|
417
|
+
prompt: prompt,
|
|
418
|
+
action: 'destroy'
|
|
419
|
+
};
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
export default SwarmCommand;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: "AI swarm management and coordination"
|
|
3
|
+
argument-hint: "<action> [parameters]"
|
|
4
|
+
allowed-tools: ["mcp__claude-flow-novice__swarm_init", "mcp__claude-flow-novice__agent_spawn", "mcp__claude-flow-novice__task_orchestrate"]
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# AI Swarm Management
|
|
8
|
+
|
|
9
|
+
Execute AI swarm coordination and management tasks.
|
|
10
|
+
|
|
11
|
+
**Command**: $ARGUMENTS
|
|
12
|
+
|
|
13
|
+
**Available Actions**:
|
|
14
|
+
- `init <topology> <count>` - Initialize swarm (mesh, hierarchical, ring, star)
|
|
15
|
+
- `status` - Show swarm status and health
|
|
16
|
+
- `spawn <type>` - Create specialized agent (researcher, coder, analyst, etc.)
|
|
17
|
+
- `orchestrate "<task>"` - Coordinate task across swarm
|
|
18
|
+
- `scale <count>` - Scale swarm to specified agent count
|
|
19
|
+
- `destroy` - Gracefully shutdown swarm
|
|
20
|
+
|
|
21
|
+
**Swarm Coordination**:
|
|
22
|
+
Use the claude-flow-novice MCP tools to coordinate AI agent swarms for complex task execution. The swarm system supports multiple topologies and can auto-scale based on workload.
|
|
23
|
+
|
|
24
|
+
Execute the requested swarm action and provide status updates on coordination progress.
|