claude-flow-novice 1.1.7 → 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 +14 -14
  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,562 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * CLAUDE-SOUL.md Slash Command
5
+ *
6
+ * Generate a project soul document - the why, what, and how of the project
7
+ * A sparse language doc limited to 500 lines focusing on project essence
8
+ */
9
+
10
+ import fs from 'fs/promises';
11
+ import path from 'path';
12
+
13
+ export class ClaudeSoulSlashCommand {
14
+ constructor(projectPath = process.cwd()) {
15
+ this.projectPath = projectPath;
16
+ this.claudeSoulPath = path.join(projectPath, 'claude-soul.md');
17
+ }
18
+
19
+ /**
20
+ * Main slash command execution
21
+ */
22
+ async execute(options = {}) {
23
+ const {
24
+ backup = true,
25
+ preview = false,
26
+ force = false
27
+ } = options;
28
+
29
+ try {
30
+ console.log('🚀 Generating claude-soul.md...');
31
+
32
+ // Step 1: Generate soul content
33
+ const soulContent = await this.generateSoulContent();
34
+
35
+ // Step 2: Handle preview mode
36
+ if (preview) {
37
+ return {
38
+ success: true,
39
+ action: 'preview',
40
+ content: soulContent,
41
+ message: 'Preview generated successfully'
42
+ };
43
+ }
44
+
45
+ // Step 3: Check for existing file
46
+ const existingSoulExists = await this.fileExists(this.claudeSoulPath);
47
+
48
+ // Step 4: Handle force/confirmation for existing files
49
+ if (existingSoulExists && !force) {
50
+ const shouldOverwrite = await this.confirmOverwrite();
51
+ if (!shouldOverwrite) {
52
+ return {
53
+ success: false,
54
+ action: 'cancelled',
55
+ message: 'Generation cancelled by user'
56
+ };
57
+ }
58
+ }
59
+
60
+ // Step 5: Create backup if requested
61
+ if (backup && existingSoulExists) {
62
+ await this.createBackup();
63
+ }
64
+
65
+ // Step 6: Write the file
66
+ await fs.writeFile(this.claudeSoulPath, soulContent, 'utf8');
67
+
68
+ console.log('✅ claude-soul.md generated successfully');
69
+ return {
70
+ success: true,
71
+ action: 'generated',
72
+ file: 'claude-soul.md',
73
+ length: soulContent.length,
74
+ lineCount: soulContent.split('\n').length
75
+ };
76
+
77
+ } catch (error) {
78
+ console.error('❌ claude-soul.md generation failed:', error.message);
79
+ return {
80
+ success: false,
81
+ action: 'error',
82
+ error: error.message
83
+ };
84
+ }
85
+ }
86
+
87
+ /**
88
+ * Generate the soul content by analyzing the project
89
+ */
90
+ async generateSoulContent() {
91
+ const projectAnalysis = await this.analyzeProject();
92
+
93
+ return `# ${projectAnalysis.name} - Project Soul
94
+
95
+ > **AI Context**: This document contains the project's essence, purpose, and philosophy. Use this context to understand project goals, make consistent decisions about code and architecture, and maintain alignment with project values throughout development.
96
+
97
+ ## WHY - The Purpose
98
+
99
+ ### Core Mission
100
+ ${projectAnalysis.mission}
101
+
102
+ ### Problem We Solve
103
+ ${projectAnalysis.problem}
104
+
105
+ ### Vision
106
+ ${projectAnalysis.vision}
107
+
108
+ ## WHAT - The Essence
109
+
110
+ ### Project Identity
111
+ - **Type**: ${projectAnalysis.type}
112
+ - **Domain**: ${projectAnalysis.domain}
113
+ - **Scope**: ${projectAnalysis.scope}
114
+
115
+ ### Core Capabilities
116
+ ${projectAnalysis.capabilities.map(cap => `- ${cap}`).join('\n')}
117
+
118
+ ### Key Features
119
+ ${projectAnalysis.features.map(feature => `- ${feature}`).join('\n')}
120
+
121
+ ### Architecture Philosophy
122
+ ${projectAnalysis.architecture}
123
+
124
+ ## HOW - The Approach
125
+
126
+ ### Development Methodology
127
+ ${projectAnalysis.methodology}
128
+
129
+ ### Technology Stack
130
+ ${projectAnalysis.techStack.map(tech => `- ${tech}`).join('\n')}
131
+
132
+ ### Code Principles
133
+ ${projectAnalysis.principles.map(principle => `- ${principle}`).join('\n')}
134
+
135
+ ### Quality Standards
136
+ ${projectAnalysis.quality}
137
+
138
+ ## SOUL - The Spirit
139
+
140
+ ### Values
141
+ ${projectAnalysis.values.map(value => `- ${value}`).join('\n')}
142
+
143
+ ### Community
144
+ ${projectAnalysis.community}
145
+
146
+ ### Future Vision
147
+ ${projectAnalysis.future}
148
+
149
+ ### Legacy Goals
150
+ ${projectAnalysis.legacy}
151
+
152
+ ---
153
+
154
+ > **For AI Assistants**: Reference this document when writing code, suggesting architecture changes, or making technical decisions. Ensure all recommendations align with the project's mission, values, and technical approach outlined above.
155
+
156
+ *Generated: ${new Date().toISOString().split('T')[0]} | Limit: 500 lines | Last updated: ${new Date().toLocaleDateString()}*
157
+ `;
158
+ }
159
+
160
+ /**
161
+ * Analyze the project to extract its soul
162
+ */
163
+ async analyzeProject() {
164
+ const packageInfo = await this.getPackageInfo();
165
+ const repoInfo = await this.getRepositoryInfo();
166
+ const codebaseInfo = await this.getCodebaseInfo();
167
+
168
+ // Generate project analysis
169
+ return {
170
+ name: packageInfo.name || path.basename(this.projectPath),
171
+ mission: this.inferMission(packageInfo, repoInfo),
172
+ problem: this.inferProblem(packageInfo, codebaseInfo),
173
+ vision: this.inferVision(packageInfo, repoInfo),
174
+ type: this.inferProjectType(packageInfo, codebaseInfo),
175
+ domain: this.inferDomain(packageInfo, codebaseInfo),
176
+ scope: this.inferScope(packageInfo, codebaseInfo),
177
+ capabilities: this.inferCapabilities(packageInfo, codebaseInfo),
178
+ features: this.inferFeatures(packageInfo, codebaseInfo),
179
+ architecture: this.inferArchitecture(codebaseInfo),
180
+ methodology: this.inferMethodology(codebaseInfo),
181
+ techStack: this.inferTechStack(packageInfo, codebaseInfo),
182
+ principles: this.inferPrinciples(codebaseInfo),
183
+ quality: this.inferQuality(packageInfo, codebaseInfo),
184
+ values: this.inferValues(packageInfo, repoInfo),
185
+ community: this.inferCommunity(packageInfo, repoInfo),
186
+ future: this.inferFuture(packageInfo, repoInfo),
187
+ legacy: this.inferLegacy(packageInfo, repoInfo)
188
+ };
189
+ }
190
+
191
+ /**
192
+ * Get package.json information
193
+ */
194
+ async getPackageInfo() {
195
+ try {
196
+ const packagePath = path.join(this.projectPath, 'package.json');
197
+ const packageContent = await fs.readFile(packagePath, 'utf8');
198
+ return JSON.parse(packageContent);
199
+ } catch {
200
+ return {};
201
+ }
202
+ }
203
+
204
+ /**
205
+ * Get repository information
206
+ */
207
+ async getRepositoryInfo() {
208
+ const info = { hasGit: false, files: [] };
209
+
210
+ try {
211
+ await fs.access(path.join(this.projectPath, '.git'));
212
+ info.hasGit = true;
213
+ } catch {}
214
+
215
+ try {
216
+ const files = await fs.readdir(this.projectPath);
217
+ info.files = files;
218
+ } catch {}
219
+
220
+ return info;
221
+ }
222
+
223
+ /**
224
+ * Get codebase structure information
225
+ */
226
+ async getCodebaseInfo() {
227
+ const info = {
228
+ directories: [],
229
+ languages: new Set(),
230
+ configFiles: [],
231
+ testFiles: [],
232
+ hasTests: false,
233
+ hasDocumentation: false
234
+ };
235
+
236
+ try {
237
+ const entries = await fs.readdir(this.projectPath, { withFileTypes: true });
238
+
239
+ for (const entry of entries) {
240
+ if (entry.isDirectory()) {
241
+ info.directories.push(entry.name);
242
+ } else {
243
+ const ext = path.extname(entry.name).toLowerCase();
244
+ const name = entry.name.toLowerCase();
245
+
246
+ // Track languages
247
+ const languageMap = {
248
+ '.js': 'JavaScript',
249
+ '.ts': 'TypeScript',
250
+ '.py': 'Python',
251
+ '.go': 'Go',
252
+ '.rs': 'Rust',
253
+ '.java': 'Java',
254
+ '.cpp': 'C++',
255
+ '.c': 'C'
256
+ };
257
+
258
+ if (languageMap[ext]) {
259
+ info.languages.add(languageMap[ext]);
260
+ }
261
+
262
+ // Track config files
263
+ if (name.includes('config') || name.includes('.json') ||
264
+ name.includes('.yml') || name.includes('.yaml')) {
265
+ info.configFiles.push(entry.name);
266
+ }
267
+
268
+ // Track test files
269
+ if (name.includes('test') || name.includes('spec')) {
270
+ info.testFiles.push(entry.name);
271
+ info.hasTests = true;
272
+ }
273
+
274
+ // Track documentation
275
+ if (ext === '.md' || name.includes('readme') || name.includes('doc')) {
276
+ info.hasDocumentation = true;
277
+ }
278
+ }
279
+ }
280
+ } catch {}
281
+
282
+ return info;
283
+ }
284
+
285
+ // Inference methods
286
+ inferMission(pkg, repo) {
287
+ if (pkg.description) {
288
+ return pkg.description;
289
+ }
290
+
291
+ const name = pkg.name || path.basename(this.projectPath);
292
+
293
+ if (name.includes('flow') || name.includes('orchestrat')) {
294
+ return "Orchestrate and coordinate complex workflows with intelligent automation";
295
+ }
296
+ if (name.includes('api') || name.includes('server')) {
297
+ return "Provide robust API services and server-side functionality";
298
+ }
299
+ if (name.includes('cli') || name.includes('tool')) {
300
+ return "Deliver powerful command-line tools for developer productivity";
301
+ }
302
+
303
+ return "Solve complex problems through innovative software solutions";
304
+ }
305
+
306
+ inferProblem(pkg, codebase) {
307
+ if (pkg.name?.includes('flow')) {
308
+ return "Complex multi-agent coordination and workflow orchestration requires simplified interfaces while maintaining advanced capabilities";
309
+ }
310
+ if (codebase.languages.has('TypeScript') && codebase.hasTests) {
311
+ return "Enterprise-grade development workflows need reliable, type-safe, and well-tested solutions";
312
+ }
313
+ return "Modern software development requires efficient, maintainable, and scalable solutions";
314
+ }
315
+
316
+ inferVision(pkg, repo) {
317
+ if (pkg.name?.includes('novice')) {
318
+ return "Democratize advanced technology by making it accessible to users of all skill levels";
319
+ }
320
+ return "Create software that empowers users and teams to achieve more with less complexity";
321
+ }
322
+
323
+ inferProjectType(pkg, codebase) {
324
+ if (pkg.bin) return "CLI Tool";
325
+ if (codebase.directories.includes('src') && codebase.directories.includes('tests')) return "Library/Framework";
326
+ if (pkg.dependencies?.express || pkg.dependencies?.fastify) return "Web Service";
327
+ if (codebase.languages.has('TypeScript')) return "TypeScript Application";
328
+ return "Software Project";
329
+ }
330
+
331
+ inferDomain(pkg, codebase) {
332
+ const name = (pkg.name || '').toLowerCase();
333
+ if (name.includes('flow') || name.includes('orchestrat')) return "Workflow Orchestration";
334
+ if (name.includes('ai') || name.includes('ml')) return "Artificial Intelligence";
335
+ if (name.includes('api') || name.includes('web')) return "Web Development";
336
+ if (name.includes('cli') || name.includes('tool')) return "Developer Tools";
337
+ return "Software Development";
338
+ }
339
+
340
+ inferScope(pkg, codebase) {
341
+ const dirCount = codebase.directories.length;
342
+ const langCount = codebase.languages.size;
343
+
344
+ if (dirCount > 10 && langCount > 2) return "Enterprise-scale multi-language platform";
345
+ if (dirCount > 5) return "Medium-scale application with modular architecture";
346
+ return "Focused tool with clear boundaries";
347
+ }
348
+
349
+ inferCapabilities(pkg, codebase) {
350
+ const caps = [];
351
+
352
+ if (pkg.bin) caps.push("Command-line interface execution");
353
+ if (codebase.hasTests) caps.push("Automated testing and validation");
354
+ if (codebase.languages.has('TypeScript')) caps.push("Type-safe development");
355
+ if (pkg.dependencies?.sqlite3) caps.push("Persistent data storage");
356
+ if (pkg.scripts?.build) caps.push("Build and compilation");
357
+ if (pkg.name?.includes('flow')) caps.push("Workflow orchestration and automation");
358
+
359
+ return caps.length > 0 ? caps : ["Core functionality delivery", "Modular architecture"];
360
+ }
361
+
362
+ inferFeatures(pkg, codebase) {
363
+ const features = new Set();
364
+
365
+ if (pkg.scripts) {
366
+ Object.keys(pkg.scripts).forEach(script => {
367
+ if (script.includes('test') && !features.has("testing")) {
368
+ features.add("Comprehensive testing suite");
369
+ features.add("testing");
370
+ }
371
+ if (script.includes('build') && !features.has("build")) {
372
+ features.add("Automated build system");
373
+ features.add("build");
374
+ }
375
+ if (script.includes('dev') && !features.has("dev")) {
376
+ features.add("Development workflow tools");
377
+ features.add("dev");
378
+ }
379
+ });
380
+ }
381
+
382
+ if (codebase.configFiles.length > 0) features.add("Flexible configuration system");
383
+ if (codebase.hasDocumentation) features.add("Comprehensive documentation");
384
+
385
+ // Filter out the marker keys and return as array
386
+ const filteredFeatures = Array.from(features).filter(f =>
387
+ f !== "testing" && f !== "build" && f !== "dev"
388
+ );
389
+
390
+ return filteredFeatures.length > 0 ? filteredFeatures : ["Modular design", "Clean architecture"];
391
+ }
392
+
393
+ inferArchitecture(codebase) {
394
+ if (codebase.directories.includes('src') && codebase.directories.includes('dist')) {
395
+ return "Source-to-distribution compilation with clear separation of concerns";
396
+ }
397
+ if (codebase.directories.includes('lib') || codebase.directories.includes('src')) {
398
+ return "Modular architecture with logical component separation";
399
+ }
400
+ return "Clean, maintainable structure following best practices";
401
+ }
402
+
403
+ inferMethodology(codebase) {
404
+ if (codebase.hasTests && codebase.directories.includes('src')) {
405
+ return "Test-driven development with continuous integration";
406
+ }
407
+ if (codebase.hasTests) {
408
+ return "Quality-first development with automated validation";
409
+ }
410
+ return "Iterative development with focus on maintainability";
411
+ }
412
+
413
+ inferTechStack(pkg, codebase) {
414
+ const stack = [];
415
+
416
+ Array.from(codebase.languages).forEach(lang => stack.push(lang));
417
+
418
+ if (pkg.dependencies?.sqlite3) stack.push("SQLite Database");
419
+ if (pkg.dependencies?.express) stack.push("Express.js");
420
+ if (pkg.dependencies?.react) stack.push("React");
421
+ if (pkg.devDependencies?.jest) stack.push("Jest Testing");
422
+ if (pkg.devDependencies?.typescript) stack.push("TypeScript Compiler");
423
+
424
+ return stack.length > 0 ? stack : ["Modern JavaScript/TypeScript ecosystem"];
425
+ }
426
+
427
+ inferPrinciples(codebase) {
428
+ const principles = ["Clean, readable code"];
429
+
430
+ if (codebase.hasTests) principles.push("Test-driven development");
431
+ if (codebase.languages.has('TypeScript')) principles.push("Type safety and static analysis");
432
+ if (codebase.directories.includes('src')) principles.push("Separation of concerns");
433
+
434
+ principles.push("Progressive enhancement");
435
+ principles.push("Documentation-first approach");
436
+
437
+ return principles;
438
+ }
439
+
440
+ inferQuality(pkg, codebase) {
441
+ let quality = "High standards with ";
442
+
443
+ if (codebase.hasTests) quality += "comprehensive testing, ";
444
+ if (codebase.languages.has('TypeScript')) quality += "type safety, ";
445
+ if (pkg.scripts?.lint) quality += "linting, ";
446
+
447
+ quality += "and continuous improvement";
448
+
449
+ return quality;
450
+ }
451
+
452
+ inferValues(pkg, repo) {
453
+ const values = ["Simplicity without sacrificing power"];
454
+
455
+ if (pkg.name?.includes('novice')) values.push("Accessibility for all skill levels");
456
+ if (pkg.license === 'MIT') values.push("Open source collaboration");
457
+
458
+ values.push("Quality over quantity");
459
+ values.push("User-centric design");
460
+
461
+ return values;
462
+ }
463
+
464
+ inferCommunity(pkg, repo) {
465
+ if (pkg.repository?.url) {
466
+ return `Open source project welcoming contributions. Repository: ${pkg.repository.url}`;
467
+ }
468
+ return "Collaborative development with focus on shared learning and improvement";
469
+ }
470
+
471
+ inferFuture(pkg, repo) {
472
+ if (pkg.name?.includes('flow')) {
473
+ return "Evolve into the premier platform for accessible AI workflow orchestration";
474
+ }
475
+ return "Continuous evolution to meet emerging developer needs and technological advances";
476
+ }
477
+
478
+ inferLegacy(pkg, repo) {
479
+ return "Create lasting impact by making complex technology accessible and empowering developers to build amazing things";
480
+ }
481
+
482
+ /**
483
+ * Create backup of existing file
484
+ */
485
+ async createBackup() {
486
+ try {
487
+ const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
488
+ const backupPath = path.join(this.projectPath, `claude-soul.md.backup.${timestamp}`);
489
+
490
+ const existingContent = await fs.readFile(this.claudeSoulPath, 'utf8');
491
+ await fs.writeFile(backupPath, existingContent, 'utf8');
492
+
493
+ console.log(`📄 Backup created: ${path.basename(backupPath)}`);
494
+ } catch (error) {
495
+ console.warn(`⚠️ Could not create backup: ${error.message}`);
496
+ }
497
+ }
498
+
499
+ /**
500
+ * Simple confirmation prompt for overwriting existing files
501
+ */
502
+ async confirmOverwrite() {
503
+ console.log('⚠️ claude-soul.md exists. Use --force to overwrite or --preview to see changes.');
504
+ return false;
505
+ }
506
+
507
+ /**
508
+ * Check if file exists
509
+ */
510
+ async fileExists(filePath) {
511
+ try {
512
+ await fs.access(filePath);
513
+ return true;
514
+ } catch {
515
+ return false;
516
+ }
517
+ }
518
+
519
+ /**
520
+ * Show preview of what would be generated
521
+ */
522
+ async showPreview() {
523
+ const result = await this.execute({ preview: true });
524
+
525
+ if (result.success) {
526
+ console.log('📄 claude-soul.md Preview:');
527
+ console.log('━'.repeat(50));
528
+ console.log(result.content.substring(0, 1500) + '...');
529
+ console.log('━'.repeat(50));
530
+ console.log(`📊 Total length: ${result.content.length} characters`);
531
+ console.log(`📏 Lines: ${result.content.split('\n').length}`);
532
+ }
533
+
534
+ return result;
535
+ }
536
+ }
537
+
538
+ /**
539
+ * CLI Interface for slash command
540
+ */
541
+ export async function executeClaudeSoulCommand(args = {}) {
542
+ const command = new ClaudeSoulSlashCommand();
543
+
544
+ // Handle different command modes
545
+ if (args.preview) {
546
+ return await command.showPreview();
547
+ }
548
+
549
+ // Default: generate claude-soul.md
550
+ return await command.execute(args);
551
+ }
552
+
553
+ // For direct execution
554
+ if (import.meta.url === `file://${process.argv[1]}`) {
555
+ const args = {
556
+ preview: process.argv.includes('--preview'),
557
+ force: process.argv.includes('--force'),
558
+ backup: !process.argv.includes('--no-backup')
559
+ };
560
+
561
+ executeClaudeSoulCommand(args);
562
+ }