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.
- package/.claude/commands/analysis/COMMAND_COMPLIANCE_REPORT.md +54 -0
- package/.claude/commands/analysis/token-efficiency.md +2 -1
- package/.claude/commands/automation/self-healing.md +47 -2
- package/.claude/commands/automation/session-memory.md +39 -10
- package/.claude/commands/automation/smart-agents.md +36 -8
- package/.claude/commands/github/code-review-swarm.md +80 -15
- package/.claude/commands/github/github-modes.md +14 -14
- package/.claude/commands/github/issue-tracker.md +19 -16
- package/.claude/commands/github/multi-repo-swarm.md +114 -16
- package/.claude/commands/github/pr-manager.md +5 -4
- package/.claude/commands/github/project-board-sync.md +38 -5
- package/.claude/commands/github/release-manager.md +19 -19
- package/.claude/commands/github/release-swarm.md +102 -13
- package/.claude/commands/github/repo-architect.md +6 -6
- package/.claude/commands/github/swarm-issue.md +139 -17
- package/.claude/commands/github/swarm-pr.md +49 -15
- package/.claude/commands/github/sync-coordinator.md +33 -33
- package/.claude/commands/github/workflow-automation.md +37 -10
- package/.claude/commands/hooks/overview.md +2 -2
- package/.claude/commands/hooks/setup.md +7 -7
- package/.claude/commands/memory/neural.md +10 -5
- package/.claude/commands/memory/usage.md +9 -5
- package/.claude/commands/monitoring/agents.md +7 -5
- package/.claude/commands/monitoring/status.md +8 -5
- package/.claude/commands/optimization/auto-topology.md +13 -1
- package/.claude/commands/optimization/parallel-execution.md +7 -1
- package/.claude/commands/sparc/analyzer.md +28 -2
- package/.claude/commands/sparc/architect.md +27 -1
- package/.claude/commands/sparc/batch-executor.md +27 -1
- package/.claude/commands/sparc/coder.md +27 -1
- package/.claude/commands/sparc/debugger.md +27 -1
- package/.claude/commands/sparc/designer.md +27 -1
- package/.claude/commands/sparc/documenter.md +27 -1
- package/.claude/commands/sparc/innovator.md +27 -1
- package/.claude/commands/sparc/memory-manager.md +27 -1
- package/.claude/commands/sparc/optimizer.md +27 -1
- package/.claude/commands/sparc/orchestrator.md +106 -2
- package/.claude/commands/sparc/researcher.md +27 -1
- package/.claude/commands/sparc/reviewer.md +27 -1
- package/.claude/commands/sparc/sparc-modes.md +137 -5
- package/.claude/commands/sparc/swarm-coordinator.md +27 -1
- package/.claude/commands/sparc/tdd.md +27 -1
- package/.claude/commands/sparc/tester.md +27 -1
- package/.claude/commands/sparc/workflow-manager.md +27 -1
- package/.claude/commands/swarm/analysis.md +82 -5
- package/.claude/commands/swarm/development.md +83 -6
- package/.claude/commands/swarm/examples.md +141 -3
- package/.claude/commands/swarm/maintenance.md +92 -8
- package/.claude/commands/swarm/optimization.md +107 -9
- package/.claude/commands/swarm/research.md +126 -8
- package/.claude/commands/swarm/testing.md +121 -9
- package/.claude/commands/training/neural-patterns.md +27 -2
- package/.claude/commands/training/specialization.md +13 -3
- package/.claude/commands/workflows/development.md +43 -4
- package/.claude/commands/workflows/research.md +26 -2
- package/CHANGELOG.md +34 -0
- package/README.md +8 -0
- package/bin/claude-flow +1 -1
- package/dist/cli/simple-commands/hive-mind/mcp-wrapper.d.ts +66 -0
- package/dist/cli/simple-commands/hive-mind/mcp-wrapper.d.ts.map +1 -1
- package/dist/cli/simple-commands/hive-mind/mcp-wrapper.js +220 -2
- package/dist/cli/simple-commands/hive-mind/mcp-wrapper.js.map +1 -1
- package/dist/cli/simple-commands/hive-mind.d.ts.map +1 -1
- package/dist/cli/simple-commands/hive-mind.js +83 -5
- package/dist/cli/simple-commands/hive-mind.js.map +1 -1
- package/dist/memory/fallback-store.d.ts +1 -0
- package/dist/memory/fallback-store.d.ts.map +1 -1
- package/dist/memory/fallback-store.js +25 -3
- package/dist/memory/fallback-store.js.map +1 -1
- package/dist/memory/sqlite-store.d.ts +34 -0
- package/dist/memory/sqlite-store.d.ts.map +1 -0
- package/dist/memory/sqlite-store.js +2 -3
- package/dist/memory/sqlite-store.js.map +1 -1
- package/dist/memory/sqlite-wrapper.d.ts +38 -0
- package/dist/memory/sqlite-wrapper.d.ts.map +1 -0
- package/dist/memory/sqlite-wrapper.js +157 -0
- package/dist/memory/sqlite-wrapper.js.map +1 -0
- package/package.json +1 -1
- package/src/api/claude-api-errors.ts +248 -0
- package/src/api/claude-client-enhanced.ts +616 -0
- package/src/api/claude-client.ts +282 -14
- package/src/cli/help-text.js +4 -3
- package/src/cli/simple-cli.js +1 -1
- package/src/cli/simple-commands/coordination.js +73 -49
- package/src/cli/simple-commands/hive-mind/auto-save-middleware.js +6 -6
- package/src/cli/simple-commands/hive-mind/mcp-wrapper.js +327 -8
- package/src/cli/simple-commands/hive-mind/session-manager.js +330 -108
- package/src/cli/simple-commands/hive-mind.js +192 -11
- package/src/cli/simple-commands/init/claude-commands/optimized-slash-commands.js +53 -28
- package/src/cli/simple-commands/init/claude-commands/slash-commands.js +36 -14
- package/src/cli/simple-commands/init/claude-commands/sparc-commands.js +107 -30
- package/src/cli/simple-commands/init/copy-revised-templates.js +175 -0
- package/src/cli/simple-commands/init/index.js +156 -235
- package/src/cli/simple-commands/init/template-copier.js +583 -0
- package/src/cli/simple-commands/init/templates/claude-flow-universal +1 -1
- package/src/cli/simple-commands/init/templates/coordination.md +16 -0
- package/src/cli/simple-commands/init/templates/memory-bank.md +16 -0
- package/src/cli/simple-commands/init/templates/settings.json.enhanced +35 -0
- package/src/cli/simple-commands/init/templates/sparc-modes.js +634 -23
- package/src/hive-mind/core/DatabaseManager.ts +75 -16
- package/src/memory/backends/sqlite.ts +21 -3
- package/src/memory/fallback-store.js +35 -3
- package/src/memory/sqlite-store.js +2 -3
- package/src/memory/sqlite-wrapper.js +173 -0
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
// copy-revised-templates.js - Copy the revised template files from repository
|
|
2
|
+
|
|
3
|
+
import fs from 'fs';
|
|
4
|
+
import path from 'path';
|
|
5
|
+
import { fileURLToPath } from 'url';
|
|
6
|
+
|
|
7
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
8
|
+
const __dirname = path.dirname(__filename);
|
|
9
|
+
|
|
10
|
+
// Source directory for revised templates (repository root .claude/commands)
|
|
11
|
+
const REPO_TEMPLATES_DIR = path.join(__dirname, '../../../../.claude/commands');
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Copy revised template files from repository to target project
|
|
15
|
+
*/
|
|
16
|
+
export async function copyRevisedTemplates(targetDir, options = {}) {
|
|
17
|
+
const results = {
|
|
18
|
+
success: true,
|
|
19
|
+
copiedFiles: [],
|
|
20
|
+
skippedFiles: [],
|
|
21
|
+
errors: []
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const targetCommandsDir = path.join(targetDir, '.claude/commands');
|
|
25
|
+
|
|
26
|
+
try {
|
|
27
|
+
// Ensure target directory exists
|
|
28
|
+
await fs.promises.mkdir(targetCommandsDir, { recursive: true });
|
|
29
|
+
|
|
30
|
+
// Copy all template files recursively
|
|
31
|
+
await copyDirectoryRecursive(REPO_TEMPLATES_DIR, targetCommandsDir, options, results);
|
|
32
|
+
|
|
33
|
+
// Copy additional .claude files if they exist
|
|
34
|
+
const additionalFiles = [
|
|
35
|
+
{ source: '../config.json', target: '.claude/config.json' },
|
|
36
|
+
{ source: '../settings.json', target: '.claude/settings.json' }
|
|
37
|
+
];
|
|
38
|
+
|
|
39
|
+
for (const file of additionalFiles) {
|
|
40
|
+
const sourcePath = path.join(REPO_TEMPLATES_DIR, file.source);
|
|
41
|
+
const targetPath = path.join(targetDir, file.target);
|
|
42
|
+
|
|
43
|
+
if (fs.existsSync(sourcePath)) {
|
|
44
|
+
try {
|
|
45
|
+
const targetDirPath = path.dirname(targetPath);
|
|
46
|
+
await fs.promises.mkdir(targetDirPath, { recursive: true });
|
|
47
|
+
|
|
48
|
+
if (!fs.existsSync(targetPath) || options.force) {
|
|
49
|
+
await fs.promises.copyFile(sourcePath, targetPath);
|
|
50
|
+
results.copiedFiles.push(file.target);
|
|
51
|
+
if (!options.dryRun) {
|
|
52
|
+
console.log(` ✓ Copied ${file.target}`);
|
|
53
|
+
}
|
|
54
|
+
} else {
|
|
55
|
+
results.skippedFiles.push(file.target);
|
|
56
|
+
if (!options.dryRun) {
|
|
57
|
+
console.log(` ⏭️ Skipped ${file.target} (already exists)`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
} catch (err) {
|
|
61
|
+
results.errors.push(`Failed to copy ${file.target}: ${err.message}`);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
results.success = results.errors.length === 0;
|
|
67
|
+
} catch (err) {
|
|
68
|
+
results.success = false;
|
|
69
|
+
results.errors.push(`Failed to copy revised templates: ${err.message}`);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return results;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Recursively copy directory contents
|
|
77
|
+
*/
|
|
78
|
+
async function copyDirectoryRecursive(sourceDir, targetDir, options, results) {
|
|
79
|
+
try {
|
|
80
|
+
const entries = await fs.promises.readdir(sourceDir, { withFileTypes: true });
|
|
81
|
+
|
|
82
|
+
for (const entry of entries) {
|
|
83
|
+
const sourcePath = path.join(sourceDir, entry.name);
|
|
84
|
+
const targetPath = path.join(targetDir, entry.name);
|
|
85
|
+
|
|
86
|
+
if (entry.isDirectory()) {
|
|
87
|
+
// Create directory and recurse
|
|
88
|
+
await fs.promises.mkdir(targetPath, { recursive: true });
|
|
89
|
+
await copyDirectoryRecursive(sourcePath, targetPath, options, results);
|
|
90
|
+
} else if (entry.isFile() && entry.name.endsWith('.md')) {
|
|
91
|
+
// Copy markdown files
|
|
92
|
+
try {
|
|
93
|
+
if (!fs.existsSync(targetPath) || options.force) {
|
|
94
|
+
if (!options.dryRun) {
|
|
95
|
+
await fs.promises.copyFile(sourcePath, targetPath);
|
|
96
|
+
}
|
|
97
|
+
const relativePath = path.relative(targetDir, targetPath);
|
|
98
|
+
results.copiedFiles.push(relativePath);
|
|
99
|
+
if (!options.dryRun && options.verbose) {
|
|
100
|
+
console.log(` ✓ Copied ${relativePath}`);
|
|
101
|
+
}
|
|
102
|
+
} else {
|
|
103
|
+
const relativePath = path.relative(targetDir, targetPath);
|
|
104
|
+
results.skippedFiles.push(relativePath);
|
|
105
|
+
if (!options.dryRun && options.verbose) {
|
|
106
|
+
console.log(` ⏭️ Skipped ${relativePath} (already exists)`);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
} catch (err) {
|
|
110
|
+
results.errors.push(`Failed to copy ${entry.name}: ${err.message}`);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
} catch (err) {
|
|
115
|
+
results.errors.push(`Failed to read directory ${sourceDir}: ${err.message}`);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Copy only specific categories
|
|
121
|
+
*/
|
|
122
|
+
export async function copyRevisedTemplatesByCategory(targetDir, categories, options = {}) {
|
|
123
|
+
const results = {
|
|
124
|
+
success: true,
|
|
125
|
+
copiedFiles: [],
|
|
126
|
+
skippedFiles: [],
|
|
127
|
+
errors: []
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
for (const category of categories) {
|
|
131
|
+
const sourceCategoryDir = path.join(REPO_TEMPLATES_DIR, category);
|
|
132
|
+
const targetCategoryDir = path.join(targetDir, '.claude/commands', category);
|
|
133
|
+
|
|
134
|
+
if (fs.existsSync(sourceCategoryDir)) {
|
|
135
|
+
await fs.promises.mkdir(targetCategoryDir, { recursive: true });
|
|
136
|
+
await copyDirectoryRecursive(sourceCategoryDir, targetCategoryDir, options, results);
|
|
137
|
+
} else {
|
|
138
|
+
results.errors.push(`Category '${category}' not found in templates`);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
results.success = results.errors.length === 0;
|
|
143
|
+
return results;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Validate that source templates exist
|
|
148
|
+
*/
|
|
149
|
+
export function validateTemplatesExist() {
|
|
150
|
+
if (!fs.existsSync(REPO_TEMPLATES_DIR)) {
|
|
151
|
+
return {
|
|
152
|
+
valid: false,
|
|
153
|
+
error: `Template directory not found: ${REPO_TEMPLATES_DIR}`
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
const requiredCategories = ['analysis', 'github', 'sparc', 'coordination'];
|
|
158
|
+
const missingCategories = [];
|
|
159
|
+
|
|
160
|
+
for (const category of requiredCategories) {
|
|
161
|
+
const categoryPath = path.join(REPO_TEMPLATES_DIR, category);
|
|
162
|
+
if (!fs.existsSync(categoryPath)) {
|
|
163
|
+
missingCategories.push(category);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
if (missingCategories.length > 0) {
|
|
168
|
+
return {
|
|
169
|
+
valid: false,
|
|
170
|
+
error: `Missing required template categories: ${missingCategories.join(', ')}`
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
return { valid: true };
|
|
175
|
+
}
|
|
@@ -8,28 +8,8 @@ import { createClaudeSlashCommands } from './claude-commands/slash-commands.js';
|
|
|
8
8
|
import { createOptimizedClaudeSlashCommands } from './claude-commands/optimized-slash-commands.js';
|
|
9
9
|
import { execSync } from 'child_process';
|
|
10
10
|
import { promises as fs } from 'fs';
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
createFullClaudeMd,
|
|
14
|
-
createMinimalClaudeMd,
|
|
15
|
-
createOptimizedSparcClaudeMd,
|
|
16
|
-
} from './templates/claude-md.js';
|
|
17
|
-
import {
|
|
18
|
-
createFullMemoryBankMd,
|
|
19
|
-
createMinimalMemoryBankMd,
|
|
20
|
-
createOptimizedMemoryBankMd,
|
|
21
|
-
} from './templates/memory-bank-md.js';
|
|
22
|
-
import {
|
|
23
|
-
createFullCoordinationMd,
|
|
24
|
-
createMinimalCoordinationMd,
|
|
25
|
-
createOptimizedCoordinationMd,
|
|
26
|
-
} from './templates/coordination-md.js';
|
|
27
|
-
import { createAgentsReadme, createSessionsReadme } from './templates/readme-files.js';
|
|
28
|
-
import {
|
|
29
|
-
createSparcModeTemplates,
|
|
30
|
-
createSparcModesOverview,
|
|
31
|
-
createSwarmStrategyTemplates,
|
|
32
|
-
} from './templates/sparc-modes.js';
|
|
11
|
+
import { copyTemplates } from './template-copier.js';
|
|
12
|
+
import { copyRevisedTemplates, validateTemplatesExist } from './copy-revised-templates.js';
|
|
33
13
|
import { showInitHelp } from './help.js';
|
|
34
14
|
import { batchInitCommand, batchInitFromConfig, validateBatchOptions } from './batch-init.js';
|
|
35
15
|
import { ValidationSystem, runFullValidation } from './validation/index.js';
|
|
@@ -44,6 +24,20 @@ import {
|
|
|
44
24
|
} from './templates/enhanced-templates.js';
|
|
45
25
|
import { getIsolatedNpxEnv } from '../../../utils/npx-isolated-cache.js';
|
|
46
26
|
import { updateGitignore, needsGitignoreUpdate } from './gitignore-updater.js';
|
|
27
|
+
import {
|
|
28
|
+
createFullClaudeMd,
|
|
29
|
+
createSparcClaudeMd,
|
|
30
|
+
createMinimalClaudeMd,
|
|
31
|
+
} from './templates/claude-md.js';
|
|
32
|
+
import {
|
|
33
|
+
createFullMemoryBankMd,
|
|
34
|
+
createMinimalMemoryBankMd,
|
|
35
|
+
} from './templates/memory-bank-md.js';
|
|
36
|
+
import {
|
|
37
|
+
createFullCoordinationMd,
|
|
38
|
+
createMinimalCoordinationMd,
|
|
39
|
+
} from './templates/coordination-md.js';
|
|
40
|
+
import { createAgentsReadme, createSessionsReadme } from './templates/readme-files.js';
|
|
47
41
|
|
|
48
42
|
/**
|
|
49
43
|
* Check if Claude Code CLI is installed
|
|
@@ -147,7 +141,7 @@ export async function initCommand(subArgs, flags) {
|
|
|
147
141
|
// Parse init options
|
|
148
142
|
const initForce = subArgs.includes('--force') || subArgs.includes('-f') || flags.force;
|
|
149
143
|
const initMinimal = subArgs.includes('--minimal') || subArgs.includes('-m') || flags.minimal;
|
|
150
|
-
const initSparc =
|
|
144
|
+
const initSparc = true; // SPARC is now included by default
|
|
151
145
|
const initDryRun = subArgs.includes('--dry-run') || subArgs.includes('-d') || flags.dryRun;
|
|
152
146
|
const initOptimized = initSparc && initForce; // Use optimized templates when both flags are present
|
|
153
147
|
const selectedModes = flags.modes ? flags.modes.split(',') : null; // Support selective mode initialization
|
|
@@ -186,228 +180,53 @@ export async function initCommand(subArgs, flags) {
|
|
|
186
180
|
return;
|
|
187
181
|
}
|
|
188
182
|
|
|
189
|
-
//
|
|
190
|
-
const
|
|
191
|
-
|
|
192
|
-
:
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
if (!initDryRun) {
|
|
199
|
-
await Deno.writeTextFile('CLAUDE.md', claudeMd);
|
|
200
|
-
console.log(
|
|
201
|
-
` ✓ Created CLAUDE.md${initOptimized ? ' (Batchtools-optimized SPARC)' : initSparc ? ' (SPARC-enhanced)' : ''}`,
|
|
202
|
-
);
|
|
203
|
-
} else {
|
|
204
|
-
console.log(
|
|
205
|
-
` [DRY RUN] Would create CLAUDE.md${initOptimized ? ' (Batchtools-optimized SPARC)' : initSparc ? ' (SPARC-enhanced)' : ''}`,
|
|
206
|
-
);
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
// Create memory-bank.md
|
|
210
|
-
const memoryBankMd = initOptimized
|
|
211
|
-
? await createOptimizedMemoryBankMd()
|
|
212
|
-
: initMinimal
|
|
213
|
-
? createMinimalMemoryBankMd()
|
|
214
|
-
: createFullMemoryBankMd();
|
|
215
|
-
if (!initDryRun) {
|
|
216
|
-
await Deno.writeTextFile('memory-bank.md', memoryBankMd);
|
|
217
|
-
console.log(
|
|
218
|
-
' ✓ Created memory-bank.md' +
|
|
219
|
-
(initOptimized ? ' (Optimized for parallel operations)' : ''),
|
|
220
|
-
);
|
|
221
|
-
} else {
|
|
222
|
-
console.log(
|
|
223
|
-
' [DRY RUN] Would create memory-bank.md' +
|
|
224
|
-
(initOptimized ? ' (Optimized for parallel operations)' : ''),
|
|
225
|
-
);
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
// Create coordination.md
|
|
229
|
-
const coordinationMd = initOptimized
|
|
230
|
-
? await createOptimizedCoordinationMd()
|
|
231
|
-
: initMinimal
|
|
232
|
-
? createMinimalCoordinationMd()
|
|
233
|
-
: createFullCoordinationMd();
|
|
234
|
-
if (!initDryRun) {
|
|
235
|
-
await Deno.writeTextFile('coordination.md', coordinationMd);
|
|
236
|
-
console.log(
|
|
237
|
-
' ✓ Created coordination.md' + (initOptimized ? ' (Enhanced with batchtools)' : ''),
|
|
238
|
-
);
|
|
239
|
-
} else {
|
|
240
|
-
console.log(
|
|
241
|
-
' [DRY RUN] Would create coordination.md' +
|
|
242
|
-
(initOptimized ? ' (Enhanced with batchtools)' : ''),
|
|
243
|
-
);
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
// Create directory structure
|
|
247
|
-
const directories = [
|
|
248
|
-
'memory',
|
|
249
|
-
'memory/agents',
|
|
250
|
-
'memory/sessions',
|
|
251
|
-
'coordination',
|
|
252
|
-
'coordination/memory_bank',
|
|
253
|
-
'coordination/subtasks',
|
|
254
|
-
'coordination/orchestration',
|
|
255
|
-
'.claude',
|
|
256
|
-
'.claude/commands',
|
|
257
|
-
'.claude/commands/sparc',
|
|
258
|
-
'.claude/commands/swarm',
|
|
259
|
-
'.claude/logs',
|
|
260
|
-
'.swarm', // Add .swarm directory for memory persistence (matching hive-mind pattern)
|
|
261
|
-
];
|
|
262
|
-
|
|
263
|
-
for (const dir of directories) {
|
|
264
|
-
try {
|
|
265
|
-
if (!initDryRun) {
|
|
266
|
-
await Deno.mkdir(dir, { recursive: true });
|
|
267
|
-
console.log(` ✓ Created ${dir}/ directory`);
|
|
268
|
-
} else {
|
|
269
|
-
console.log(` [DRY RUN] Would create ${dir}/ directory`);
|
|
270
|
-
}
|
|
271
|
-
} catch (err) {
|
|
272
|
-
if (err.code !== 'EEXIST') {
|
|
273
|
-
throw err;
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
// Create SPARC command files if --sparc flag is used
|
|
279
|
-
if (initSparc && !initDryRun) {
|
|
280
|
-
try {
|
|
281
|
-
const sparcTargetDir = `${workingDir}/.claude/commands/sparc`;
|
|
282
|
-
|
|
283
|
-
// Get SPARC mode templates
|
|
284
|
-
const sparcTemplates = createSparcModeTemplates();
|
|
285
|
-
|
|
286
|
-
console.log(' 📁 Creating SPARC command files...');
|
|
287
|
-
|
|
288
|
-
for (const [filename, content] of Object.entries(sparcTemplates)) {
|
|
289
|
-
try {
|
|
290
|
-
await Deno.writeTextFile(`${sparcTargetDir}/${filename}`, content);
|
|
291
|
-
console.log(` ✓ Created ${filename}`);
|
|
292
|
-
} catch (err) {
|
|
293
|
-
console.log(` ⚠️ Could not create ${filename}: ${err.message}`);
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
// Also create sparc-modes.md overview file
|
|
298
|
-
const sparcModesOverview = createSparcModesOverview();
|
|
299
|
-
await Deno.writeTextFile(`${sparcTargetDir}/sparc-modes.md`, sparcModesOverview);
|
|
300
|
-
console.log(` ✓ Created sparc-modes.md`);
|
|
301
|
-
|
|
302
|
-
console.log(' ✅ SPARC command files created successfully');
|
|
303
|
-
} catch (err) {
|
|
304
|
-
console.log(` ⚠️ Could not create SPARC files: ${err.message}`);
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
// Also create swarm strategy files
|
|
308
|
-
try {
|
|
309
|
-
const swarmTargetDir = `${workingDir}/.claude/commands/swarm`;
|
|
310
|
-
|
|
311
|
-
// Get swarm strategy templates
|
|
312
|
-
const swarmTemplates = createSwarmStrategyTemplates();
|
|
183
|
+
// Use template copier to copy all template files
|
|
184
|
+
const templateOptions = {
|
|
185
|
+
sparc: initSparc,
|
|
186
|
+
minimal: initMinimal,
|
|
187
|
+
optimized: initOptimized,
|
|
188
|
+
dryRun: initDryRun,
|
|
189
|
+
force: initForce,
|
|
190
|
+
selectedModes: selectedModes,
|
|
191
|
+
};
|
|
313
192
|
|
|
314
|
-
|
|
193
|
+
// First try to copy revised templates from repository
|
|
194
|
+
const validation = validateTemplatesExist();
|
|
195
|
+
if (validation.valid) {
|
|
196
|
+
console.log(' 📁 Copying revised template files...');
|
|
197
|
+
const revisedResults = await copyRevisedTemplates(workingDir, {
|
|
198
|
+
force: initForce,
|
|
199
|
+
dryRun: initDryRun,
|
|
200
|
+
verbose: true,
|
|
201
|
+
sparc: initSparc
|
|
202
|
+
});
|
|
315
203
|
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
} catch (err) {
|
|
321
|
-
console.log(` ⚠️ Could not create ${filename}: ${err.message}`);
|
|
322
|
-
}
|
|
204
|
+
if (revisedResults.success) {
|
|
205
|
+
console.log(` ✅ Copied ${revisedResults.copiedFiles.length} template files`);
|
|
206
|
+
if (revisedResults.skippedFiles.length > 0) {
|
|
207
|
+
console.log(` ⏭️ Skipped ${revisedResults.skippedFiles.length} existing files`);
|
|
323
208
|
}
|
|
324
|
-
|
|
325
|
-
console.log('
|
|
326
|
-
|
|
327
|
-
console.log(` ⚠️ Could not create swarm files: ${err.message}`);
|
|
209
|
+
} else {
|
|
210
|
+
console.log(' ⚠️ Some template files could not be copied:');
|
|
211
|
+
revisedResults.errors.forEach(err => console.log(` - ${err}`));
|
|
328
212
|
}
|
|
213
|
+
} else {
|
|
214
|
+
// Fall back to generated templates
|
|
215
|
+
console.log(' ⚠️ Revised templates not available, using generated templates');
|
|
216
|
+
const copyResults = await copyTemplates(workingDir, templateOptions);
|
|
329
217
|
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
sparc: {
|
|
335
|
-
enabled: true,
|
|
336
|
-
modes: [
|
|
337
|
-
'orchestrator',
|
|
338
|
-
'coder',
|
|
339
|
-
'researcher',
|
|
340
|
-
'tdd',
|
|
341
|
-
'architect',
|
|
342
|
-
'reviewer',
|
|
343
|
-
'debugger',
|
|
344
|
-
'tester',
|
|
345
|
-
'analyzer',
|
|
346
|
-
'optimizer',
|
|
347
|
-
'documenter',
|
|
348
|
-
'designer',
|
|
349
|
-
'innovator',
|
|
350
|
-
'swarm-coordinator',
|
|
351
|
-
'memory-manager',
|
|
352
|
-
'batch-executor',
|
|
353
|
-
'workflow-manager',
|
|
354
|
-
],
|
|
355
|
-
},
|
|
356
|
-
swarm: {
|
|
357
|
-
enabled: true,
|
|
358
|
-
strategies: [
|
|
359
|
-
'research',
|
|
360
|
-
'development',
|
|
361
|
-
'analysis',
|
|
362
|
-
'testing',
|
|
363
|
-
'optimization',
|
|
364
|
-
'maintenance',
|
|
365
|
-
],
|
|
366
|
-
},
|
|
367
|
-
};
|
|
368
|
-
|
|
369
|
-
await Deno.writeTextFile(
|
|
370
|
-
`${workingDir}/.claude/config.json`,
|
|
371
|
-
JSON.stringify(configContent, null, 2),
|
|
372
|
-
);
|
|
373
|
-
console.log(' ✓ Created .claude/config.json');
|
|
374
|
-
} catch (err) {
|
|
375
|
-
console.log(` ⚠️ Could not create config.json: ${err.message}`);
|
|
218
|
+
if (!copyResults.success) {
|
|
219
|
+
printError('Failed to copy templates:');
|
|
220
|
+
copyResults.errors.forEach(err => console.log(` ❌ ${err}`));
|
|
221
|
+
return;
|
|
376
222
|
}
|
|
377
223
|
}
|
|
378
224
|
|
|
379
|
-
//
|
|
380
|
-
const agentsReadme = createAgentsReadme();
|
|
381
|
-
if (!initDryRun) {
|
|
382
|
-
await Deno.writeTextFile('memory/agents/README.md', agentsReadme);
|
|
383
|
-
console.log(' ✓ Created memory/agents/README.md');
|
|
384
|
-
} else {
|
|
385
|
-
console.log(' [DRY RUN] Would create memory/agents/README.md');
|
|
386
|
-
}
|
|
225
|
+
// Directory structure is created by template copier
|
|
387
226
|
|
|
388
|
-
|
|
389
|
-
if (!initDryRun) {
|
|
390
|
-
await Deno.writeTextFile('memory/sessions/README.md', sessionsReadme);
|
|
391
|
-
console.log(' ✓ Created memory/sessions/README.md');
|
|
392
|
-
} else {
|
|
393
|
-
console.log(' [DRY RUN] Would create memory/sessions/README.md');
|
|
394
|
-
}
|
|
227
|
+
// SPARC files are created by template copier when --sparc flag is used
|
|
395
228
|
|
|
396
|
-
//
|
|
397
|
-
const initialData = {
|
|
398
|
-
agents: [],
|
|
399
|
-
tasks: [],
|
|
400
|
-
lastUpdated: Date.now(),
|
|
401
|
-
};
|
|
402
|
-
if (!initDryRun) {
|
|
403
|
-
await Deno.writeTextFile(
|
|
404
|
-
'memory/claude-flow-data.json',
|
|
405
|
-
JSON.stringify(initialData, null, 2),
|
|
406
|
-
);
|
|
407
|
-
console.log(' ✓ Created memory/claude-flow-data.json (persistence database)');
|
|
408
|
-
} else {
|
|
409
|
-
console.log(' [DRY RUN] Would create memory/claude-flow-data.json (persistence database)');
|
|
410
|
-
}
|
|
229
|
+
// Memory README files and persistence database are created by template copier
|
|
411
230
|
|
|
412
231
|
// Create local claude-flow executable wrapper
|
|
413
232
|
if (!initDryRun) {
|
|
@@ -1273,6 +1092,7 @@ ${commands.map((cmd) => `- [${cmd}](./${cmd}.md)`).join('\n')}
|
|
|
1273
1092
|
'coordination/subtasks',
|
|
1274
1093
|
'coordination/orchestration',
|
|
1275
1094
|
'.swarm', // Add .swarm directory for shared memory
|
|
1095
|
+
'.hive-mind', // Add .hive-mind directory for hive-mind system
|
|
1276
1096
|
];
|
|
1277
1097
|
|
|
1278
1098
|
for (const dir of standardDirs) {
|
|
@@ -1318,6 +1138,84 @@ ${commands.map((cmd) => `- [${cmd}](./${cmd}.md)`).join('\n')}
|
|
|
1318
1138
|
console.log(` ⚠️ Could not initialize memory system: ${err.message}`);
|
|
1319
1139
|
console.log(' Memory will be initialized on first use');
|
|
1320
1140
|
}
|
|
1141
|
+
|
|
1142
|
+
// Initialize hive-mind configuration
|
|
1143
|
+
try {
|
|
1144
|
+
const hiveMindConfig = {
|
|
1145
|
+
version: '2.0.0',
|
|
1146
|
+
initialized: new Date().toISOString(),
|
|
1147
|
+
defaults: {
|
|
1148
|
+
queenType: 'strategic',
|
|
1149
|
+
maxWorkers: 8,
|
|
1150
|
+
consensusAlgorithm: 'majority',
|
|
1151
|
+
memorySize: 100,
|
|
1152
|
+
autoScale: true,
|
|
1153
|
+
encryption: false,
|
|
1154
|
+
},
|
|
1155
|
+
mcpTools: {
|
|
1156
|
+
enabled: true,
|
|
1157
|
+
parallel: true,
|
|
1158
|
+
timeout: 60000,
|
|
1159
|
+
},
|
|
1160
|
+
};
|
|
1161
|
+
|
|
1162
|
+
await fs.writeFile(
|
|
1163
|
+
`${workingDir}/.hive-mind/config.json`,
|
|
1164
|
+
JSON.stringify(hiveMindConfig, null, 2),
|
|
1165
|
+
);
|
|
1166
|
+
|
|
1167
|
+
// Initialize hive.db
|
|
1168
|
+
try {
|
|
1169
|
+
const Database = (await import('better-sqlite3')).default;
|
|
1170
|
+
const hivePath = `${workingDir}/.hive-mind/hive.db`;
|
|
1171
|
+
const hiveDb = new Database(hivePath);
|
|
1172
|
+
|
|
1173
|
+
// Create initial tables
|
|
1174
|
+
hiveDb.exec(`
|
|
1175
|
+
CREATE TABLE IF NOT EXISTS swarms (
|
|
1176
|
+
id TEXT PRIMARY KEY,
|
|
1177
|
+
name TEXT NOT NULL,
|
|
1178
|
+
objective TEXT,
|
|
1179
|
+
status TEXT DEFAULT 'active',
|
|
1180
|
+
queen_type TEXT DEFAULT 'strategic',
|
|
1181
|
+
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
|
1182
|
+
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP
|
|
1183
|
+
);
|
|
1184
|
+
|
|
1185
|
+
CREATE TABLE IF NOT EXISTS agents (
|
|
1186
|
+
id TEXT PRIMARY KEY,
|
|
1187
|
+
swarm_id TEXT,
|
|
1188
|
+
name TEXT NOT NULL,
|
|
1189
|
+
type TEXT NOT NULL,
|
|
1190
|
+
capabilities TEXT,
|
|
1191
|
+
status TEXT DEFAULT 'active',
|
|
1192
|
+
performance_score REAL DEFAULT 0.5,
|
|
1193
|
+
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
|
1194
|
+
FOREIGN KEY (swarm_id) REFERENCES swarms (id)
|
|
1195
|
+
);
|
|
1196
|
+
|
|
1197
|
+
CREATE TABLE IF NOT EXISTS messages (
|
|
1198
|
+
id TEXT PRIMARY KEY,
|
|
1199
|
+
swarm_id TEXT,
|
|
1200
|
+
agent_id TEXT,
|
|
1201
|
+
content TEXT NOT NULL,
|
|
1202
|
+
type TEXT DEFAULT 'task',
|
|
1203
|
+
timestamp DATETIME DEFAULT CURRENT_TIMESTAMP,
|
|
1204
|
+
FOREIGN KEY (swarm_id) REFERENCES swarms (id),
|
|
1205
|
+
FOREIGN KEY (agent_id) REFERENCES agents (id)
|
|
1206
|
+
);
|
|
1207
|
+
`);
|
|
1208
|
+
|
|
1209
|
+
hiveDb.close();
|
|
1210
|
+
printSuccess('✓ Initialized hive-mind database (.hive-mind/hive.db)');
|
|
1211
|
+
} catch (dbErr) {
|
|
1212
|
+
console.log(` ⚠️ Could not initialize hive-mind database: ${dbErr.message}`);
|
|
1213
|
+
}
|
|
1214
|
+
|
|
1215
|
+
printSuccess('✓ Initialized hive-mind system');
|
|
1216
|
+
} catch (err) {
|
|
1217
|
+
console.log(` ⚠️ Could not initialize hive-mind system: ${err.message}`);
|
|
1218
|
+
}
|
|
1321
1219
|
}
|
|
1322
1220
|
|
|
1323
1221
|
// Update .gitignore with Claude Flow entries
|
|
@@ -1332,6 +1230,29 @@ ${commands.map((cmd) => `- [${cmd}](./${cmd}.md)`).join('\n')}
|
|
|
1332
1230
|
console.log(` ⚠️ ${gitignoreResult.message}`);
|
|
1333
1231
|
}
|
|
1334
1232
|
|
|
1233
|
+
// SPARC initialization (now included by default)
|
|
1234
|
+
console.log('\n🚀 Initializing SPARC development environment...');
|
|
1235
|
+
let sparcInitialized = false;
|
|
1236
|
+
try {
|
|
1237
|
+
// Run create-sparc
|
|
1238
|
+
console.log(' 🔄 Running: npx -y create-sparc init --force');
|
|
1239
|
+
execSync('npx -y create-sparc init --force', {
|
|
1240
|
+
cwd: workingDir,
|
|
1241
|
+
stdio: 'inherit',
|
|
1242
|
+
});
|
|
1243
|
+
sparcInitialized = true;
|
|
1244
|
+
printSuccess('✅ SPARC environment initialized successfully');
|
|
1245
|
+
} catch (err) {
|
|
1246
|
+
console.log(` ⚠️ Could not run create-sparc: ${err.message}`);
|
|
1247
|
+
console.log(' SPARC features will be limited to basic functionality');
|
|
1248
|
+
}
|
|
1249
|
+
|
|
1250
|
+
// Create Claude slash commands for SPARC
|
|
1251
|
+
if (sparcInitialized && !dryRun) {
|
|
1252
|
+
console.log('\n📝 Creating Claude Code slash commands...');
|
|
1253
|
+
await createClaudeSlashCommands(workingDir);
|
|
1254
|
+
}
|
|
1255
|
+
|
|
1335
1256
|
// Check for Claude Code and set up MCP servers (always enabled by default)
|
|
1336
1257
|
if (!dryRun && isClaudeCodeInstalled()) {
|
|
1337
1258
|
console.log('\n🔍 Claude Code CLI detected!');
|