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
@@ -1,17 +1,10 @@
1
1
  #!/usr/bin/env node
2
2
  /**
3
- * Claude-Flow Novice MCP Server - SIMPLIFIED VERSION
3
+ * Claude-Flow Novice MCP Server - SIMPLIFIED STANDALONE VERSION
4
4
  * Only 36 essential tools for beginners
5
- * 80% complexity reduction while preserving core capabilities
5
+ * No external dependencies, completely self-contained
6
6
  */
7
7
 
8
- import { promises as fs } from 'fs';
9
- import path from 'path';
10
- import { fileURLToPath } from 'url';
11
-
12
- const __filename = fileURLToPath(import.meta.url);
13
- const __dirname = path.dirname(__filename);
14
-
15
8
  class ClaudeFlowNoviceMCPServer {
16
9
  constructor() {
17
10
  this.version = '2.0.0-novice-simplified';
@@ -396,7 +389,6 @@ class ClaudeFlowNoviceMCPServer {
396
389
 
397
390
  initializeResources() {
398
391
  return {
399
- // Simple resource definitions for novice users
400
392
  'memory://sessions': {
401
393
  uri: 'memory://sessions',
402
394
  name: 'Memory Sessions',
@@ -443,7 +435,8 @@ class ClaudeFlowNoviceMCPServer {
443
435
  }
444
436
 
445
437
  handleInitialize(params) {
446
- console.error(`[${new Date().toISOString()}] INFO [claude-flow-novice-mcp] (${this.sessionId}) Initialized with ${Object.keys(this.tools).length} tools`);
438
+ const toolCount = Object.keys(this.tools).length;
439
+ console.error(`[${new Date().toISOString()}] INFO [claude-flow-novice-mcp] (${this.sessionId}) Initialized with ${toolCount} tools`);
447
440
  return {
448
441
  protocolVersion: '2024-11-05',
449
442
  capabilities: this.capabilities,
@@ -469,8 +462,6 @@ class ClaudeFlowNoviceMCPServer {
469
462
 
470
463
  console.error(`[${new Date().toISOString()}] INFO [claude-flow-novice-mcp] (${this.sessionId}) Executing tool: ${name}`);
471
464
 
472
- // Simple mock implementations for demonstration
473
- // In a real implementation, these would call actual functionality
474
465
  const result = {
475
466
  success: true,
476
467
  tool: name,
@@ -570,9 +561,18 @@ async function main() {
570
561
  process.exit(0);
571
562
  });
572
563
 
573
- console.error(`[${new Date().toISOString()}] INFO [claude-flow-novice-mcp] Server starting with 36 essential tools`);
564
+ const toolCount = Object.keys(server.tools).length;
565
+ console.error(`[${new Date().toISOString()}] INFO [claude-flow-novice-mcp] Server starting with ${toolCount} essential tools`);
574
566
  }
575
567
 
568
+ // ES module entry point detection
569
+ import { fileURLToPath } from 'url';
570
+ import { dirname } from 'path';
571
+
572
+ const __filename = fileURLToPath(import.meta.url);
573
+ const __dirname = dirname(__filename);
574
+
575
+ // Check if this file is being run directly
576
576
  if (import.meta.url === `file://${process.argv[1]}`) {
577
577
  main().catch((error) => {
578
578
  console.error(`[${new Date().toISOString()}] FATAL [claude-flow-novice-mcp] ${error.message}`);
@@ -0,0 +1,271 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Claude Code Session Start Hook - Soul Integration
5
+ *
6
+ * Automatically feeds claude-soul.md content into Claude Code sessions
7
+ * Handles graceful errors when the file is missing
8
+ */
9
+
10
+ import fs from 'fs/promises';
11
+ import path from 'path';
12
+ import { printSuccess, printError, printWarning } from '../../utils.js';
13
+
14
+ export class SessionStartSoulHook {
15
+ constructor(projectPath = process.cwd()) {
16
+ this.projectPath = projectPath;
17
+ this.claudeSoulPath = path.join(projectPath, 'claude-soul.md');
18
+ this.hookName = 'session-start-soul';
19
+ }
20
+
21
+ /**
22
+ * Execute the session start hook
23
+ */
24
+ async execute(options = {}) {
25
+ const {
26
+ silent = false,
27
+ generateMissing = true,
28
+ fallbackToDefault = true
29
+ } = options;
30
+
31
+ try {
32
+ if (!silent) {
33
+ console.log('🚀 Session Start: Loading project soul...');
34
+ }
35
+
36
+ const soulContent = await this.loadOrGenerateSoul({
37
+ generateMissing,
38
+ fallbackToDefault
39
+ });
40
+
41
+ if (soulContent) {
42
+ // Log the soul loading for integration tracking
43
+ await this.logSoulLoad(soulContent, { silent });
44
+
45
+ if (!silent) {
46
+ printSuccess('✅ Project soul available for Claude Code session');
47
+ console.log(`📖 Soul file: claude-soul.md (${soulContent.length} chars)`);
48
+ }
49
+
50
+ return {
51
+ success: true,
52
+ action: 'soul-loaded',
53
+ contentLength: soulContent.length,
54
+ source: await this.fileExists(this.claudeSoulPath) ? 'file' : 'generated'
55
+ };
56
+ } else {
57
+ if (!silent) {
58
+ printWarning('⚠️ No project soul available - continuing without soul context');
59
+ }
60
+
61
+ return {
62
+ success: true,
63
+ action: 'no-soul',
64
+ message: 'Session started without soul context'
65
+ };
66
+ }
67
+
68
+ } catch (error) {
69
+ if (!silent) {
70
+ printError(`❌ Session start soul hook failed: ${error.message}`);
71
+ }
72
+
73
+ return {
74
+ success: false,
75
+ action: 'error',
76
+ error: error.message
77
+ };
78
+ }
79
+ }
80
+
81
+ /**
82
+ * Load existing soul or generate one if missing
83
+ */
84
+ async loadOrGenerateSoul(options = {}) {
85
+ const { generateMissing = true, fallbackToDefault = true } = options;
86
+
87
+ try {
88
+ // Try to load existing soul file
89
+ if (await this.fileExists(this.claudeSoulPath)) {
90
+ const content = await fs.readFile(this.claudeSoulPath, 'utf8');
91
+ console.log('📖 Loading existing claude-soul.md');
92
+ return content;
93
+ }
94
+
95
+ // File doesn't exist - handle based on options
96
+ if (generateMissing) {
97
+ console.log('🔄 claude-soul.md not found, generating...');
98
+ return await this.generateDefaultSoul();
99
+ }
100
+
101
+ if (fallbackToDefault) {
102
+ console.log('🔄 Using minimal project soul...');
103
+ return this.getMinimalSoul();
104
+ }
105
+
106
+ return null;
107
+
108
+ } catch (error) {
109
+ console.warn(`⚠️ Could not load project soul: ${error.message}`);
110
+
111
+ if (fallbackToDefault) {
112
+ return this.getMinimalSoul();
113
+ }
114
+
115
+ return null;
116
+ }
117
+ }
118
+
119
+ /**
120
+ * Generate a default soul document
121
+ */
122
+ async generateDefaultSoul() {
123
+ try {
124
+ // Import the soul generator
125
+ const { ClaudeSoulSlashCommand } = await import('../../slash-commands/claude-soul.js');
126
+ const generator = new ClaudeSoulSlashCommand(this.projectPath);
127
+
128
+ const result = await generator.execute({ backup: false });
129
+
130
+ if (result.success) {
131
+ const content = await fs.readFile(this.claudeSoulPath, 'utf8');
132
+ console.log('✅ Generated claude-soul.md for session');
133
+ return content;
134
+ } else {
135
+ throw new Error(`Soul generation failed: ${result.error}`);
136
+ }
137
+
138
+ } catch (error) {
139
+ console.warn(`⚠️ Could not generate soul: ${error.message}`);
140
+ return this.getMinimalSoul();
141
+ }
142
+ }
143
+
144
+ /**
145
+ * Get minimal soul content as fallback
146
+ */
147
+ getMinimalSoul() {
148
+ const projectName = path.basename(this.projectPath);
149
+
150
+ return `# ${projectName} - Project Soul
151
+
152
+ ## WHY - The Purpose
153
+ This project aims to solve important problems through software.
154
+
155
+ ## WHAT - The Essence
156
+ A software project focused on delivering value through clean, maintainable code.
157
+
158
+ ## HOW - The Approach
159
+ Following best practices and iterative development.
160
+
161
+ ## SOUL - The Spirit
162
+ Committed to quality, simplicity, and user-centric design.
163
+
164
+ ---
165
+ *Minimal soul context - generate full claude-soul.md for complete project essence*
166
+ `;
167
+ }
168
+
169
+ /**
170
+ * Log soul loading for integration tracking
171
+ */
172
+ async logSoulLoad(soulContent, options = {}) {
173
+ const { silent = false } = options;
174
+
175
+ try {
176
+ if (!silent) {
177
+ console.log('📋 Project soul ready for Claude Code session context');
178
+ }
179
+
180
+ // Log hook execution for integration with other systems
181
+ await this.logHookExecution(soulContent);
182
+
183
+ } catch (error) {
184
+ console.warn(`⚠️ Could not log soul loading: ${error.message}`);
185
+ }
186
+ }
187
+
188
+ /**
189
+ * Log hook execution for integration with other systems
190
+ */
191
+ async logHookExecution(soulContent) {
192
+ try {
193
+ // Try to use memory store if available
194
+ const { SqliteMemoryStore } = await import('../../../memory/sqlite-store.js');
195
+ const store = new SqliteMemoryStore();
196
+ await store.initialize();
197
+
198
+ const hookData = {
199
+ hookName: this.hookName,
200
+ executedAt: new Date().toISOString(),
201
+ soulContentLength: soulContent.length,
202
+ soulPreview: soulContent.substring(0, 200) + '...',
203
+ projectPath: this.projectPath
204
+ };
205
+
206
+ await store.store(`session-start:${Date.now()}`, hookData, {
207
+ namespace: 'session-hooks',
208
+ metadata: { type: 'session-start', hook: this.hookName }
209
+ });
210
+
211
+ store.close();
212
+
213
+ } catch (error) {
214
+ // Silent fail - memory store is optional
215
+ }
216
+ }
217
+
218
+ /**
219
+ * Check if file exists
220
+ */
221
+ async fileExists(filePath) {
222
+ try {
223
+ await fs.access(filePath);
224
+ return true;
225
+ } catch {
226
+ return false;
227
+ }
228
+ }
229
+
230
+ /**
231
+ * Clean up (no files to clean since we use claude-soul.md directly)
232
+ */
233
+ async cleanup() {
234
+ // No cleanup needed since we read claude-soul.md directly
235
+ console.log('🧹 Session soul cleanup completed (no temporary files)');
236
+ }
237
+ }
238
+
239
+ /**
240
+ * Execute the session start soul hook
241
+ */
242
+ export async function executeSessionStartSoulHook(args = {}) {
243
+ const hook = new SessionStartSoulHook();
244
+
245
+ const options = {
246
+ silent: args.silent || args.includes('--silent'),
247
+ generateMissing: !args.includes('--no-generate'),
248
+ fallbackToDefault: !args.includes('--no-fallback')
249
+ };
250
+
251
+ return await hook.execute(options);
252
+ }
253
+
254
+ /**
255
+ * Execute session end cleanup
256
+ */
257
+ export async function executeSessionEndSoulHook() {
258
+ const hook = new SessionStartSoulHook();
259
+ return await hook.cleanup();
260
+ }
261
+
262
+ // For direct execution
263
+ if (import.meta.url === `file://${process.argv[1]}`) {
264
+ const args = process.argv.slice(2);
265
+
266
+ if (args.includes('--cleanup') || args.includes('cleanup')) {
267
+ executeSessionEndSoulHook();
268
+ } else {
269
+ executeSessionStartSoulHook(args);
270
+ }
271
+ }
@@ -0,0 +1,157 @@
1
+ # CLAUDE.md Slash Command System
2
+
3
+ ## 🎯 Simple, Focused CLAUDE.md Generation
4
+
5
+ A lightweight slash command system for generating CLAUDE.md files with NPX protection.
6
+
7
+ ## 📋 Features
8
+
9
+ ### ✅ **Simple Slash Command**
10
+ ```bash
11
+ /claude-md # Generate CLAUDE.md for current project
12
+ /claude-md --preview # Show what would be generated
13
+ /claude-md --force # Overwrite without confirmation
14
+ /claude-md --detect # Auto-detect project and show recommendations
15
+ /claude-md --no-backup # Skip backup creation
16
+ ```
17
+
18
+ ### 🛡️ **NPX Protection System**
19
+ - **Problem**: NPX installs overwrite customized CLAUDE.md files
20
+ - **Solution**: Generate `claude-copy-to-main.md` when existing CLAUDE.md detected
21
+ - **Benefit**: User customizations are never lost
22
+
23
+ ### 🔄 **Integration Flow**
24
+
25
+ **Normal Usage (Slash Command):**
26
+ 1. User runs `/claude-md`
27
+ 2. System detects project type
28
+ 3. Generates appropriate CLAUDE.md
29
+ 4. Creates backup if file exists
30
+
31
+ **NPX Install Protection:**
32
+ 1. NPX installs claude-flow-novice
33
+ 2. `postinstall` script runs
34
+ 3. Detects existing CLAUDE.md
35
+ 4. Creates `claude-copy-to-main.md` instead
36
+ 5. User manually merges desired changes
37
+
38
+ ## 🏗️ Architecture
39
+
40
+ ### **Files:**
41
+ - `claude-md.js` - Core slash command implementation
42
+ - `register-claude-md.js` - Slash command registration
43
+ - `../npx/claude-md-protection.js` - NPX protection logic
44
+ - `../../scripts/post-install-claude-md.js` - Post-install hook
45
+
46
+ ### **Integration Points:**
47
+ - **Existing Generator**: Uses `../language/claude-md-generator.js`
48
+ - **Language Detection**: Uses `../language/language-detector.js`
49
+ - **Preferences**: Reads `.claude-flow-novice/preferences/generation.json`
50
+ - **Package.json**: `postinstall` script triggers protection
51
+
52
+ ## 🎮 Usage Examples
53
+
54
+ ### **Basic Generation:**
55
+ ```bash
56
+ # Generate CLAUDE.md for current project
57
+ /claude-md
58
+
59
+ # Output:
60
+ # 🚀 Generating CLAUDE.md...
61
+ # ✅ CLAUDE.md generated successfully
62
+ ```
63
+
64
+ ### **Preview Mode:**
65
+ ```bash
66
+ # See what would be generated
67
+ /claude-md --preview
68
+
69
+ # Output:
70
+ # 📄 CLAUDE.md Preview:
71
+ # ══════════════════════════════════════════════════
72
+ # # Claude Code Configuration - JavaScript Project
73
+ # ...
74
+ # ══════════════════════════════════════════════════
75
+ # 📊 Total length: 2,847 characters
76
+ ```
77
+
78
+ ### **NPX Protection:**
79
+ ```bash
80
+ # When NPX detects existing CLAUDE.md
81
+ npm install claude-flow-novice
82
+
83
+ # Output:
84
+ # 🛡️ NPX Protection Activated
85
+ # 📄 Generated: claude-copy-to-main.md
86
+ # 💡 Your existing CLAUDE.md is protected from overwrite
87
+ # 🔄 Review and merge changes manually as needed
88
+ ```
89
+
90
+ ## 🧠 Smart Detection
91
+
92
+ ### **Project Type Detection:**
93
+ - Analyzes `package.json`, file patterns, and directory structure
94
+ - Detects frameworks (React, Express, Django, etc.)
95
+ - Suggests appropriate CLAUDE.md configurations
96
+
97
+ ### **Confidence Levels:**
98
+ - **High (>70%)**: Automatic generation recommended
99
+ - **Medium (30-70%)**: Generate with user confirmation
100
+ - **Low (<30%)**: Manual review suggested
101
+
102
+ ## 🔧 Configuration
103
+
104
+ ### **Generation Preferences:**
105
+ `.claude-flow-novice/preferences/generation.json`:
106
+ ```json
107
+ {
108
+ "autoGenerate": true,
109
+ "includeFrameworkSpecific": true,
110
+ "includeBestPractices": true,
111
+ "backupExisting": true,
112
+ "confidenceThreshold": 0.3
113
+ }
114
+ ```
115
+
116
+ ### **NPX Detection:**
117
+ - Environment variables (`NPX_INSTALL=true`)
118
+ - Temporary directory patterns (`/.npm/_npx/`)
119
+ - Package.json analysis (fresh installs)
120
+
121
+ ## 🎯 Design Principles
122
+
123
+ ### **Keep It Simple:**
124
+ - Single focused command
125
+ - Minimal configuration
126
+ - Clear user feedback
127
+ - No feature bloat
128
+
129
+ ### **Protect User Work:**
130
+ - Never overwrite without permission
131
+ - Always offer backup options
132
+ - Provide clear merge instructions
133
+ - Preserve customizations
134
+
135
+ ### **Smart Defaults:**
136
+ - Auto-detect project type
137
+ - Use appropriate templates
138
+ - Respect user preferences
139
+ - Fail safely
140
+
141
+ ## 🚀 Future Enhancements
142
+
143
+ ### **Potential Improvements (If Needed):**
144
+ - Interactive confirmation prompts
145
+ - Template customization options
146
+ - Multi-project detection
147
+ - Advanced merge assistance
148
+
149
+ ### **Not Planned (Avoiding Bloat):**
150
+ - SQLite analysis integration
151
+ - Multi-file scaffolding
152
+ - Complex workflow automation
153
+ - Enterprise features
154
+
155
+ ---
156
+
157
+ **Simple, focused, and protective - exactly what CLAUDE.md generation should be!** 🎯