Delete workspace-utils-fixed directory

This commit is contained in:
BarrelOfMonkeyNuts 2025-07-23 22:29:16 -04:00 committed by GitHub
parent 587344b624
commit c51b66c101
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 0 additions and 441 deletions

View File

@ -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 };

View File

@ -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 <from-agent> <to-agent> [context]');
process.exit(1);
}
createHandoff(args[0], args[1], args[2] || '');
}
module.exports = { createHandoff };

View File

@ -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 };

View File

@ -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 };

View File

@ -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 };