claude-flow-novice 1.1.8 → 1.1.9

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.
Files changed (30) hide show
  1. package/dist/mcp/mcp-server-novice.js +10 -2
  2. package/dist/src/cli/simple-commands/hooks/session-start-soul.js +271 -0
  3. package/dist/src/slash-commands/README.md +157 -0
  4. package/dist/src/slash-commands/claude-md.js +237 -0
  5. package/dist/src/slash-commands/claude-soul.js +562 -0
  6. package/dist/src/slash-commands/cli-integration.js +216 -0
  7. package/dist/src/slash-commands/github.js +638 -0
  8. package/dist/src/slash-commands/hooks.js +648 -0
  9. package/dist/src/slash-commands/index.js +115 -0
  10. package/dist/src/slash-commands/neural.js +572 -0
  11. package/dist/src/slash-commands/performance.js +582 -0
  12. package/dist/src/slash-commands/register-all-commands.js +314 -0
  13. package/dist/src/slash-commands/register-claude-md.js +82 -0
  14. package/dist/src/slash-commands/register-claude-soul.js +80 -0
  15. package/dist/src/slash-commands/sparc.js +110 -0
  16. package/dist/src/slash-commands/swarm.js +423 -0
  17. package/dist/src/slash-commands/validate-commands.js +223 -0
  18. package/dist/src/slash-commands/workflow.js +606 -0
  19. package/package.json +8 -7
  20. package/src/slash-commands/cli-integration.js +216 -0
  21. package/src/slash-commands/github.js +638 -0
  22. package/src/slash-commands/hooks.js +648 -0
  23. package/src/slash-commands/index.js +115 -0
  24. package/src/slash-commands/neural.js +572 -0
  25. package/src/slash-commands/performance.js +582 -0
  26. package/src/slash-commands/register-all-commands.js +314 -0
  27. package/src/slash-commands/sparc.js +110 -0
  28. package/src/slash-commands/swarm.js +423 -0
  29. package/src/slash-commands/validate-commands.js +223 -0
  30. package/src/slash-commands/workflow.js +606 -0
@@ -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,223 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Validate All Slash Commands
5
+ *
6
+ * Tests that all slash commands are properly implemented and working
7
+ */
8
+
9
+ import { globalRegistry, executeSlashCommand } from './register-all-commands.js';
10
+
11
+ /**
12
+ * Command Validator
13
+ */
14
+ export class CommandValidator {
15
+ constructor() {
16
+ this.registry = globalRegistry;
17
+ this.results = [];
18
+ }
19
+
20
+ /**
21
+ * Validate all commands
22
+ */
23
+ async validateAll() {
24
+ console.log('šŸ” Validating all slash commands...');
25
+
26
+ const commands = this.registry.listCommands();
27
+
28
+ for (const cmd of commands) {
29
+ await this.validateCommand(cmd.name);
30
+ }
31
+
32
+ this.printResults();
33
+ return this.results;
34
+ }
35
+
36
+ /**
37
+ * Validate individual command
38
+ * @param {string} commandName - Command to validate
39
+ */
40
+ async validateCommand(commandName) {
41
+ const result = {
42
+ command: commandName,
43
+ tests: {
44
+ help: false,
45
+ execute: false,
46
+ errorHandling: false
47
+ },
48
+ errors: []
49
+ };
50
+
51
+ try {
52
+ // Test 1: Help functionality
53
+ const helpResult = this.registry.getHelp(commandName);
54
+ result.tests.help = helpResult.success;
55
+ if (!helpResult.success) {
56
+ result.errors.push(`Help failed: ${helpResult.error}`);
57
+ }
58
+
59
+ // Test 2: Basic execution (should fail gracefully with no args)
60
+ try {
61
+ const execResult = await executeSlashCommand(`/${commandName}`);
62
+ result.tests.execute = true;
63
+ } catch (error) {
64
+ result.tests.execute = false;
65
+ result.errors.push(`Execution failed: ${error.message}`);
66
+ }
67
+
68
+ // Test 3: Error handling (invalid args)
69
+ try {
70
+ const errorResult = await executeSlashCommand(`/${commandName} invalid-arg-test`);
71
+ result.tests.errorHandling = true;
72
+ } catch (error) {
73
+ result.tests.errorHandling = false;
74
+ result.errors.push(`Error handling failed: ${error.message}`);
75
+ }
76
+
77
+ } catch (error) {
78
+ result.errors.push(`Validation failed: ${error.message}`);
79
+ }
80
+
81
+ this.results.push(result);
82
+ }
83
+
84
+ /**
85
+ * Print validation results
86
+ */
87
+ printResults() {
88
+ console.log('\nšŸ“ˆ **VALIDATION RESULTS**\n');
89
+
90
+ let totalTests = 0;
91
+ let passedTests = 0;
92
+
93
+ for (const result of this.results) {
94
+ const tests = Object.values(result.tests);
95
+ const passed = tests.filter(t => t).length;
96
+ const total = tests.length;
97
+
98
+ totalTests += total;
99
+ passedTests += passed;
100
+
101
+ const status = passed === total ? 'āœ…' : 'āš ļø';
102
+ console.log(`${status} /${result.command} - ${passed}/${total} tests passed`);
103
+
104
+ if (result.errors.length > 0) {
105
+ result.errors.forEach(error => {
106
+ console.log(` āŒ ${error}`);
107
+ });
108
+ }
109
+ }
110
+
111
+ console.log(`\nšŸ“‰ **Overall: ${passedTests}/${totalTests} tests passed**`);
112
+
113
+ if (passedTests === totalTests) {
114
+ console.log('āœ… All commands validated successfully!');
115
+ } else {
116
+ console.log('āš ļø Some commands need attention.');
117
+ }
118
+ }
119
+
120
+ /**
121
+ * Test specific command with args
122
+ * @param {string} commandName - Command name
123
+ * @param {string[]} args - Arguments to test
124
+ */
125
+ async testCommand(commandName, args = []) {
126
+ const input = `/${commandName} ${args.join(' ')}`.trim();
127
+
128
+ console.log(`\nšŸ” Testing: ${input}`);
129
+
130
+ try {
131
+ const result = await executeSlashCommand(input);
132
+
133
+ if (result.success) {
134
+ console.log('āœ… Command executed successfully');
135
+ if (result.result && result.result.prompt) {
136
+ console.log('Generated prompt preview:');
137
+ console.log(result.result.prompt.substring(0, 200) + '...');
138
+ }
139
+ } else {
140
+ console.log(`āš ļø Command failed: ${result.error}`);
141
+ }
142
+
143
+ return result;
144
+ } catch (error) {
145
+ console.log(`āŒ Test failed: ${error.message}`);
146
+ return { success: false, error: error.message };
147
+ }
148
+ }
149
+ }
150
+
151
+ /**
152
+ * Run interactive command testing
153
+ */
154
+ export async function interactiveTest() {
155
+ const validator = new CommandValidator();
156
+
157
+ console.log('šŸš€ **INTERACTIVE COMMAND TESTING**\n');
158
+
159
+ // Test each command with example arguments
160
+ const testCases = [
161
+ { command: 'swarm', args: ['init', 'mesh', '8'] },
162
+ { command: 'hooks', args: ['enable'] },
163
+ { command: 'neural', args: ['status'] },
164
+ { command: 'performance', args: ['report'] },
165
+ { command: 'github', args: ['analyze', 'owner/repo'] },
166
+ { command: 'workflow', args: ['create', 'Test Workflow'] },
167
+ { command: 'sparc', args: ['spec', 'Build API'] }
168
+ ];
169
+
170
+ for (const testCase of testCases) {
171
+ await validator.testCommand(testCase.command, testCase.args);
172
+
173
+ // Small delay for readability
174
+ await new Promise(resolve => setTimeout(resolve, 100));
175
+ }
176
+ }
177
+
178
+ /**
179
+ * Quick validation - just check structure
180
+ */
181
+ export function quickValidation() {
182
+ console.log('⚔ **QUICK VALIDATION**\n');
183
+
184
+ const commands = globalRegistry.listCommands();
185
+
186
+ console.log(`āœ… Registry loaded with ${commands.length} commands`);
187
+
188
+ commands.forEach(cmd => {
189
+ console.log(`āœ… /${cmd.name} - ${cmd.description}`);
190
+ if (cmd.aliases.length > 0) {
191
+ console.log(` Aliases: ${cmd.aliases.map(a => `/${a}`).join(', ')}`);
192
+ }
193
+ });
194
+
195
+ console.log('\nāœ… All commands loaded successfully!');
196
+ }
197
+
198
+ // Main execution
199
+ if (import.meta.url === `file://${process.argv[1]}`) {
200
+ const mode = process.argv[2] || 'quick';
201
+
202
+ switch (mode) {
203
+ case 'full':
204
+ const validator = new CommandValidator();
205
+ await validator.validateAll();
206
+ break;
207
+
208
+ case 'interactive':
209
+ await interactiveTest();
210
+ break;
211
+
212
+ case 'quick':
213
+ default:
214
+ quickValidation();
215
+ break;
216
+ }
217
+ }
218
+
219
+ export default {
220
+ CommandValidator,
221
+ interactiveTest,
222
+ quickValidation
223
+ };