diff --git a/workspace-utils-fixed/cleanup.js b/workspace-utils-fixed/cleanup.js deleted file mode 100644 index dffff88f..00000000 --- a/workspace-utils-fixed/cleanup.js +++ /dev/null @@ -1,141 +0,0 @@ -#!/usr/bin/env node -const fs = require('fs'); -const path = require('path'); - -function ensureDir(dirPath) { - if (!fs.existsSync(dirPath)) { - fs.mkdirSync(dirPath, { recursive: true }); - } -} - -function removeFile(filePath) { - try { - fs.unlinkSync(filePath); - return true; - } catch (e) { - return false; - } -} - -function moveFile(sourcePath, targetPath) { - try { - const data = fs.readFileSync(sourcePath); - fs.writeFileSync(targetPath, data); - fs.unlinkSync(sourcePath); - return true; - } catch (e) { - return false; - } -} - -async function cleanupWorkspace() { - try { - const workspacePath = path.join(process.cwd(), '.workspace'); - - if (!fs.existsSync(workspacePath)) { - console.error('โŒ Workspace directory not found.'); - process.exit(1); - } - - console.log('๐Ÿงน Starting workspace cleanup...'); - - // Repair directory structure - const directories = ['sessions', 'context', 'handoffs', 'decisions', 'progress', 'quality', 'archive']; - let repairedDirs = 0; - - for (const dir of directories) { - const dirPath = path.join(workspacePath, dir); - if (!fs.existsSync(dirPath)) { - ensureDir(dirPath); - repairedDirs++; - } - } - - if (repairedDirs > 0) { - console.log(`โœ… Repaired ${repairedDirs} missing directories`); - } - - // Clean up expired sessions (older than 2 hours) - const sessionsPath = path.join(workspacePath, 'sessions'); - let sessionFiles = []; - if (fs.existsSync(sessionsPath)) { - sessionFiles = fs.readdirSync(sessionsPath); - } - const twoHoursAgo = Date.now() - (2 * 60 * 60 * 1000); - - let cleanedSessions = 0; - for (const file of sessionFiles) { - if (file.endsWith('.json')) { - try { - const sessionPath = path.join(sessionsPath, file); - const sessionContent = fs.readFileSync(sessionPath, 'utf8'); - const sessionData = JSON.parse(sessionContent); - const lastHeartbeat = new Date(sessionData.lastHeartbeat).getTime(); - - if (lastHeartbeat < twoHoursAgo) { - if (removeFile(sessionPath)) { - cleanedSessions++; - } - } - } catch (e) { - // Remove corrupted session files - if (removeFile(path.join(sessionsPath, file))) { - cleanedSessions++; - } - } - } - } - - if (cleanedSessions > 0) { - console.log(`โœ… Cleaned up ${cleanedSessions} expired sessions`); - } - - // Archive old context files (older than 30 days) - const contextPath = path.join(workspacePath, 'context'); - const archivePath = path.join(workspacePath, 'archive'); - const thirtyDaysAgo = Date.now() - (30 * 24 * 60 * 60 * 1000); - - if (fs.existsSync(contextPath)) { - let contextFiles = []; - try { - contextFiles = fs.readdirSync(contextPath); - } catch (e) { - contextFiles = []; - } - - let archivedFiles = 0; - - for (const file of contextFiles) { - const filePath = path.join(contextPath, file); - try { - const stats = fs.statSync(filePath); - - if (stats.mtime.getTime() < thirtyDaysAgo) { - const archiveFile = path.join(archivePath, `archived-${Date.now()}-${file}`); - if (moveFile(filePath, archiveFile)) { - archivedFiles++; - } - } - } catch (e) { - // Skip files that can't be processed - } - } - - if (archivedFiles > 0) { - console.log(`โœ… Archived ${archivedFiles} old context files`); - } - } - - console.log('โœ… Workspace cleanup completed successfully'); - - } catch (error) { - console.error('โŒ Failed to cleanup workspace:', error.message); - process.exit(1); - } -} - -if (require.main === module) { - cleanupWorkspace(); -} - -module.exports = { cleanupWorkspace }; \ No newline at end of file diff --git a/workspace-utils-fixed/handoff.js b/workspace-utils-fixed/handoff.js deleted file mode 100644 index b6a130c3..00000000 --- a/workspace-utils-fixed/handoff.js +++ /dev/null @@ -1,77 +0,0 @@ -#!/usr/bin/env node -const fs = require('fs'); -const path = require('path'); - -async function createHandoff(fromAgent, toAgent, context = '') { - try { - const workspacePath = path.join(process.cwd(), '.workspace'); - const handoffsPath = path.join(workspacePath, 'handoffs'); - - if (!fs.existsSync(handoffsPath)) { - console.error('โŒ Workspace handoffs directory not found.'); - process.exit(1); - } - - const timestamp = new Date().toISOString().replace(/[:.]/g, '-'); - const handoffId = `${fromAgent}-to-${toAgent}-${timestamp}`; - const handoffFile = path.join(handoffsPath, `${handoffId}.md`); - - const handoffContent = `# Agent Handoff: ${fromAgent} โ†’ ${toAgent} - -**Created:** ${new Date().toISOString()} -**Handoff ID:** ${handoffId} -**Source Agent:** ${fromAgent} -**Target Agent:** ${toAgent} - -## Context Summary -${context || 'No additional context provided.'} - -## Key Decisions Made -[To be filled by source agent] - -## Current Progress -[To be filled by source agent] - -## Next Actions for ${toAgent} -- [ ] [Action item 1] -- [ ] [Action item 2] -- [ ] [Action item 3] - -## Files and References -[List of relevant files and documentation] - -## Blockers and Dependencies -[Any blockers or dependencies the target agent should be aware of] - -## Handoff Validation -- [ ] Context completeness verified -- [ ] Decisions documented -- [ ] Next actions clearly defined -- [ ] References included -`; - - fs.writeFileSync(handoffFile, handoffContent); - - console.log('โœ… Handoff package created successfully'); - console.log(`๐Ÿ“ฆ Handoff ID: ${handoffId}`); - console.log(`๐Ÿ“ File: ${handoffFile}`); - - return handoffId; - } catch (error) { - console.error('โŒ Failed to create handoff:', error.message); - process.exit(1); - } -} - -// Command line usage -if (require.main === module) { - const args = process.argv.slice(2); - if (args.length < 2) { - console.log('Usage: node handoff.js [context]'); - process.exit(1); - } - - createHandoff(args[0], args[1], args[2] || ''); -} - -module.exports = { createHandoff }; \ No newline at end of file diff --git a/workspace-utils-fixed/init.js b/workspace-utils-fixed/init.js deleted file mode 100644 index 8c2a0df8..00000000 --- a/workspace-utils-fixed/init.js +++ /dev/null @@ -1,52 +0,0 @@ -#!/usr/bin/env node -const fs = require('fs'); -const path = require('path'); -const crypto = require('crypto'); - -async function initWorkspace() { - try { - const workspacePath = path.join(process.cwd(), '.workspace'); - - if (!fs.existsSync(workspacePath)) { - console.error('โŒ Workspace directory not found. Run `npx bmad-method install` first.'); - process.exit(1); - } - - // Generate session ID - const sessionId = crypto.randomBytes(8).toString('hex'); - const timestamp = new Date().toISOString(); - - // Create session file - const sessionData = { - id: sessionId, - created: timestamp, - lastHeartbeat: timestamp, - ide: process.env.IDE_TYPE || 'unknown', - pid: process.pid, - user: process.env.USER || process.env.USERNAME || 'unknown' - }; - - const sessionsPath = path.join(workspacePath, 'sessions'); - if (!fs.existsSync(sessionsPath)) { - fs.mkdirSync(sessionsPath, { recursive: true }); - } - - const sessionFile = path.join(sessionsPath, `${sessionId}.json`); - fs.writeFileSync(sessionFile, JSON.stringify(sessionData, null, 2)); - - console.log('โœ… Workspace initialized successfully'); - console.log(`๐Ÿ“ Session ID: ${sessionId}`); - console.log(`๐Ÿ• Created: ${timestamp}`); - - return sessionId; - } catch (error) { - console.error('โŒ Failed to initialize workspace:', error.message); - process.exit(1); - } -} - -if (require.main === module) { - initWorkspace(); -} - -module.exports = { initWorkspace }; \ No newline at end of file diff --git a/workspace-utils-fixed/status.js b/workspace-utils-fixed/status.js deleted file mode 100644 index 73b03eee..00000000 --- a/workspace-utils-fixed/status.js +++ /dev/null @@ -1,87 +0,0 @@ -#!/usr/bin/env node -const fs = require('fs'); -const path = require('path'); - -async function getWorkspaceStatus() { - try { - const workspacePath = path.join(process.cwd(), '.workspace'); - - if (!fs.existsSync(workspacePath)) { - console.error('โŒ Workspace directory not found.'); - process.exit(1); - } - - // Read workspace config - const configPath = path.join(workspacePath, 'workspace-config.json'); - let config = {}; - if (fs.existsSync(configPath)) { - const configContent = fs.readFileSync(configPath, 'utf8'); - config = JSON.parse(configContent); - } - - // Get active sessions - const sessionsPath = path.join(workspacePath, 'sessions'); - let sessionFiles = []; - if (fs.existsSync(sessionsPath)) { - sessionFiles = fs.readdirSync(sessionsPath); - } - - const activeSessions = []; - for (const file of sessionFiles) { - if (file.endsWith('.json')) { - try { - const sessionPath = path.join(sessionsPath, file); - const sessionContent = fs.readFileSync(sessionPath, 'utf8'); - const sessionData = JSON.parse(sessionContent); - activeSessions.push(sessionData); - } catch (e) { - // Skip corrupted session files - } - } - } - - // Display status - console.log('๐Ÿค BMAD Collaborative Workspace Status'); - console.log('====================================='); - console.log(`๐Ÿ“ Workspace: ${workspacePath}`); - console.log(`โš™๏ธ Version: ${config.version || 'Unknown'}`); - console.log(`๐Ÿ• Created: ${config.created || 'Unknown'}`); - console.log(`๐Ÿ‘ฅ Active Sessions: ${activeSessions.length}`); - - if (activeSessions.length > 0) { - console.log('\n๐Ÿ“ Session Details:'); - activeSessions.forEach((session, index) => { - console.log(` ${index + 1}. ${session.id} (${session.ide}) - ${session.user}`); - console.log(` Created: ${new Date(session.created).toLocaleString()}`); - console.log(` Last Heartbeat: ${new Date(session.lastHeartbeat).toLocaleString()}`); - }); - } - - // Check directory structure - const directories = ['context', 'handoffs', 'decisions', 'progress', 'quality', 'archive']; - const missingDirs = []; - - for (const dir of directories) { - if (!fs.existsSync(path.join(workspacePath, dir))) { - missingDirs.push(dir); - } - } - - if (missingDirs.length > 0) { - console.log(`\nโš ๏ธ Missing directories: ${missingDirs.join(', ')}`); - console.log(' Run `node workspace-utils/cleanup.js` to repair.'); - } else { - console.log('\nโœ… Workspace structure is healthy'); - } - - } catch (error) { - console.error('โŒ Failed to get workspace status:', error.message); - process.exit(1); - } -} - -if (require.main === module) { - getWorkspaceStatus(); -} - -module.exports = { getWorkspaceStatus }; \ No newline at end of file diff --git a/workspace-utils-fixed/sync.js b/workspace-utils-fixed/sync.js deleted file mode 100644 index 37fb0357..00000000 --- a/workspace-utils-fixed/sync.js +++ /dev/null @@ -1,84 +0,0 @@ -#!/usr/bin/env node -const fs = require('fs'); -const path = require('path'); - -async function syncWorkspace() { - try { - const workspacePath = path.join(process.cwd(), '.workspace'); - - if (!fs.existsSync(workspacePath)) { - console.error('โŒ Workspace directory not found.'); - process.exit(1); - } - - console.log('๐Ÿ”„ Synchronizing workspace context...'); - - // Update session heartbeat - const sessionsPath = path.join(workspacePath, 'sessions'); - let sessionFiles = []; - if (fs.existsSync(sessionsPath)) { - try { - sessionFiles = fs.readdirSync(sessionsPath); - } catch (e) { - sessionFiles = []; - } - } - - // For simplicity, update the most recent session - let latestSession = null; - let latestTime = 0; - - for (const file of sessionFiles) { - if (file.endsWith('.json')) { - try { - const sessionPath = path.join(sessionsPath, file); - const sessionContent = fs.readFileSync(sessionPath, 'utf8'); - const sessionData = JSON.parse(sessionContent); - const created = new Date(sessionData.created).getTime(); - - if (created > latestTime) { - latestTime = created; - latestSession = { path: sessionPath, data: sessionData }; - } - } catch (e) { - // Skip corrupted files - } - } - } - - if (latestSession) { - latestSession.data.lastHeartbeat = new Date().toISOString(); - fs.writeFileSync(latestSession.path, JSON.stringify(latestSession.data, null, 2)); - console.log(`โœ… Updated session heartbeat: ${latestSession.data.id}`); - } - - // Load and display recent context - const contextPath = path.join(workspacePath, 'context'); - const sharedContext = path.join(contextPath, 'shared-context.md'); - - if (fs.existsSync(sharedContext)) { - try { - const content = fs.readFileSync(sharedContext, 'utf8'); - console.log('\n๐Ÿ“„ Current Shared Context:'); - console.log('='.repeat(50)); - console.log(content.substring(0, 500) + (content.length > 500 ? '...' : '')); - } catch (e) { - console.log('\n๐Ÿ“„ Shared context file exists but could not be read.'); - } - } else { - console.log('\n๐Ÿ“„ No shared context available yet.'); - } - - console.log('\nโœ… Workspace synchronization completed'); - - } catch (error) { - console.error('โŒ Failed to sync workspace:', error.message); - process.exit(1); - } -} - -if (require.main === module) { - syncWorkspace(); -} - -module.exports = { syncWorkspace }; \ No newline at end of file