claude-flow 2.0.0-alpha.62 → 2.0.0-alpha.64

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 (104) hide show
  1. package/.claude/commands/analysis/COMMAND_COMPLIANCE_REPORT.md +54 -0
  2. package/.claude/commands/analysis/token-efficiency.md +2 -1
  3. package/.claude/commands/automation/self-healing.md +47 -2
  4. package/.claude/commands/automation/session-memory.md +39 -10
  5. package/.claude/commands/automation/smart-agents.md +36 -8
  6. package/.claude/commands/github/code-review-swarm.md +80 -15
  7. package/.claude/commands/github/github-modes.md +14 -14
  8. package/.claude/commands/github/issue-tracker.md +19 -16
  9. package/.claude/commands/github/multi-repo-swarm.md +114 -16
  10. package/.claude/commands/github/pr-manager.md +5 -4
  11. package/.claude/commands/github/project-board-sync.md +38 -5
  12. package/.claude/commands/github/release-manager.md +19 -19
  13. package/.claude/commands/github/release-swarm.md +102 -13
  14. package/.claude/commands/github/repo-architect.md +6 -6
  15. package/.claude/commands/github/swarm-issue.md +139 -17
  16. package/.claude/commands/github/swarm-pr.md +49 -15
  17. package/.claude/commands/github/sync-coordinator.md +33 -33
  18. package/.claude/commands/github/workflow-automation.md +37 -10
  19. package/.claude/commands/hooks/overview.md +2 -2
  20. package/.claude/commands/hooks/setup.md +7 -7
  21. package/.claude/commands/memory/neural.md +10 -5
  22. package/.claude/commands/memory/usage.md +9 -5
  23. package/.claude/commands/monitoring/agents.md +7 -5
  24. package/.claude/commands/monitoring/status.md +8 -5
  25. package/.claude/commands/optimization/auto-topology.md +13 -1
  26. package/.claude/commands/optimization/parallel-execution.md +7 -1
  27. package/.claude/commands/sparc/analyzer.md +28 -2
  28. package/.claude/commands/sparc/architect.md +27 -1
  29. package/.claude/commands/sparc/batch-executor.md +27 -1
  30. package/.claude/commands/sparc/coder.md +27 -1
  31. package/.claude/commands/sparc/debugger.md +27 -1
  32. package/.claude/commands/sparc/designer.md +27 -1
  33. package/.claude/commands/sparc/documenter.md +27 -1
  34. package/.claude/commands/sparc/innovator.md +27 -1
  35. package/.claude/commands/sparc/memory-manager.md +27 -1
  36. package/.claude/commands/sparc/optimizer.md +27 -1
  37. package/.claude/commands/sparc/orchestrator.md +106 -2
  38. package/.claude/commands/sparc/researcher.md +27 -1
  39. package/.claude/commands/sparc/reviewer.md +27 -1
  40. package/.claude/commands/sparc/sparc-modes.md +137 -5
  41. package/.claude/commands/sparc/swarm-coordinator.md +27 -1
  42. package/.claude/commands/sparc/tdd.md +27 -1
  43. package/.claude/commands/sparc/tester.md +27 -1
  44. package/.claude/commands/sparc/workflow-manager.md +27 -1
  45. package/.claude/commands/swarm/analysis.md +82 -5
  46. package/.claude/commands/swarm/development.md +83 -6
  47. package/.claude/commands/swarm/examples.md +141 -3
  48. package/.claude/commands/swarm/maintenance.md +92 -8
  49. package/.claude/commands/swarm/optimization.md +107 -9
  50. package/.claude/commands/swarm/research.md +126 -8
  51. package/.claude/commands/swarm/testing.md +121 -9
  52. package/.claude/commands/training/neural-patterns.md +27 -2
  53. package/.claude/commands/training/specialization.md +13 -3
  54. package/.claude/commands/workflows/development.md +43 -4
  55. package/.claude/commands/workflows/research.md +26 -2
  56. package/CHANGELOG.md +34 -0
  57. package/README.md +8 -0
  58. package/bin/claude-flow +1 -1
  59. package/dist/cli/simple-commands/hive-mind/mcp-wrapper.d.ts +66 -0
  60. package/dist/cli/simple-commands/hive-mind/mcp-wrapper.d.ts.map +1 -1
  61. package/dist/cli/simple-commands/hive-mind/mcp-wrapper.js +220 -2
  62. package/dist/cli/simple-commands/hive-mind/mcp-wrapper.js.map +1 -1
  63. package/dist/cli/simple-commands/hive-mind.d.ts.map +1 -1
  64. package/dist/cli/simple-commands/hive-mind.js +83 -5
  65. package/dist/cli/simple-commands/hive-mind.js.map +1 -1
  66. package/dist/memory/fallback-store.d.ts +1 -0
  67. package/dist/memory/fallback-store.d.ts.map +1 -1
  68. package/dist/memory/fallback-store.js +25 -3
  69. package/dist/memory/fallback-store.js.map +1 -1
  70. package/dist/memory/sqlite-store.d.ts +34 -0
  71. package/dist/memory/sqlite-store.d.ts.map +1 -0
  72. package/dist/memory/sqlite-store.js +2 -3
  73. package/dist/memory/sqlite-store.js.map +1 -1
  74. package/dist/memory/sqlite-wrapper.d.ts +38 -0
  75. package/dist/memory/sqlite-wrapper.d.ts.map +1 -0
  76. package/dist/memory/sqlite-wrapper.js +157 -0
  77. package/dist/memory/sqlite-wrapper.js.map +1 -0
  78. package/package.json +1 -1
  79. package/src/api/claude-api-errors.ts +248 -0
  80. package/src/api/claude-client-enhanced.ts +616 -0
  81. package/src/api/claude-client.ts +282 -14
  82. package/src/cli/help-text.js +4 -3
  83. package/src/cli/simple-cli.js +1 -1
  84. package/src/cli/simple-commands/coordination.js +73 -49
  85. package/src/cli/simple-commands/hive-mind/auto-save-middleware.js +6 -6
  86. package/src/cli/simple-commands/hive-mind/mcp-wrapper.js +327 -8
  87. package/src/cli/simple-commands/hive-mind/session-manager.js +330 -108
  88. package/src/cli/simple-commands/hive-mind.js +192 -11
  89. package/src/cli/simple-commands/init/claude-commands/optimized-slash-commands.js +53 -28
  90. package/src/cli/simple-commands/init/claude-commands/slash-commands.js +36 -14
  91. package/src/cli/simple-commands/init/claude-commands/sparc-commands.js +107 -30
  92. package/src/cli/simple-commands/init/copy-revised-templates.js +175 -0
  93. package/src/cli/simple-commands/init/index.js +156 -235
  94. package/src/cli/simple-commands/init/template-copier.js +583 -0
  95. package/src/cli/simple-commands/init/templates/claude-flow-universal +1 -1
  96. package/src/cli/simple-commands/init/templates/coordination.md +16 -0
  97. package/src/cli/simple-commands/init/templates/memory-bank.md +16 -0
  98. package/src/cli/simple-commands/init/templates/settings.json.enhanced +35 -0
  99. package/src/cli/simple-commands/init/templates/sparc-modes.js +634 -23
  100. package/src/hive-mind/core/DatabaseManager.ts +75 -16
  101. package/src/memory/backends/sqlite.ts +21 -3
  102. package/src/memory/fallback-store.js +35 -3
  103. package/src/memory/sqlite-store.js +2 -3
  104. package/src/memory/sqlite-wrapper.js +173 -0
@@ -0,0 +1,583 @@
1
+ // template-copier.js - Copy template files instead of generating them dynamically
2
+
3
+ import { Deno, existsSync } from '../../node-compat.js';
4
+ import { promises as fs } from 'fs';
5
+ import { dirname, join, relative } from 'path';
6
+ import { fileURLToPath } from 'url';
7
+
8
+ const __filename = fileURLToPath(import.meta.url);
9
+ const __dirname = dirname(__filename);
10
+
11
+ /**
12
+ * Copy template files from the templates directory to the target directory
13
+ * @param {string} targetDir - The directory to copy templates to
14
+ * @param {Object} options - Options for template copying
15
+ * @param {boolean} options.sparc - Whether to include SPARC templates
16
+ * @param {boolean} options.enhanced - Whether to use enhanced templates
17
+ * @param {boolean} options.minimal - Whether to use minimal templates
18
+ * @param {boolean} options.optimized - Whether to use optimized templates
19
+ * @param {boolean} options.dryRun - Whether to perform a dry run
20
+ * @param {boolean} options.force - Whether to overwrite existing files
21
+ * @param {string[]} options.selectedModes - Selected SPARC modes to copy
22
+ * @returns {Promise<{success: boolean, copiedFiles: string[], errors: string[]}>}
23
+ */
24
+ export async function copyTemplates(targetDir, options = {}) {
25
+ const results = {
26
+ success: true,
27
+ copiedFiles: [],
28
+ errors: [],
29
+ };
30
+
31
+ try {
32
+ const templatesDir = join(__dirname, 'templates');
33
+
34
+ // Determine which template variants to use
35
+ const templateVariant = options.optimized ? 'optimized' :
36
+ options.enhanced ? 'enhanced' :
37
+ options.minimal ? 'minimal' :
38
+ options.sparc ? 'sparc' : 'full';
39
+
40
+ // Core files to copy
41
+ const coreFiles = [
42
+ {
43
+ source: 'CLAUDE.md',
44
+ destination: 'CLAUDE.md',
45
+ useVariant: true
46
+ },
47
+ {
48
+ source: 'memory-bank.md',
49
+ destination: 'memory-bank.md',
50
+ useVariant: true
51
+ },
52
+ {
53
+ source: 'coordination.md',
54
+ destination: 'coordination.md',
55
+ useVariant: true
56
+ },
57
+ ];
58
+
59
+ // Copy core files
60
+ for (const file of coreFiles) {
61
+ const sourceFile = file.useVariant && existsSync(join(templatesDir, `${file.source}.${templateVariant}`))
62
+ ? `${file.source}.${templateVariant}`
63
+ : file.source;
64
+
65
+ const sourcePath = join(templatesDir, sourceFile);
66
+ const destPath = join(targetDir, file.destination);
67
+
68
+ if (await copyFile(sourcePath, destPath, options)) {
69
+ results.copiedFiles.push(file.destination);
70
+ } else if (!options.dryRun) {
71
+ results.errors.push(`Failed to copy ${file.destination}`);
72
+ }
73
+ }
74
+
75
+ // Copy .claude directory structure
76
+ if (options.enhanced || !options.minimal) {
77
+ const claudeDir = join(targetDir, '.claude');
78
+
79
+ // Copy settings.json
80
+ const settingsSource = options.enhanced ? 'settings.json.enhanced' : 'settings.json';
81
+ const settingsPath = join(templatesDir, settingsSource);
82
+ const settingsDest = join(claudeDir, 'settings.json');
83
+
84
+ if (!options.dryRun) {
85
+ await fs.mkdir(claudeDir, { recursive: true });
86
+ }
87
+
88
+ if (await copyFile(settingsPath, settingsDest, options)) {
89
+ results.copiedFiles.push('.claude/settings.json');
90
+ }
91
+
92
+ // Copy command templates
93
+ if (options.sparc || options.enhanced) {
94
+ await copyCommandTemplates(templatesDir, targetDir, options, results);
95
+ }
96
+
97
+ // Copy helper scripts (enhanced mode only)
98
+ if (options.enhanced) {
99
+ await copyHelperScripts(templatesDir, targetDir, options, results);
100
+ }
101
+ }
102
+
103
+ // Copy SPARC-specific files
104
+ if (options.sparc) {
105
+ await copySparcTemplates(templatesDir, targetDir, options, results);
106
+ }
107
+
108
+ // Copy wrapper scripts
109
+ await copyWrapperScripts(templatesDir, targetDir, options, results);
110
+
111
+ // Create directory structure
112
+ await createDirectoryStructure(targetDir, options);
113
+
114
+ // Create README files for memory directories
115
+ await createMemoryReadmeFiles(targetDir, options, results);
116
+
117
+ } catch (err) {
118
+ results.success = false;
119
+ results.errors.push(`Template copy failed: ${err.message}`);
120
+ }
121
+
122
+ return results;
123
+ }
124
+
125
+ /**
126
+ * Copy a single file with options
127
+ */
128
+ async function copyFile(source, destination, options) {
129
+ try {
130
+ // Check if source exists
131
+ if (!existsSync(source)) {
132
+ // Try reading from templates directory as fallback
133
+ const templateContent = await getTemplateContent(source);
134
+ if (templateContent) {
135
+ if (!options.dryRun) {
136
+ await fs.writeFile(destination, templateContent);
137
+ }
138
+ console.log(` ${options.dryRun ? '[DRY RUN] Would create' : '✓ Created'} ${relative(process.cwd(), destination)}`);
139
+ return true;
140
+ }
141
+ console.log(` ⚠️ Template not found: ${relative(process.cwd(), source)}`);
142
+ return false;
143
+ }
144
+
145
+ // Check if destination exists and handle force flag
146
+ if (existsSync(destination) && !options.force) {
147
+ console.log(` ⚠️ File already exists: ${relative(process.cwd(), destination)} (use --force to overwrite)`);
148
+ return false;
149
+ }
150
+
151
+ if (!options.dryRun) {
152
+ // Ensure destination directory exists
153
+ await fs.mkdir(dirname(destination), { recursive: true });
154
+
155
+ // Copy the file
156
+ const content = await fs.readFile(source, 'utf8');
157
+ await fs.writeFile(destination, content);
158
+
159
+ // Preserve file permissions for executable scripts
160
+ if (source.endsWith('.sh') || source.includes('claude-flow')) {
161
+ await fs.chmod(destination, 0o755);
162
+ }
163
+ }
164
+
165
+ console.log(` ${options.dryRun ? '[DRY RUN] Would copy' : '✓ Copied'} ${relative(process.cwd(), destination)}`);
166
+ return true;
167
+ } catch (err) {
168
+ console.log(` ❌ Failed to copy ${relative(process.cwd(), destination)}: ${err.message}`);
169
+ return false;
170
+ }
171
+ }
172
+
173
+ /**
174
+ * Copy command templates
175
+ */
176
+ async function copyCommandTemplates(templatesDir, targetDir, options, results) {
177
+ const commandsSourceDir = join(templatesDir, 'commands');
178
+ const commandsDestDir = join(targetDir, '.claude', 'commands');
179
+
180
+ if (!existsSync(commandsSourceDir)) {
181
+ // Use generated command templates as fallback
182
+ return await generateCommandTemplates(targetDir, options, results);
183
+ }
184
+
185
+ try {
186
+ if (!options.dryRun) {
187
+ await fs.mkdir(commandsDestDir, { recursive: true });
188
+ }
189
+
190
+ // Copy command categories
191
+ const categories = await fs.readdir(commandsSourceDir);
192
+
193
+ for (const category of categories) {
194
+ const categoryPath = join(commandsSourceDir, category);
195
+ const stat = await fs.stat(categoryPath);
196
+
197
+ if (stat.isDirectory()) {
198
+ const destCategoryPath = join(commandsDestDir, category);
199
+
200
+ if (!options.dryRun) {
201
+ await fs.mkdir(destCategoryPath, { recursive: true });
202
+ }
203
+
204
+ // Copy files in category
205
+ const files = await fs.readdir(categoryPath);
206
+ for (const file of files) {
207
+ const sourcePath = join(categoryPath, file);
208
+ const destPath = join(destCategoryPath, file);
209
+
210
+ if (await copyFile(sourcePath, destPath, options)) {
211
+ results.copiedFiles.push(join('.claude', 'commands', category, file));
212
+ }
213
+ }
214
+ }
215
+ }
216
+ } catch (err) {
217
+ results.errors.push(`Failed to copy command templates: ${err.message}`);
218
+ }
219
+ }
220
+
221
+ /**
222
+ * Copy SPARC templates
223
+ */
224
+ async function copySparcTemplates(templatesDir, targetDir, options, results) {
225
+ const sparcDir = join(targetDir, '.claude', 'commands', 'sparc');
226
+
227
+ try {
228
+ if (!options.dryRun) {
229
+ await fs.mkdir(sparcDir, { recursive: true });
230
+ }
231
+
232
+ // Get SPARC mode templates
233
+ const { createSparcModeTemplates, createSparcModesOverview } = await import('./templates/sparc-modes.js');
234
+ const sparcTemplates = createSparcModeTemplates();
235
+
236
+ // Filter templates if selectedModes is specified
237
+ const templatesToCreate = options.selectedModes
238
+ ? Object.entries(sparcTemplates).filter(([filename]) => {
239
+ const mode = filename.replace('.md', '');
240
+ return options.selectedModes.includes(mode);
241
+ })
242
+ : Object.entries(sparcTemplates);
243
+
244
+ // Write SPARC mode files
245
+ for (const [filename, content] of templatesToCreate) {
246
+ const destPath = join(sparcDir, filename);
247
+
248
+ if (!options.dryRun) {
249
+ await fs.writeFile(destPath, content);
250
+ }
251
+
252
+ console.log(` ${options.dryRun ? '[DRY RUN] Would create' : '✓ Created'} .claude/commands/sparc/${filename}`);
253
+ results.copiedFiles.push(join('.claude', 'commands', 'sparc', filename));
254
+ }
255
+
256
+ // Create sparc-modes.md overview
257
+ const overviewPath = join(sparcDir, 'sparc-modes.md');
258
+ if (!options.dryRun) {
259
+ await fs.writeFile(overviewPath, createSparcModesOverview());
260
+ }
261
+ console.log(` ${options.dryRun ? '[DRY RUN] Would create' : '✓ Created'} .claude/commands/sparc/sparc-modes.md`);
262
+ results.copiedFiles.push('.claude/commands/sparc/sparc-modes.md');
263
+
264
+ // Copy swarm templates
265
+ await copySwarmTemplates(templatesDir, targetDir, options, results);
266
+
267
+ } catch (err) {
268
+ results.errors.push(`Failed to copy SPARC templates: ${err.message}`);
269
+ }
270
+ }
271
+
272
+ /**
273
+ * Copy swarm strategy templates
274
+ */
275
+ async function copySwarmTemplates(templatesDir, targetDir, options, results) {
276
+ const swarmDir = join(targetDir, '.claude', 'commands', 'swarm');
277
+
278
+ try {
279
+ if (!options.dryRun) {
280
+ await fs.mkdir(swarmDir, { recursive: true });
281
+ }
282
+
283
+ // Get swarm strategy templates
284
+ const { createSwarmStrategyTemplates } = await import('./templates/sparc-modes.js');
285
+ const swarmTemplates = createSwarmStrategyTemplates();
286
+
287
+ // Write swarm strategy files
288
+ for (const [filename, content] of Object.entries(swarmTemplates)) {
289
+ const destPath = join(swarmDir, filename);
290
+
291
+ if (!options.dryRun) {
292
+ await fs.writeFile(destPath, content);
293
+ }
294
+
295
+ console.log(` ${options.dryRun ? '[DRY RUN] Would create' : '✓ Created'} .claude/commands/swarm/${filename}`);
296
+ results.copiedFiles.push(join('.claude', 'commands', 'swarm', filename));
297
+ }
298
+ } catch (err) {
299
+ results.errors.push(`Failed to copy swarm templates: ${err.message}`);
300
+ }
301
+ }
302
+
303
+ /**
304
+ * Copy helper scripts (enhanced mode)
305
+ */
306
+ async function copyHelperScripts(templatesDir, targetDir, options, results) {
307
+ const helpersDir = join(targetDir, '.claude', 'helpers');
308
+
309
+ try {
310
+ if (!options.dryRun) {
311
+ await fs.mkdir(helpersDir, { recursive: true });
312
+ }
313
+
314
+ const helpers = ['setup-mcp.sh', 'quick-start.sh', 'github-setup.sh'];
315
+ const { createHelperScript } = await import('./templates/enhanced-templates.js');
316
+
317
+ for (const helper of helpers) {
318
+ const content = createHelperScript(helper);
319
+ if (content) {
320
+ const destPath = join(helpersDir, helper);
321
+
322
+ if (!options.dryRun) {
323
+ await fs.writeFile(destPath, content);
324
+ await fs.chmod(destPath, 0o755);
325
+ }
326
+
327
+ console.log(` ${options.dryRun ? '[DRY RUN] Would create' : '✓ Created'} .claude/helpers/${helper}`);
328
+ results.copiedFiles.push(join('.claude', 'helpers', helper));
329
+ }
330
+ }
331
+ } catch (err) {
332
+ results.errors.push(`Failed to copy helper scripts: ${err.message}`);
333
+ }
334
+ }
335
+
336
+ /**
337
+ * Copy wrapper scripts
338
+ */
339
+ async function copyWrapperScripts(templatesDir, targetDir, options, results) {
340
+ try {
341
+ // Unix wrapper
342
+ const unixWrapperPath = join(targetDir, 'claude-flow');
343
+ const unixWrapperSource = join(templatesDir, 'claude-flow-universal');
344
+
345
+ if (await copyFile(unixWrapperSource, unixWrapperPath, options)) {
346
+ if (!options.dryRun) {
347
+ await fs.chmod(unixWrapperPath, 0o755);
348
+ }
349
+ results.copiedFiles.push('claude-flow');
350
+ }
351
+
352
+ // Windows batch wrapper
353
+ const batchWrapperPath = join(targetDir, 'claude-flow.bat');
354
+ const batchWrapperSource = join(templatesDir, 'claude-flow.bat');
355
+
356
+ if (await copyFile(batchWrapperSource, batchWrapperPath, options)) {
357
+ results.copiedFiles.push('claude-flow.bat');
358
+ }
359
+
360
+ // PowerShell wrapper
361
+ const psWrapperPath = join(targetDir, 'claude-flow.ps1');
362
+ const psWrapperSource = join(templatesDir, 'claude-flow.ps1');
363
+
364
+ if (await copyFile(psWrapperSource, psWrapperPath, options)) {
365
+ results.copiedFiles.push('claude-flow.ps1');
366
+ }
367
+ } catch (err) {
368
+ results.errors.push(`Failed to copy wrapper scripts: ${err.message}`);
369
+ }
370
+ }
371
+
372
+ /**
373
+ * Create directory structure
374
+ */
375
+ async function createDirectoryStructure(targetDir, options) {
376
+ const directories = [
377
+ 'memory',
378
+ 'memory/agents',
379
+ 'memory/sessions',
380
+ 'coordination',
381
+ 'coordination/memory_bank',
382
+ 'coordination/subtasks',
383
+ 'coordination/orchestration',
384
+ '.claude',
385
+ '.claude/commands',
386
+ '.claude/logs',
387
+ '.swarm', // For memory persistence
388
+ ];
389
+
390
+ if (options.sparc) {
391
+ directories.push(
392
+ '.claude/commands/sparc',
393
+ '.claude/commands/swarm'
394
+ );
395
+ }
396
+
397
+ for (const dir of directories) {
398
+ const dirPath = join(targetDir, dir);
399
+ try {
400
+ if (!options.dryRun) {
401
+ await fs.mkdir(dirPath, { recursive: true });
402
+ }
403
+ console.log(` ${options.dryRun ? '[DRY RUN] Would create' : '✓ Created'} ${dir}/ directory`);
404
+ } catch (err) {
405
+ if (err.code !== 'EEXIST') {
406
+ console.log(` ❌ Failed to create ${dir}/: ${err.message}`);
407
+ }
408
+ }
409
+ }
410
+ }
411
+
412
+ /**
413
+ * Create README files for memory directories
414
+ */
415
+ async function createMemoryReadmeFiles(targetDir, options, results) {
416
+ const { createAgentsReadme, createSessionsReadme } = await import('./templates/readme-files.js');
417
+
418
+ const readmeFiles = [
419
+ { path: 'memory/agents/README.md', content: createAgentsReadme() },
420
+ { path: 'memory/sessions/README.md', content: createSessionsReadme() },
421
+ ];
422
+
423
+ for (const { path, content } of readmeFiles) {
424
+ const fullPath = join(targetDir, path);
425
+
426
+ try {
427
+ if (!options.dryRun) {
428
+ await fs.mkdir(dirname(fullPath), { recursive: true });
429
+ await fs.writeFile(fullPath, content);
430
+ }
431
+ console.log(` ${options.dryRun ? '[DRY RUN] Would create' : '✓ Created'} ${path}`);
432
+ results.copiedFiles.push(path);
433
+ } catch (err) {
434
+ results.errors.push(`Failed to create ${path}: ${err.message}`);
435
+ }
436
+ }
437
+
438
+ // Initialize persistence database
439
+ const dbPath = join(targetDir, 'memory', 'claude-flow-data.json');
440
+ const initialData = {
441
+ agents: [],
442
+ tasks: [],
443
+ lastUpdated: Date.now(),
444
+ };
445
+
446
+ try {
447
+ if (!options.dryRun) {
448
+ await fs.writeFile(dbPath, JSON.stringify(initialData, null, 2));
449
+ }
450
+ console.log(` ${options.dryRun ? '[DRY RUN] Would create' : '✓ Created'} memory/claude-flow-data.json (persistence database)`);
451
+ results.copiedFiles.push('memory/claude-flow-data.json');
452
+ } catch (err) {
453
+ results.errors.push(`Failed to create persistence database: ${err.message}`);
454
+ }
455
+ }
456
+
457
+ /**
458
+ * Get template content as fallback (for backwards compatibility)
459
+ */
460
+ async function getTemplateContent(templatePath) {
461
+ const filename = templatePath.split('/').pop();
462
+
463
+ // Map template files to their generator functions
464
+ const templateGenerators = {
465
+ 'CLAUDE.md': async () => {
466
+ const { createFullClaudeMd } = await import('./templates/claude-md.js');
467
+ return createFullClaudeMd();
468
+ },
469
+ 'CLAUDE.md.sparc': async () => {
470
+ const { createSparcClaudeMd } = await import('./templates/claude-md.js');
471
+ return createSparcClaudeMd();
472
+ },
473
+ 'CLAUDE.md.minimal': async () => {
474
+ const { createMinimalClaudeMd } = await import('./templates/claude-md.js');
475
+ return createMinimalClaudeMd();
476
+ },
477
+ 'CLAUDE.md.optimized': async () => {
478
+ const { createOptimizedSparcClaudeMd } = await import('./templates/claude-md.js');
479
+ return createOptimizedSparcClaudeMd();
480
+ },
481
+ 'CLAUDE.md.enhanced': async () => {
482
+ const { createEnhancedClaudeMd } = await import('./templates/enhanced-templates.js');
483
+ return createEnhancedClaudeMd();
484
+ },
485
+ 'memory-bank.md': async () => {
486
+ const { createFullMemoryBankMd } = await import('./templates/memory-bank-md.js');
487
+ return createFullMemoryBankMd();
488
+ },
489
+ 'memory-bank.md.minimal': async () => {
490
+ const { createMinimalMemoryBankMd } = await import('./templates/memory-bank-md.js');
491
+ return createMinimalMemoryBankMd();
492
+ },
493
+ 'memory-bank.md.optimized': async () => {
494
+ const { createOptimizedMemoryBankMd } = await import('./templates/memory-bank-md.js');
495
+ return createOptimizedMemoryBankMd();
496
+ },
497
+ 'coordination.md': async () => {
498
+ const { createFullCoordinationMd } = await import('./templates/coordination-md.js');
499
+ return createFullCoordinationMd();
500
+ },
501
+ 'coordination.md.minimal': async () => {
502
+ const { createMinimalCoordinationMd } = await import('./templates/coordination-md.js');
503
+ return createMinimalCoordinationMd();
504
+ },
505
+ 'coordination.md.optimized': async () => {
506
+ const { createOptimizedCoordinationMd } = await import('./templates/coordination-md.js');
507
+ return createOptimizedCoordinationMd();
508
+ },
509
+ 'settings.json': async () => {
510
+ return await fs.readFile(join(__dirname, 'templates', 'settings.json'), 'utf8');
511
+ },
512
+ 'settings.json.enhanced': async () => {
513
+ const { createEnhancedSettingsJson } = await import('./templates/enhanced-templates.js');
514
+ return createEnhancedSettingsJson();
515
+ },
516
+ 'claude-flow-universal': async () => {
517
+ return await fs.readFile(join(__dirname, 'templates', 'claude-flow-universal'), 'utf8');
518
+ },
519
+ 'claude-flow.bat': async () => {
520
+ return await fs.readFile(join(__dirname, 'templates', 'claude-flow.bat'), 'utf8');
521
+ },
522
+ 'claude-flow.ps1': async () => {
523
+ return await fs.readFile(join(__dirname, 'templates', 'claude-flow.ps1'), 'utf8');
524
+ },
525
+ };
526
+
527
+ const generator = templateGenerators[filename] || templateGenerators[filename.replace(/\.(sparc|minimal|optimized|enhanced)$/, '')];
528
+
529
+ if (generator) {
530
+ try {
531
+ return await generator();
532
+ } catch (err) {
533
+ console.log(` ⚠️ Failed to generate template content for ${filename}: ${err.message}`);
534
+ return null;
535
+ }
536
+ }
537
+
538
+ return null;
539
+ }
540
+
541
+ /**
542
+ * Generate command templates as fallback
543
+ */
544
+ async function generateCommandTemplates(targetDir, options, results) {
545
+ const { COMMAND_STRUCTURE, createCommandDoc } = await import('./templates/enhanced-templates.js');
546
+
547
+ for (const [category, commands] of Object.entries(COMMAND_STRUCTURE)) {
548
+ const categoryDir = join(targetDir, '.claude', 'commands', category);
549
+
550
+ try {
551
+ if (!options.dryRun) {
552
+ await fs.mkdir(categoryDir, { recursive: true });
553
+
554
+ // Create category README
555
+ const categoryReadme = `# ${category.charAt(0).toUpperCase() + category.slice(1)} Commands
556
+
557
+ Commands for ${category} operations in Claude Flow.
558
+
559
+ ## Available Commands
560
+
561
+ ${commands.map(cmd => `- [${cmd}](./${cmd}.md)`).join('\n')}
562
+ `;
563
+ await fs.writeFile(join(categoryDir, 'README.md'), categoryReadme);
564
+ }
565
+
566
+ // Create individual command docs
567
+ for (const command of commands) {
568
+ const doc = createCommandDoc(category, command);
569
+ if (doc) {
570
+ const docPath = join(categoryDir, `${command}.md`);
571
+ if (!options.dryRun) {
572
+ await fs.writeFile(docPath, doc);
573
+ }
574
+ results.copiedFiles.push(join('.claude', 'commands', category, `${command}.md`));
575
+ }
576
+ }
577
+
578
+ console.log(` ${options.dryRun ? '[DRY RUN] Would create' : '✓ Created'} ${commands.length} ${category} command docs`);
579
+ } catch (err) {
580
+ results.errors.push(`Failed to generate ${category} command templates: ${err.message}`);
581
+ }
582
+ }
583
+ }
@@ -53,7 +53,7 @@
53
53
 
54
54
  // 3. NPX with latest alpha version (prioritized over global)
55
55
  async () => {
56
- return spawn('npx', ['claude-flow@2.0.0-alpha.27', ...process.argv.slice(2)], {
56
+ return spawn('npx', ['claude-flow@alpha', ...process.argv.slice(2)], {
57
57
  stdio: 'inherit',
58
58
  });
59
59
  },
@@ -0,0 +1,16 @@
1
+ # Coordination
2
+
3
+ ## Task Orchestration
4
+ This file coordinates tasks and workflows across the project.
5
+
6
+ ## Active Tasks
7
+ <!-- Track active development tasks -->
8
+
9
+ ## Workflows
10
+ <!-- Define project workflows -->
11
+
12
+ ## Dependencies
13
+ <!-- Track task dependencies -->
14
+
15
+ ## Progress Tracking
16
+ <!-- Monitor task progress -->
@@ -0,0 +1,16 @@
1
+ # Memory Bank
2
+
3
+ ## Overview
4
+ This file serves as a persistent memory bank for important project context that should be retained across sessions.
5
+
6
+ ## Project Context
7
+ <!-- Add project-specific information here -->
8
+
9
+ ## Key Decisions
10
+ <!-- Document important decisions and their rationale -->
11
+
12
+ ## Code Patterns
13
+ <!-- Document established patterns and conventions -->
14
+
15
+ ## Session History
16
+ <!-- Track significant session outcomes -->
@@ -0,0 +1,35 @@
1
+ {
2
+ "hooks": {
3
+ "pre-task": ".claude/commands/hooks/pre-task.md",
4
+ "post-task": ".claude/commands/hooks/post-task.md",
5
+ "pre-edit": ".claude/commands/hooks/pre-edit.md",
6
+ "post-edit": ".claude/commands/hooks/post-edit.md",
7
+ "session-start": ".claude/commands/hooks/session-start.md",
8
+ "session-end": ".claude/commands/hooks/session-end.md"
9
+ },
10
+ "permissions": {
11
+ "allow": ["mcp__ruv-swarm", "mcp__claude-flow"],
12
+ "autoApprove": {
13
+ "mcp__ruv-swarm": ["*"],
14
+ "mcp__claude-flow": ["*"]
15
+ }
16
+ },
17
+ "mcpServers": {
18
+ "claude-flow": {
19
+ "command": "npx",
20
+ "args": ["claude-flow@alpha", "mcp", "start"],
21
+ "type": "stdio"
22
+ },
23
+ "ruv-swarm": {
24
+ "command": "npx",
25
+ "args": ["ruv-swarm@latest", "mcp", "start"],
26
+ "type": "stdio"
27
+ }
28
+ },
29
+ "features": {
30
+ "hooks": true,
31
+ "mcpIntegration": true,
32
+ "autoCompletion": true,
33
+ "commandPalette": true
34
+ }
35
+ }