@codemafia0000/d0
Version:
Claude Multi-Agent Automated Development AI - Revolutionary development environment where multiple AI agents collaborate to automate software development
72 lines (59 loc) • 2.25 kB
JavaScript
const fs = require('fs');
const path = require('path');
const CONSTANTS = require('../constants');
// Hook agent communication (enhanced for better message flow)
function hookAgentCommunication() {
// Create communication channels and status tracking
const d0Dir = CONSTANTS.D0_DIR;
const commDir = CONSTANTS.COMMUNICATION_DIR;
if (!fs.existsSync(commDir)) {
fs.mkdirSync(commDir, { recursive: true });
}
// Create communication guidelines file for agents
const guidelinesFile = path.join(commDir, 'communication_guidelines.md');
const guidelines = `# Agent Communication Guidelines
## Message Flow
1. PRESIDENT → boss (via \`d0 tell boss "message"\`)
2. boss → workers (via \`d0 tell worker1 "message"\`)
3. workers → boss (progress reports)
4. boss → PRESIDENT (status updates)
## Important Notes for Agents
- Always check your inbox file: \`.d0/tmp/inbox/[your-role].txt\`
- Acknowledge messages by creating completion files
- Report progress every 30 minutes
- Escalate blockers immediately
## Notification System
- Notification files indicate new messages: \`.d0/tmp/inbox/[role]_notification.txt\`
- Message status tracking: \`.d0/tmp/message_status.json\`
Generated: ${new Date().toISOString()}
`;
fs.writeFileSync(guidelinesFile, guidelines);
// Set up periodic communication health check
const healthCheckFile = path.join(commDir, 'health_check.sh');
const healthCheck = `#!/bin/bash
# Communication Health Check
echo "🔄 Checking agent communication health..."
INBOX_DIR=".d0/tmp/inbox"
if [ -d "$INBOX_DIR" ]; then
echo "📬 Inbox status:"
for role in president boss worker1 worker2 worker3; do
if [ -f "$INBOX_DIR/$role.txt" ]; then
count=$(wc -l < "$INBOX_DIR/$role.txt")
if [ -f "$INBOX_DIR/$role_notification.txt" ]; then
echo " • $role: $count messages (🔔 unread)"
else
echo " • $role: $count messages"
fi
fi
done
else
echo "⚠️ No inbox directory found"
fi
echo "📊 Communication status: \$(date)"
`;
fs.writeFileSync(healthCheckFile, healthCheck);
fs.chmodSync(healthCheckFile, '755');
}
module.exports = {
hookAgentCommunication
};