claude-flow-novice 1.3.1 โ 1.3.3
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/commands/coordination/coordination-system.md +88 -0
- package/.claude/commands/memory/memory-bank.md +58 -0
- package/package.json +2 -1
- package/src/language/README.md +503 -0
- package/src/language/claude-md-generator.js +618 -0
- package/src/language/cli.js +422 -0
- package/src/language/example.js +347 -0
- package/src/language/integration-system.js +619 -0
- package/src/language/language-detector.js +581 -0
|
@@ -0,0 +1,422 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { program } from 'commander';
|
|
4
|
+
import { LanguageDetector } from './language-detector.js';
|
|
5
|
+
import { ClaudeMdGenerator } from './claude-md-generator.js';
|
|
6
|
+
import { IntegrationSystem } from './integration-system.js';
|
|
7
|
+
import path from 'path';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Claude Flow Language Detection CLI
|
|
11
|
+
*
|
|
12
|
+
* Command-line interface for language detection and CLAUDE.md generation
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
program
|
|
16
|
+
.name('claude-flow-lang')
|
|
17
|
+
.description('Intelligent language detection and CLAUDE.md generation for Claude Flow')
|
|
18
|
+
.version('1.0.0');
|
|
19
|
+
|
|
20
|
+
// Main detect command
|
|
21
|
+
program
|
|
22
|
+
.command('detect')
|
|
23
|
+
.description('Detect languages and frameworks in current project')
|
|
24
|
+
.option('-p, --path <path>', 'Project path', process.cwd())
|
|
25
|
+
.option('-v, --verbose', 'Verbose output')
|
|
26
|
+
.option('-j, --json', 'Output as JSON')
|
|
27
|
+
.action(async (options) => {
|
|
28
|
+
try {
|
|
29
|
+
console.log('๐ Detecting project languages and frameworks...');
|
|
30
|
+
|
|
31
|
+
const detector = new LanguageDetector(options.path);
|
|
32
|
+
const results = await detector.detectProject();
|
|
33
|
+
|
|
34
|
+
if (options.json) {
|
|
35
|
+
console.log(JSON.stringify(results, null, 2));
|
|
36
|
+
} else {
|
|
37
|
+
console.log('\n๐ Detection Results:');
|
|
38
|
+
console.log('โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ');
|
|
39
|
+
|
|
40
|
+
console.log(`\n๐ฏ Project Type: ${results.projectType}`);
|
|
41
|
+
console.log(`๐ Confidence: ${(results.confidence * 100).toFixed(1)}%`);
|
|
42
|
+
|
|
43
|
+
if (Object.keys(results.languages).length > 0) {
|
|
44
|
+
console.log('\n๐ป Languages:');
|
|
45
|
+
for (const [lang, score] of Object.entries(results.languages)) {
|
|
46
|
+
const percentage = (score * 100).toFixed(1);
|
|
47
|
+
const bar = 'โ'.repeat(Math.floor(score * 20));
|
|
48
|
+
console.log(` ${lang.padEnd(15)} ${bar.padEnd(20)} ${percentage}%`);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (Object.keys(results.frameworks).length > 0) {
|
|
53
|
+
console.log('\n๐ Frameworks:');
|
|
54
|
+
for (const [framework, score] of Object.entries(results.frameworks)) {
|
|
55
|
+
const percentage = (score * 100).toFixed(1);
|
|
56
|
+
const bar = 'โ'.repeat(Math.floor(score * 20));
|
|
57
|
+
console.log(` ${framework.padEnd(15)} ${bar.padEnd(20)} ${percentage}%`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (Object.keys(results.dependencies).length > 0 && options.verbose) {
|
|
62
|
+
console.log('\n๐ฆ Dependencies:');
|
|
63
|
+
const deps = Object.keys(results.dependencies).slice(0, 10);
|
|
64
|
+
console.log(
|
|
65
|
+
` ${deps.join(', ')}${Object.keys(results.dependencies).length > 10 ? '...' : ''}`,
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const recommendations = detector.getRecommendations();
|
|
70
|
+
if (recommendations.linting.length > 0) {
|
|
71
|
+
console.log(`\n๐ก Recommended Tools:`);
|
|
72
|
+
console.log(` Linting: ${recommendations.linting.join(', ')}`);
|
|
73
|
+
console.log(` Testing: ${recommendations.testing.join(', ')}`);
|
|
74
|
+
if (recommendations.building.length > 0) {
|
|
75
|
+
console.log(` Building: ${recommendations.building.join(', ')}`);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
} catch (error) {
|
|
80
|
+
console.error('โ Detection failed:', error.message);
|
|
81
|
+
if (options.verbose) {
|
|
82
|
+
console.error(error.stack);
|
|
83
|
+
}
|
|
84
|
+
process.exit(1);
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
// Generate CLAUDE.md command
|
|
89
|
+
program
|
|
90
|
+
.command('generate')
|
|
91
|
+
.description('Generate CLAUDE.md file based on detected languages')
|
|
92
|
+
.option('-p, --path <path>', 'Project path', process.cwd())
|
|
93
|
+
.option('-f, --force', 'Force regeneration even if file exists')
|
|
94
|
+
.option('--no-backup', 'Skip creating backup of existing file')
|
|
95
|
+
.option('-t, --template <path>', 'Custom template path')
|
|
96
|
+
.action(async (options) => {
|
|
97
|
+
try {
|
|
98
|
+
console.log('๐ Generating CLAUDE.md file...');
|
|
99
|
+
|
|
100
|
+
const generator = new ClaudeMdGenerator(options.path, {
|
|
101
|
+
backupExisting: options.backup,
|
|
102
|
+
templatePath: options.template,
|
|
103
|
+
forceRegenerate: options.force,
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
const content = await generator.generateClaudeMd();
|
|
107
|
+
|
|
108
|
+
console.log(`โ
CLAUDE.md generated successfully (${content.length} characters)`);
|
|
109
|
+
console.log(`๐ File location: ${path.join(options.path, 'CLAUDE.md')}`);
|
|
110
|
+
} catch (error) {
|
|
111
|
+
console.error('โ Generation failed:', error.message);
|
|
112
|
+
process.exit(1);
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
// Initialize project command
|
|
117
|
+
program
|
|
118
|
+
.command('init')
|
|
119
|
+
.description('Initialize language detection and CLAUDE.md generation for project')
|
|
120
|
+
.option('-p, --path <path>', 'Project path', process.cwd())
|
|
121
|
+
.option('-i, --interactive', 'Run interactive setup')
|
|
122
|
+
.option('--skip-validation', 'Skip project validation')
|
|
123
|
+
.action(async (options) => {
|
|
124
|
+
try {
|
|
125
|
+
console.log('๐ Initializing Claude Flow language detection...');
|
|
126
|
+
|
|
127
|
+
const integration = new IntegrationSystem(options.path);
|
|
128
|
+
|
|
129
|
+
if (options.interactive) {
|
|
130
|
+
console.log('๐ฏ Starting interactive setup...');
|
|
131
|
+
await integration.interactiveSetup();
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
if (!options.skipValidation) {
|
|
135
|
+
console.log('๐ Validating project...');
|
|
136
|
+
const validation = await integration.validateProject();
|
|
137
|
+
|
|
138
|
+
if (validation.issues.length > 0) {
|
|
139
|
+
console.log('โ ๏ธ Validation issues found:');
|
|
140
|
+
validation.issues.forEach((issue) => {
|
|
141
|
+
console.log(` โข ${issue.message}`);
|
|
142
|
+
if (issue.suggestion) {
|
|
143
|
+
console.log(` ๐ก ${issue.suggestion}`);
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
if (validation.suggestions.length > 0) {
|
|
149
|
+
console.log('๐ก Suggestions:');
|
|
150
|
+
validation.suggestions.forEach((suggestion) => {
|
|
151
|
+
console.log(` โข ${suggestion.message}`);
|
|
152
|
+
if (suggestion.suggestion) {
|
|
153
|
+
console.log(` โ ${suggestion.suggestion}`);
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
const result = await integration.initialize();
|
|
160
|
+
|
|
161
|
+
if (result.skipped) {
|
|
162
|
+
console.log(`โญ๏ธ Initialization skipped: ${result.reason}`);
|
|
163
|
+
} else {
|
|
164
|
+
console.log('โ
Initialization completed successfully');
|
|
165
|
+
console.log(`๐ Detected: ${Object.keys(result.detection.languages).join(', ')}`);
|
|
166
|
+
if (result.claudeGenerated) {
|
|
167
|
+
console.log('๐ CLAUDE.md file generated');
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
} catch (error) {
|
|
171
|
+
console.error('โ Initialization failed:', error.message);
|
|
172
|
+
process.exit(1);
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
// Update command for when new technologies are added
|
|
177
|
+
program
|
|
178
|
+
.command('update')
|
|
179
|
+
.description('Update CLAUDE.md when new languages/frameworks are detected')
|
|
180
|
+
.option('-p, --path <path>', 'Project path', process.cwd())
|
|
181
|
+
.option('-c, --check-only', "Only check for changes, don't update")
|
|
182
|
+
.action(async (options) => {
|
|
183
|
+
try {
|
|
184
|
+
console.log('๐ Checking for project changes...');
|
|
185
|
+
|
|
186
|
+
const integration = new IntegrationSystem(options.path);
|
|
187
|
+
const result = await integration.updateForNewTechnology();
|
|
188
|
+
|
|
189
|
+
if (result.changes.hasChanges) {
|
|
190
|
+
console.log(`๐ Changes detected: ${result.changes.summary}`);
|
|
191
|
+
|
|
192
|
+
if (result.changes.newTechnologies.length > 0) {
|
|
193
|
+
console.log('๐ New technologies:');
|
|
194
|
+
result.changes.newTechnologies.forEach((tech) => {
|
|
195
|
+
console.log(` โข ${tech.name} (${tech.type})`);
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
if (!options.checkOnly && result.updated) {
|
|
200
|
+
console.log('โ
CLAUDE.md updated successfully');
|
|
201
|
+
} else if (options.checkOnly) {
|
|
202
|
+
console.log('๐ Check complete - use "update" without --check-only to apply changes');
|
|
203
|
+
}
|
|
204
|
+
} else {
|
|
205
|
+
console.log('โจ No changes detected');
|
|
206
|
+
}
|
|
207
|
+
} catch (error) {
|
|
208
|
+
console.error('โ Update failed:', error.message);
|
|
209
|
+
process.exit(1);
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
// Report command
|
|
214
|
+
program
|
|
215
|
+
.command('report')
|
|
216
|
+
.description('Generate comprehensive project analysis report')
|
|
217
|
+
.option('-p, --path <path>', 'Project path', process.cwd())
|
|
218
|
+
.option('-o, --output <file>', 'Output file path')
|
|
219
|
+
.option('--json', 'Output as JSON')
|
|
220
|
+
.action(async (options) => {
|
|
221
|
+
try {
|
|
222
|
+
console.log('๐ Generating project report...');
|
|
223
|
+
|
|
224
|
+
const integration = new IntegrationSystem(options.path);
|
|
225
|
+
const report = await integration.generateProjectReport();
|
|
226
|
+
|
|
227
|
+
if (options.output) {
|
|
228
|
+
const fs = await import('fs/promises');
|
|
229
|
+
await fs.writeFile(options.output, JSON.stringify(report, null, 2));
|
|
230
|
+
console.log(`๐ Report saved to: ${options.output}`);
|
|
231
|
+
} else if (options.json) {
|
|
232
|
+
console.log(JSON.stringify(report, null, 2));
|
|
233
|
+
} else {
|
|
234
|
+
// Display formatted report
|
|
235
|
+
console.log('\n๐ Project Analysis Report');
|
|
236
|
+
console.log('โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ');
|
|
237
|
+
|
|
238
|
+
console.log(`\n๐๏ธ Project: ${report.project.name}`);
|
|
239
|
+
console.log(`๐ Path: ${report.project.path}`);
|
|
240
|
+
console.log(`๐
Analyzed: ${new Date(report.project.analyzedAt).toLocaleString()}`);
|
|
241
|
+
|
|
242
|
+
console.log(`\n๐ฏ Project Type: ${report.detection.projectType}`);
|
|
243
|
+
console.log(`๐ Detection Confidence: ${(report.detection.confidence * 100).toFixed(1)}%`);
|
|
244
|
+
|
|
245
|
+
if (report.validation.issues.length > 0) {
|
|
246
|
+
console.log(`\nโ ๏ธ Issues Found:`);
|
|
247
|
+
report.validation.issues.forEach((issue) => {
|
|
248
|
+
console.log(` โข ${issue.message}`);
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
if (report.suggestions.length > 0) {
|
|
253
|
+
console.log(`\n๐ก Recommendations:`);
|
|
254
|
+
report.suggestions.forEach((suggestion) => {
|
|
255
|
+
const priority =
|
|
256
|
+
suggestion.priority === 'high'
|
|
257
|
+
? '๐ด'
|
|
258
|
+
: suggestion.priority === 'medium'
|
|
259
|
+
? '๐ก'
|
|
260
|
+
: '๐ข';
|
|
261
|
+
console.log(` ${priority} ${suggestion.message}`);
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
if (report.nextSteps.length > 0) {
|
|
266
|
+
console.log(`\n๐ Next Steps:`);
|
|
267
|
+
report.nextSteps.forEach((step, index) => {
|
|
268
|
+
console.log(` ${index + 1}. ${step}`);
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
} catch (error) {
|
|
273
|
+
console.error('โ Report generation failed:', error.message);
|
|
274
|
+
process.exit(1);
|
|
275
|
+
}
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
// Validate command
|
|
279
|
+
program
|
|
280
|
+
.command('validate')
|
|
281
|
+
.description('Validate project structure and configuration')
|
|
282
|
+
.option('-p, --path <path>', 'Project path', process.cwd())
|
|
283
|
+
.option('--json', 'Output as JSON')
|
|
284
|
+
.action(async (options) => {
|
|
285
|
+
try {
|
|
286
|
+
console.log('๐ Validating project...');
|
|
287
|
+
|
|
288
|
+
const integration = new IntegrationSystem(options.path);
|
|
289
|
+
const validation = await integration.validateProject();
|
|
290
|
+
|
|
291
|
+
if (options.json) {
|
|
292
|
+
console.log(JSON.stringify(validation, null, 2));
|
|
293
|
+
} else {
|
|
294
|
+
console.log(`\n๐ Validation Results`);
|
|
295
|
+
console.log('โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ');
|
|
296
|
+
|
|
297
|
+
if (validation.valid) {
|
|
298
|
+
console.log('โ
Project validation passed');
|
|
299
|
+
} else {
|
|
300
|
+
console.log('โ ๏ธ Project validation found issues');
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
if (validation.issues.length > 0) {
|
|
304
|
+
console.log(`\nโ Issues (${validation.issues.length}):`);
|
|
305
|
+
validation.issues.forEach((issue) => {
|
|
306
|
+
console.log(` โข ${issue.message}`);
|
|
307
|
+
if (issue.suggestion) {
|
|
308
|
+
console.log(` ๐ก ${issue.suggestion}`);
|
|
309
|
+
}
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
if (validation.suggestions.length > 0) {
|
|
314
|
+
console.log(`\n๐ก Suggestions (${validation.suggestions.length}):`);
|
|
315
|
+
validation.suggestions.forEach((suggestion) => {
|
|
316
|
+
console.log(` โข ${suggestion.message}`);
|
|
317
|
+
if (suggestion.suggestion) {
|
|
318
|
+
console.log(` โ ${suggestion.suggestion}`);
|
|
319
|
+
}
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
// Exit with error code if validation failed
|
|
325
|
+
if (!validation.valid) {
|
|
326
|
+
process.exit(1);
|
|
327
|
+
}
|
|
328
|
+
} catch (error) {
|
|
329
|
+
console.error('โ Validation failed:', error.message);
|
|
330
|
+
process.exit(1);
|
|
331
|
+
}
|
|
332
|
+
});
|
|
333
|
+
|
|
334
|
+
// Configuration commands
|
|
335
|
+
const configCommand = program.command('config').description('Manage configuration and preferences');
|
|
336
|
+
|
|
337
|
+
configCommand
|
|
338
|
+
.command('show')
|
|
339
|
+
.description('Show current configuration')
|
|
340
|
+
.option('-p, --path <path>', 'Project path', process.cwd())
|
|
341
|
+
.action(async (options) => {
|
|
342
|
+
try {
|
|
343
|
+
const integration = new IntegrationSystem(options.path);
|
|
344
|
+
const config = await integration.loadConfiguration();
|
|
345
|
+
|
|
346
|
+
console.log('โ๏ธ Current Configuration:');
|
|
347
|
+
console.log(JSON.stringify(config, null, 2));
|
|
348
|
+
} catch (error) {
|
|
349
|
+
console.error('โ Failed to load configuration:', error.message);
|
|
350
|
+
process.exit(1);
|
|
351
|
+
}
|
|
352
|
+
});
|
|
353
|
+
|
|
354
|
+
configCommand
|
|
355
|
+
.command('set <key> <value>')
|
|
356
|
+
.description('Set configuration value')
|
|
357
|
+
.option('-p, --path <path>', 'Project path', process.cwd())
|
|
358
|
+
.action(async (key, value, options) => {
|
|
359
|
+
try {
|
|
360
|
+
const integration = new IntegrationSystem(options.path);
|
|
361
|
+
const config = await integration.loadConfiguration();
|
|
362
|
+
|
|
363
|
+
// Parse value as JSON if possible, otherwise as string
|
|
364
|
+
let parsedValue;
|
|
365
|
+
try {
|
|
366
|
+
parsedValue = JSON.parse(value);
|
|
367
|
+
} catch {
|
|
368
|
+
parsedValue = value;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
// Set nested key if dot notation is used
|
|
372
|
+
const keys = key.split('.');
|
|
373
|
+
let current = config;
|
|
374
|
+
for (let i = 0; i < keys.length - 1; i++) {
|
|
375
|
+
if (!current[keys[i]]) current[keys[i]] = {};
|
|
376
|
+
current = current[keys[i]];
|
|
377
|
+
}
|
|
378
|
+
current[keys[keys.length - 1]] = parsedValue;
|
|
379
|
+
|
|
380
|
+
await integration.updateConfiguration(config);
|
|
381
|
+
console.log(`โ
Configuration updated: ${key} = ${value}`);
|
|
382
|
+
} catch (error) {
|
|
383
|
+
console.error('โ Failed to update configuration:', error.message);
|
|
384
|
+
process.exit(1);
|
|
385
|
+
}
|
|
386
|
+
});
|
|
387
|
+
|
|
388
|
+
// Cleanup command
|
|
389
|
+
program
|
|
390
|
+
.command('cleanup')
|
|
391
|
+
.description('Clean up old backup files and reports')
|
|
392
|
+
.option('-p, --path <path>', 'Project path', process.cwd())
|
|
393
|
+
.option('-d, --days <days>', 'Files older than N days', '30')
|
|
394
|
+
.action(async (options) => {
|
|
395
|
+
try {
|
|
396
|
+
console.log(`๐งน Cleaning up files older than ${options.days} days...`);
|
|
397
|
+
|
|
398
|
+
const integration = new IntegrationSystem(options.path);
|
|
399
|
+
const result = await integration.cleanup(parseInt(options.days));
|
|
400
|
+
|
|
401
|
+
console.log(`โ
Cleanup completed: ${result.cleanedCount} files removed`);
|
|
402
|
+
} catch (error) {
|
|
403
|
+
console.error('โ Cleanup failed:', error.message);
|
|
404
|
+
process.exit(1);
|
|
405
|
+
}
|
|
406
|
+
});
|
|
407
|
+
|
|
408
|
+
// Global error handler
|
|
409
|
+
process.on('uncaughtException', (error) => {
|
|
410
|
+
console.error('๐ฅ Uncaught Exception:', error.message);
|
|
411
|
+
process.exit(1);
|
|
412
|
+
});
|
|
413
|
+
|
|
414
|
+
process.on('unhandledRejection', (reason, promise) => {
|
|
415
|
+
console.error('๐ฅ Unhandled Rejection at:', promise, 'reason:', reason);
|
|
416
|
+
process.exit(1);
|
|
417
|
+
});
|
|
418
|
+
|
|
419
|
+
// Parse command line arguments
|
|
420
|
+
program.parse();
|
|
421
|
+
|
|
422
|
+
export { program };
|