From 3516ceffb0dbd4a08f25ec8fe7d9f87f28bde1fb Mon Sep 17 00:00:00 2001 From: rUv Date: Fri, 18 Jul 2025 21:08:23 +0000 Subject: [PATCH] feat(init): Make SPARC included by default and add hive.db initialization MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - SPARC is now included by default (no --sparc flag needed) - Added hive.db creation with initial tables (swarms, agents, messages) - Added SPARC initialization to v2.0.0 enhanced flow - Creates both .swarm/memory.db and .hive-mind/hive.db - Runs create-sparc init automatically - Creates slash commands for SPARC modes - Sessions directory is already created properly Now init creates complete environment with: - 113 total files - Both databases (.swarm/memory.db and .hive-mind/hive.db) - SPARC commands with MCP/npx fallback patterns - .roo directory with SPARC rules - Complete directory structure including sessions/ šŸ¤– Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- src/cli/simple-commands/init/index.js | 76 ++++++++++++++++++++++++++- 1 file changed, 74 insertions(+), 2 deletions(-) diff --git a/src/cli/simple-commands/init/index.js b/src/cli/simple-commands/init/index.js index d5eb84ca21..d5f89c975b 100644 --- a/src/cli/simple-commands/init/index.js +++ b/src/cli/simple-commands/init/index.js @@ -141,7 +141,7 @@ export async function initCommand(subArgs, flags) { // Parse init options const initForce = subArgs.includes('--force') || subArgs.includes('-f') || flags.force; const initMinimal = subArgs.includes('--minimal') || subArgs.includes('-m') || flags.minimal; - const initSparc = subArgs.includes('--sparc') || subArgs.includes('-s') || flags.sparc; + const initSparc = true; // SPARC is now included by default const initDryRun = subArgs.includes('--dry-run') || subArgs.includes('-d') || flags.dryRun; const initOptimized = initSparc && initForce; // Use optimized templates when both flags are present const selectedModes = flags.modes ? flags.modes.split(',') : null; // Support selective mode initialization @@ -197,7 +197,8 @@ export async function initCommand(subArgs, flags) { const revisedResults = await copyRevisedTemplates(workingDir, { force: initForce, dryRun: initDryRun, - verbose: true + verbose: true, + sparc: initSparc }); if (revisedResults.success) { @@ -1163,6 +1164,54 @@ ${commands.map((cmd) => `- [${cmd}](./${cmd}.md)`).join('\n')} JSON.stringify(hiveMindConfig, null, 2), ); + // Initialize hive.db + try { + const Database = (await import('better-sqlite3')).default; + const hivePath = `${workingDir}/.hive-mind/hive.db`; + const hiveDb = new Database(hivePath); + + // Create initial tables + hiveDb.exec(` + CREATE TABLE IF NOT EXISTS swarms ( + id TEXT PRIMARY KEY, + name TEXT NOT NULL, + objective TEXT, + status TEXT DEFAULT 'active', + queen_type TEXT DEFAULT 'strategic', + created_at DATETIME DEFAULT CURRENT_TIMESTAMP, + updated_at DATETIME DEFAULT CURRENT_TIMESTAMP + ); + + CREATE TABLE IF NOT EXISTS agents ( + id TEXT PRIMARY KEY, + swarm_id TEXT, + name TEXT NOT NULL, + type TEXT NOT NULL, + capabilities TEXT, + status TEXT DEFAULT 'active', + performance_score REAL DEFAULT 0.5, + created_at DATETIME DEFAULT CURRENT_TIMESTAMP, + FOREIGN KEY (swarm_id) REFERENCES swarms (id) + ); + + CREATE TABLE IF NOT EXISTS messages ( + id TEXT PRIMARY KEY, + swarm_id TEXT, + agent_id TEXT, + content TEXT NOT NULL, + type TEXT DEFAULT 'task', + timestamp DATETIME DEFAULT CURRENT_TIMESTAMP, + FOREIGN KEY (swarm_id) REFERENCES swarms (id), + FOREIGN KEY (agent_id) REFERENCES agents (id) + ); + `); + + hiveDb.close(); + printSuccess('āœ“ Initialized hive-mind database (.hive-mind/hive.db)'); + } catch (dbErr) { + console.log(` āš ļø Could not initialize hive-mind database: ${dbErr.message}`); + } + printSuccess('āœ“ Initialized hive-mind system'); } catch (err) { console.log(` āš ļø Could not initialize hive-mind system: ${err.message}`); @@ -1181,6 +1230,29 @@ ${commands.map((cmd) => `- [${cmd}](./${cmd}.md)`).join('\n')} console.log(` āš ļø ${gitignoreResult.message}`); } + // SPARC initialization (now included by default) + console.log('\nšŸš€ Initializing SPARC development environment...'); + let sparcInitialized = false; + try { + // Run create-sparc + console.log(' šŸ”„ Running: npx -y create-sparc init --force'); + execSync('npx -y create-sparc init --force', { + cwd: workingDir, + stdio: 'inherit', + }); + sparcInitialized = true; + printSuccess('āœ… SPARC environment initialized successfully'); + } catch (err) { + console.log(` āš ļø Could not run create-sparc: ${err.message}`); + console.log(' SPARC features will be limited to basic functionality'); + } + + // Create Claude slash commands for SPARC + if (sparcInitialized && !dryRun) { + console.log('\nšŸ“ Creating Claude Code slash commands...'); + await createClaudeSlashCommands(workingDir); + } + // Check for Claude Code and set up MCP servers (always enabled by default) if (!dryRun && isClaudeCodeInstalled()) { console.log('\nšŸ” Claude Code CLI detected!');