Files
OpenClaw-bot-review/lib/daily.ts
T
liweiqiu797-cmyk 38ed48aceb feat: add Agent workspace and Daily board pages
- Add /workspace page: Agent grid with real-time status
- Add /daily page: Daily report board with TTS playback
- Add new API routes: /api/agents, /api/daily
- Add new components: agent-card, agent-grid
- Add sidebar navigation for new pages
- Add i18n labels (zh-CN + en)
2026-03-31 17:00:33 +08:00

53 lines
1.2 KiB
TypeScript

// lib/daily.ts
import { readFileSync, existsSync } from 'fs';
import { join } from 'path';
export interface DailyItem {
time: string;
content: string;
status: 'completed' | 'in-progress' | 'pending';
agent?: string;
}
export function getTodayItems(): DailyItem[] {
const today = new Date().toISOString().split('T')[0]; // YYYY-MM-DD
const memoryDir = join(process.env.HOME || '', '.openclaw/workspace/memory');
const dailyPath = join(memoryDir, `${today}.md`);
if (!existsSync(dailyPath)) {
return [];
}
let content = '';
try {
content = readFileSync(dailyPath, 'utf-8');
} catch {
return [];
}
const items: DailyItem[] = [];
const lines = content.split('\n');
for (const line of lines) {
// 匹配 - [x] 或 - [ ] 格式
const match = line.match(/^-\s+\[([ x])\]\s+(.+)/);
if (!match) continue;
const status = match[1] === 'x' ? 'completed' : 'pending';
const text = match[2];
// 提取时间(如果存在)
const timeMatch = text.match(/\[([\d: -]+)\]/);
const time = timeMatch?.[1] || '';
const contentText = text.replace(/\[[\d: -]+\]\s*/, '').trim();
items.push({
time,
content: contentText,
status,
});
}
return items;
}