Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
A comprehensive collection of Agent Skills for context engineering, multi-agent architectures, and production agent systems.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
examples/digital-brain-skill/agents/scripts/weekly_review.py
1#!/usr/bin/env python32"""3Weekly Review Generator4Compiles data from Digital Brain into a weekly review document.5"""67import json8import os9from datetime import datetime, timedelta10from pathlib import Path1112# Get the digital brain root (parent of agents/)13BRAIN_ROOT = Path(__file__).parent.parent.parent1415def load_jsonl(filepath):16"""Load JSONL file, skipping schema lines."""17items = []18if not filepath.exists():19return items20with open(filepath, 'r') as f:21for line in f:22line = line.strip()23if not line:24continue25try:26data = json.loads(line)27# Skip schema definition lines28if '_schema' not in data:29items.append(data)30except json.JSONDecodeError:31continue32return items3334def get_week_range():35"""Get the start and end of the current week."""36today = datetime.now()37start = today - timedelta(days=today.weekday())38end = start + timedelta(days=6)39return start.strftime('%Y-%m-%d'), end.strftime('%Y-%m-%d')4041def analyze_content(week_start):42"""Analyze content published this week."""43posts = load_jsonl(BRAIN_ROOT / 'content' / 'posts.jsonl')44ideas = load_jsonl(BRAIN_ROOT / 'content' / 'ideas.jsonl')4546week_posts = [p for p in posts if p.get('published', '') >= week_start]47new_ideas = [i for i in ideas if i.get('created', '') >= week_start]4849return {50'posts_published': len(week_posts),51'new_ideas': len(new_ideas),52'posts': week_posts53}5455def analyze_network(week_start):56"""Analyze network activity this week."""57interactions = load_jsonl(BRAIN_ROOT / 'network' / 'interactions.jsonl')5859week_interactions = [i for i in interactions if i.get('date', '') >= week_start]6061return {62'interactions': len(week_interactions),63'details': week_interactions64}6566def analyze_metrics():67"""Get latest metrics if available."""68metrics = load_jsonl(BRAIN_ROOT / 'operations' / 'metrics.jsonl')69if metrics:70return metrics[-1] # Most recent71return {}7273def generate_review():74"""Generate the weekly review output."""75week_start, week_end = get_week_range()7677content = analyze_content(week_start)78network = analyze_network(week_start)79metrics = analyze_metrics()8081review = f"""82# Weekly Review: {week_start} to {week_end}83Generated: {datetime.now().isoformat()}8485## Summary8687### Content88- Posts published: {content['posts_published']}89- New ideas captured: {content['new_ideas']}9091### Network92- Interactions logged: {network['interactions']}9394### Latest Metrics95"""9697if metrics:98audience = metrics.get('audience', {})99for key, value in audience.items():100review += f"- {key}: {value}\n"101else:102review += "- No metrics recorded yet\n"103104review += """105## Action Items1061071. [ ] Review content performance1082. [ ] Plan next week's content1093. [ ] Follow up on pending introductions1104. [ ] Update goals progress1115. [ ] Schedule key meetings112113## Notes114115[Add your reflections here]116"""117118return review119120if __name__ == '__main__':121print(generate_review())122