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/content_ideas.py
1#!/usr/bin/env python32"""3Content Ideas Generator4Generates content ideas based on knowledge base and past successful content.5"""67import json8import argparse9from datetime import datetime10from pathlib import Path1112BRAIN_ROOT = Path(__file__).parent.parent.parent1314def load_jsonl(filepath):15"""Load JSONL file, skipping schema lines."""16items = []17if not filepath.exists():18return items19with open(filepath, 'r') as f:20for line in f:21line = line.strip()22if not line:23continue24try:25data = json.loads(line)26if '_schema' not in data:27items.append(data)28except json.JSONDecodeError:29continue30return items3132def get_top_performing_content():33"""Get posts with highest engagement."""34posts = load_jsonl(BRAIN_ROOT / 'content' / 'posts.jsonl')3536# Sort by engagement metrics if available37def engagement_score(post):38metrics = post.get('metrics', {})39return (40metrics.get('likes', 0) +41metrics.get('comments', 0) * 2 +42metrics.get('reposts', 0) * 343)4445sorted_posts = sorted(posts, key=engagement_score, reverse=True)46return sorted_posts[:5]4748def get_recent_bookmarks(category=None):49"""Get recent bookmarks, optionally filtered by category."""50bookmarks = load_jsonl(BRAIN_ROOT / 'knowledge' / 'bookmarks.jsonl')5152if category:53bookmarks = [b for b in bookmarks if b.get('category') == category]5455# Sort by date, most recent first56bookmarks.sort(key=lambda x: x.get('saved_at', ''), reverse=True)57return bookmarks[:10]5859def get_undeveloped_ideas():60"""Get ideas that haven't been developed yet."""61ideas = load_jsonl(BRAIN_ROOT / 'content' / 'ideas.jsonl')6263raw_ideas = [i for i in ideas if i.get('status') == 'raw']64return raw_ideas6566def generate_suggestions(pillar=None, count=5):67"""Generate content suggestions."""6869output = f"""70# Content Ideas Generator71Generated: {datetime.now().isoformat()}72Filter: {pillar or 'All pillars'}7374## Based on Top Performing Content75"""7677top_posts = get_top_performing_content()78if top_posts:79output += "\nYour best performing content themes:\n"80for post in top_posts[:3]:81output += f"- {post.get('pillar', 'Unknown')}: {post.get('type', 'post')}\n"82output += "\n**Suggestion**: Create more content in these high-performing areas.\n"83else:84output += "\nNo post history yet. Start creating!\n"8586output += """87## From Your Knowledge Base88"""8990bookmarks = get_recent_bookmarks(pillar)91if bookmarks:92output += "\nRecent topics you've been researching:\n"93for bm in bookmarks[:5]:94output += f"- {bm.get('title', 'Untitled')} ({bm.get('category', 'uncategorized')})\n"95if bm.get('key_insights'):96output += f" Key insight: {bm['key_insights'][0]}\n"97output += "\n**Suggestion**: Turn these research topics into educational content.\n"98else:99output += "\nNo bookmarks yet. Save interesting content to fuel ideas.\n"100101output += """102## Undeveloped Ideas103"""104105ideas = get_undeveloped_ideas()106if ideas:107output += f"\nYou have {len(ideas)} undeveloped ideas:\n"108for idea in ideas[:count]:109output += f"- [{idea.get('priority', 'medium')}] {idea.get('idea', 'No content')}\n"110output += "\n**Suggestion**: Pick one high-priority idea and develop it today.\n"111else:112output += "\nNo undeveloped ideas in the queue.\n"113114output += """115## Quick Prompts1161171. "What's one thing I learned this week that others would find valuable?"1182. "What's a common mistake I see in my industry?"1193. "What question do I get asked most often?"1204. "What worked for me that's counterintuitive?"1215. "What do I wish I knew when I started?"122"""123124return output125126if __name__ == '__main__':127parser = argparse.ArgumentParser(description='Generate content ideas')128parser.add_argument('--pillar', '-p', help='Filter by content pillar')129parser.add_argument('--count', '-c', type=int, default=5, help='Number of ideas to show')130131args = parser.parse_args()132print(generate_suggestions(args.pillar, args.count))133