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.
- package/dist/mcp/mcp-server-novice.js +14 -14
- package/dist/src/cli/simple-commands/hooks/session-start-soul.js +271 -0
- package/dist/src/slash-commands/README.md +157 -0
- package/dist/src/slash-commands/claude-md.js +237 -0
- package/dist/src/slash-commands/claude-soul.js +562 -0
- package/dist/src/slash-commands/cli-integration.js +216 -0
- package/dist/src/slash-commands/github.js +638 -0
- package/dist/src/slash-commands/hooks.js +648 -0
- package/dist/src/slash-commands/index.js +115 -0
- package/dist/src/slash-commands/neural.js +572 -0
- package/dist/src/slash-commands/performance.js +582 -0
- package/dist/src/slash-commands/register-all-commands.js +314 -0
- package/dist/src/slash-commands/register-claude-md.js +82 -0
- package/dist/src/slash-commands/register-claude-soul.js +80 -0
- package/dist/src/slash-commands/sparc.js +110 -0
- package/dist/src/slash-commands/swarm.js +423 -0
- package/dist/src/slash-commands/validate-commands.js +223 -0
- package/dist/src/slash-commands/workflow.js +606 -0
- package/package.json +8 -7
- package/src/slash-commands/cli-integration.js +216 -0
- package/src/slash-commands/github.js +638 -0
- package/src/slash-commands/hooks.js +648 -0
- package/src/slash-commands/index.js +115 -0
- package/src/slash-commands/neural.js +572 -0
- package/src/slash-commands/performance.js +582 -0
- package/src/slash-commands/register-all-commands.js +314 -0
- package/src/slash-commands/sparc.js +110 -0
- package/src/slash-commands/swarm.js +423 -0
- package/src/slash-commands/validate-commands.js +223 -0
- package/src/slash-commands/workflow.js +606 -0
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* CLAUDE.md Slash Command
|
|
5
|
+
*
|
|
6
|
+
* Simple wrapper around the existing CLAUDE.md generator with NPX protection
|
|
7
|
+
* Keeps it focused and lightweight - no bloat!
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { ClaudeMdGenerator } from '../language/claude-md-generator.js';
|
|
11
|
+
import { LanguageDetector } from '../language/language-detector.js';
|
|
12
|
+
import fs from 'fs/promises';
|
|
13
|
+
import path from 'path';
|
|
14
|
+
|
|
15
|
+
export class ClaudeMdSlashCommand {
|
|
16
|
+
constructor(projectPath = process.cwd()) {
|
|
17
|
+
this.projectPath = projectPath;
|
|
18
|
+
this.claudeMdPath = path.join(projectPath, 'CLAUDE.md');
|
|
19
|
+
this.copyToMainPath = path.join(projectPath, 'claude-copy-to-main.md');
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Main slash command execution
|
|
24
|
+
*/
|
|
25
|
+
async execute(options = {}) {
|
|
26
|
+
const {
|
|
27
|
+
backup = true,
|
|
28
|
+
preview = false,
|
|
29
|
+
force = false,
|
|
30
|
+
isNpxInstall = false
|
|
31
|
+
} = options;
|
|
32
|
+
|
|
33
|
+
try {
|
|
34
|
+
console.log('🚀 Generating CLAUDE.md...');
|
|
35
|
+
|
|
36
|
+
// Step 1: Detect if this is an NPX install scenario
|
|
37
|
+
const existingClaudeExists = await this.fileExists(this.claudeMdPath);
|
|
38
|
+
const shouldUseNpxProtection = isNpxInstall && existingClaudeExists;
|
|
39
|
+
|
|
40
|
+
// Step 2: Generate content using existing system
|
|
41
|
+
const generator = new ClaudeMdGenerator(this.projectPath, {
|
|
42
|
+
backupExisting: backup && !shouldUseNpxProtection,
|
|
43
|
+
preserveCustomSections: true
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
const newContent = await generator.generateClaudeMd();
|
|
47
|
+
|
|
48
|
+
// Step 3: Handle NPX protection
|
|
49
|
+
if (shouldUseNpxProtection) {
|
|
50
|
+
await this.handleNpxProtection(newContent);
|
|
51
|
+
return {
|
|
52
|
+
success: true,
|
|
53
|
+
action: 'npx-protection',
|
|
54
|
+
file: 'claude-copy-to-main.md',
|
|
55
|
+
message: 'Generated claude-copy-to-main.md to protect your existing CLAUDE.md'
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// Step 4: Handle preview mode
|
|
60
|
+
if (preview) {
|
|
61
|
+
return {
|
|
62
|
+
success: true,
|
|
63
|
+
action: 'preview',
|
|
64
|
+
content: newContent,
|
|
65
|
+
message: 'Preview generated successfully'
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// Step 5: Handle force/confirmation for existing files
|
|
70
|
+
if (existingClaudeExists && !force) {
|
|
71
|
+
const shouldOverwrite = await this.confirmOverwrite();
|
|
72
|
+
if (!shouldOverwrite) {
|
|
73
|
+
return {
|
|
74
|
+
success: false,
|
|
75
|
+
action: 'cancelled',
|
|
76
|
+
message: 'Generation cancelled by user'
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// Step 6: Write the file
|
|
82
|
+
await fs.writeFile(this.claudeMdPath, newContent, 'utf8');
|
|
83
|
+
|
|
84
|
+
console.log('✅ CLAUDE.md generated successfully');
|
|
85
|
+
return {
|
|
86
|
+
success: true,
|
|
87
|
+
action: 'generated',
|
|
88
|
+
file: 'CLAUDE.md',
|
|
89
|
+
length: newContent.length
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
} catch (error) {
|
|
93
|
+
console.error('❌ CLAUDE.md generation failed:', error.message);
|
|
94
|
+
return {
|
|
95
|
+
success: false,
|
|
96
|
+
action: 'error',
|
|
97
|
+
error: error.message
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* NPX Protection: Generate claude-copy-to-main.md instead of overwriting
|
|
104
|
+
*/
|
|
105
|
+
async handleNpxProtection(newContent) {
|
|
106
|
+
const protectedContent = this.createProtectedContent(newContent);
|
|
107
|
+
|
|
108
|
+
await fs.writeFile(this.copyToMainPath, protectedContent, 'utf8');
|
|
109
|
+
|
|
110
|
+
console.log('🛡️ NPX Protection Activated');
|
|
111
|
+
console.log('📄 Generated: claude-copy-to-main.md');
|
|
112
|
+
console.log('💡 Your existing CLAUDE.md is protected from overwrite');
|
|
113
|
+
console.log('🔄 Review and merge changes manually as needed');
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Create content for the protected file with merge instructions
|
|
118
|
+
*/
|
|
119
|
+
createProtectedContent(newContent) {
|
|
120
|
+
return `# 🛡️ NPX-Protected CLAUDE.md Content
|
|
121
|
+
|
|
122
|
+
## 📋 Merge Instructions
|
|
123
|
+
|
|
124
|
+
This file was generated because you have an existing CLAUDE.md file.
|
|
125
|
+
To protect your customizations from being overwritten by NPX installs,
|
|
126
|
+
the new content is provided here for manual review and merging.
|
|
127
|
+
|
|
128
|
+
### 🔄 How to Merge:
|
|
129
|
+
1. Review the content below
|
|
130
|
+
2. Copy sections you want to your main CLAUDE.md
|
|
131
|
+
3. Delete this file when done
|
|
132
|
+
4. Your customizations remain safe!
|
|
133
|
+
|
|
134
|
+
---
|
|
135
|
+
|
|
136
|
+
# Generated CLAUDE.md Content
|
|
137
|
+
|
|
138
|
+
${newContent}
|
|
139
|
+
|
|
140
|
+
---
|
|
141
|
+
|
|
142
|
+
## 🗑️ Cleanup
|
|
143
|
+
Delete this file after merging: \`rm claude-copy-to-main.md\`
|
|
144
|
+
`;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Simple confirmation prompt for overwriting existing files
|
|
149
|
+
*/
|
|
150
|
+
async confirmOverwrite() {
|
|
151
|
+
// In a real implementation, this would use readline or similar
|
|
152
|
+
// For now, return true (could be enhanced with proper prompting)
|
|
153
|
+
console.log('⚠️ CLAUDE.md exists. Use --force to overwrite or --preview to see changes.');
|
|
154
|
+
return false;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Check if file exists
|
|
159
|
+
*/
|
|
160
|
+
async fileExists(filePath) {
|
|
161
|
+
try {
|
|
162
|
+
await fs.access(filePath);
|
|
163
|
+
return true;
|
|
164
|
+
} catch {
|
|
165
|
+
return false;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Show preview of what would be generated
|
|
171
|
+
*/
|
|
172
|
+
async showPreview() {
|
|
173
|
+
const result = await this.execute({ preview: true });
|
|
174
|
+
|
|
175
|
+
if (result.success) {
|
|
176
|
+
console.log('📄 CLAUDE.md Preview:');
|
|
177
|
+
console.log('━'.repeat(50));
|
|
178
|
+
console.log(result.content.substring(0, 1000) + '...');
|
|
179
|
+
console.log('━'.repeat(50));
|
|
180
|
+
console.log(`📊 Total length: ${result.content.length} characters`);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
return result;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Auto-detect project and suggest generation
|
|
188
|
+
*/
|
|
189
|
+
async autoDetectAndSuggest() {
|
|
190
|
+
const detector = new LanguageDetector(this.projectPath);
|
|
191
|
+
const detection = await detector.detectProject();
|
|
192
|
+
|
|
193
|
+
console.log('🔍 Project Detection Results:');
|
|
194
|
+
console.log(` Type: ${detection.projectType}`);
|
|
195
|
+
console.log(` Confidence: ${(detection.confidence * 100).toFixed(1)}%`);
|
|
196
|
+
|
|
197
|
+
if (detection.confidence > 0.7) {
|
|
198
|
+
console.log('💡 High confidence - CLAUDE.md generation recommended');
|
|
199
|
+
return true;
|
|
200
|
+
} else {
|
|
201
|
+
console.log('⚠️ Low confidence - manual review recommended');
|
|
202
|
+
return false;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* CLI Interface for slash command
|
|
209
|
+
*/
|
|
210
|
+
export async function executeClaudeMdCommand(args = {}) {
|
|
211
|
+
const command = new ClaudeMdSlashCommand();
|
|
212
|
+
|
|
213
|
+
// Handle different command modes
|
|
214
|
+
if (args.preview) {
|
|
215
|
+
return await command.showPreview();
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
if (args.detect) {
|
|
219
|
+
return await command.autoDetectAndSuggest();
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
// Default: generate CLAUDE.md
|
|
223
|
+
return await command.execute(args);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
// For direct execution
|
|
227
|
+
if (import.meta.url === `file://${process.argv[1]}`) {
|
|
228
|
+
const args = {
|
|
229
|
+
preview: process.argv.includes('--preview'),
|
|
230
|
+
force: process.argv.includes('--force'),
|
|
231
|
+
backup: !process.argv.includes('--no-backup'),
|
|
232
|
+
detect: process.argv.includes('--detect'),
|
|
233
|
+
isNpxInstall: process.env.NPX_INSTALL === 'true'
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
executeClaudeMdCommand(args);
|
|
237
|
+
}
|