← back to Daily Reporting
README.md
411 lines
# Daily Reporting System for DW-Agents
Comprehensive automated reporting system that generates morning standup and end-of-day summary reports for all DW-Agents in the hierarchy.
## Features
- **Automated Daily Reports**: Morning (6:00 AM) and End-of-Day (5:00 PM)
- **Hierarchical Agent Collection**: Collects data from all agents in organizational order
- **Executive Summary**: System health, critical alerts, top achievements
- **Department Reports**: Detailed metrics from each department
- **Issue Detection**: Automatic identification of problems requiring attention
- **Action Items**: Clear next steps based on current status
- **Q&A Readiness**: Agent status and recent activities
- **Slack Integration**: Formatted reports sent to #morning-report channel
- **File Backup**: All reports saved to `/root/DW-Agents/reports/`
## Agent Hierarchy
### Executive Level
- **Master Hub (President)** - Port 9893 - Central command & coordination
### Department Heads
- **Legal Team** - Port 9878 - Legal compliance & risk management
- **Accounting** - Port 9882 - Financial management & reporting
- **Marketing** - Port 9881 - Marketing campaigns & content
- **Purchasing Office** - Port 9880 - Procurement & vendor management
- **Digital Samples** - Port 9879 - Sample processing & delivery
- **Trend Research** - Port 9883 - Market intelligence & analysis
### Support Services
- **Zendesk Chat** - Port 9884 - Customer support & chat
- **Shopify Store Manager** - Port 7238 - E-commerce operations
- **Server Uptime Monitor** - Port 7242 - Infrastructure monitoring
- **Log Monitor** - Port 7239 - Error detection & analysis
- **UI Manager** - Port 7240 - Design system & UX
- **Restart Analyzer** - Port 7241 - System health & pattern analysis
### Operations & Orchestration
- **Task Orchestrator** - Port 9900 - Task routing & coordination
- **Needs Attention** - Port 7243 - Issue detection & escalation
## Installation
### 1. Install Dependencies
```bash
cd /root/DW-Agents
npm install node-fetch @types/node-fetch
```
### 2. Configure Slack Webhook
Create a Slack incoming webhook:
1. Go to https://api.slack.com/messaging/webhooks
2. Click "Create New App" > "From scratch"
3. Name it "DW-Agents Reporter"
4. Select your workspace
5. Click "Incoming Webhooks" > "Activate Incoming Webhooks"
6. Click "Add New Webhook to Workspace"
7. Select the **#morning-report** channel (create it first if needed)
8. Copy the webhook URL
### 3. Set Environment Variables
Add to `~/.bashrc` or `~/.profile`:
```bash
export SLACK_WEBHOOK_URL="https://hooks.slack.com/services/YOUR/WEBHOOK/URL"
export SLACK_CHANNEL="#morning-report"
export REPORTS_DIR="/root/DW-Agents/reports"
```
Then reload:
```bash
source ~/.bashrc
```
### 4. Run Setup Script
```bash
cd /root/.claude/skills/daily-reporting
./setup-cron.sh
```
This will:
- Verify prerequisites
- Configure Slack (if needed)
- Install cron jobs
- Run a test report
## Usage
### Manual Report Generation
```bash
cd /root/.claude/skills/daily-reporting
# Generate morning report
tsx daily-report-runner.ts morning
# Generate end-of-day report
tsx daily-report-runner.ts eod
# Test Slack connection
tsx daily-report-runner.ts test
# Show help
tsx daily-report-runner.ts help
```
### Automated Scheduling
Reports are automatically generated via cron:
- **6:00 AM**: Morning standup report
- **5:00 PM**: End-of-day summary
View cron jobs:
```bash
crontab -l
```
### Monitor Logs
```bash
# Morning report logs
tail -f /root/DW-Agents/logs/morning-report.log
# EOD report logs
tail -f /root/DW-Agents/logs/eod-report.log
# All reports saved to
ls -lh /root/DW-Agents/reports/
```
## Report Structure
### Executive Summary
- System health percentage
- Agents online count
- Tasks completed today
- Critical issues count
- Top achievements
### Department Reports
For each department:
- Agent status (online/offline)
- Tasks completed
- Error counts
- Highlights and achievements
- Issues detected
### Issues Requiring Attention
Prioritized list of:
- Critical: Offline agents, system failures
- High: High error rates, performance issues
- Medium: Degraded performance, low readiness
- Low: Minor warnings
### Action Items
- Clear next steps based on current status
- Prioritized by severity
- Includes department-specific actions
### Q&A Readiness Status
- Overall readiness score (0-100)
- Individual agent readiness scores
- Recent activities per agent
## Slack Integration
### Channel Setup
1. **Create the channel**:
```
/create #morning-report
```
2. **Set channel description**:
```
Daily automated reports from DW-Agents system
Morning standup at 6:00 AM | EOD summary at 5:00 PM
```
3. **Invite team members**:
```
/invite @username
```
### Message Format
Reports are sent in clean Slack markdown with:
- Health bars with emoji indicators
- Status indicators (✅❌⚠️)
- Severity emojis (🚨⚠️⚡ℹ️)
- Department sections
- Action buttons to dashboard
- @channel mentions for critical issues
### Sample Report
```
☀️ MORNING STANDUP REPORT
Friday, November 9, 2025
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📊 EXECUTIVE SUMMARY
System Health: 🟢🟢🟢🟢🟢🟢🟢🟢🟢⚪⚪⚪⚪⚪⚪ 95%
Agents Online: 14/15
Tasks Completed Today: 127
Critical Issues: ✅ None
🏆 Top Achievements:
1. Marketing completed 45 tasks
2. Digital Samples processed 32 orders
3. Zendesk handled 28 tickets
🏢 DEPARTMENT REPORTS
Executive (1/1 online)
🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢 100%
Tasks Completed: 12
✅ Master Hub (President) • 12 tasks
Legal (1/1 online)
🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢 100%
Tasks Completed: 8
✅ Legal Team • 8 tasks
...
```
## Troubleshooting
### No Slack Messages Received
1. **Verify webhook URL**:
```bash
echo $SLACK_WEBHOOK_URL
```
2. **Test connection**:
```bash
cd /root/.claude/skills/daily-reporting
tsx daily-report-runner.ts test
```
3. **Check logs**:
```bash
tail -50 /root/DW-Agents/logs/morning-report.log
```
### Agents Showing as Offline
1. **Check PM2 status**:
```bash
pm2 list
```
2. **Check individual agent**:
```bash
curl http://45.61.58.125:9878/api/metrics
```
3. **View agent logs**:
```bash
pm2 logs dw-legal-team
```
### Cron Jobs Not Running
1. **Verify cron is running**:
```bash
systemctl status cron
```
2. **Check crontab**:
```bash
crontab -l
```
3. **Run manually to test**:
```bash
cd /root/.claude/skills/daily-reporting
tsx daily-report-runner.ts morning
```
### Reports Not Saving
1. **Check directory permissions**:
```bash
ls -la /root/DW-Agents/reports/
```
2. **Create directory if missing**:
```bash
mkdir -p /root/DW-Agents/reports
```
## Customization
### Change Report Times
Edit crontab:
```bash
crontab -e
```
Cron format: `minute hour day month weekday`
Examples:
```
# 7:00 AM instead of 6:00 AM
0 7 * * * cd /root/.claude/skills/daily-reporting && tsx daily-report-runner.ts morning
# 6:00 PM instead of 5:00 PM
0 18 * * * cd /root/.claude/skills/daily-reporting && tsx daily-report-runner.ts eod
```
### Add Custom Metrics
Edit `/root/.claude/skills/daily-reporting/agent-hierarchy.ts` to add metrics for each agent.
### Change Slack Channel
```bash
export SLACK_CHANNEL="#your-channel-name"
```
Update in crontab:
```bash
crontab -e
# Add: SLACK_CHANNEL=#your-channel-name
```
### Disable @channel Mentions
Edit `/root/.claude/skills/daily-reporting/slack-notifier.ts`:
```typescript
const slackConfig = {
// ...
mentionChannelOnIssues: false // Change to false
};
```
## API Endpoints
Each agent should expose a `/api/metrics` endpoint returning:
```json
{
"uptime": 86400,
"responseTime": 150,
"tasksCompleted": 42,
"errorsToday": 2,
"qnaReadiness": 85,
"lastActivity": "2025-11-09T14:30:00Z",
"customMetrics": {
"specific_metric": "value"
}
}
```
## Files Structure
```
/root/.claude/skills/daily-reporting/
├── skill.json # Skill configuration
├── agent-hierarchy.ts # Agent organizational structure
├── report-generator.ts # Report generation logic
├── slack-formatter.ts # Slack message formatting
├── slack-notifier.ts # Slack API integration
├── daily-report-runner.ts # Main entry point
├── setup-cron.sh # Installation script
└── README.md # This file
/root/DW-Agents/reports/ # Backup reports directory
├── morning-report-2025-11-09-06-00-00.json
├── eod-report-2025-11-09-17-00-00.json
└── ...
/root/DW-Agents/logs/ # Log files
├── morning-report.log
└── eod-report.log
```
## Support
For issues or questions:
1. Check logs: `tail -f /root/DW-Agents/logs/morning-report.log`
2. Run manual test: `tsx daily-report-runner.ts morning`
3. Test Slack: `tsx daily-report-runner.ts test`
4. Review agent status: `pm2 list`
## Version History
- **v1.0.0** (2025-11-09)
- Initial release
- Morning and EOD reports
- Full agent hierarchy support
- Slack integration
- Automated scheduling
- Q&A readiness tracking