Skip to main content

molten_herald/
lib.rs

1//! # Herald 📢
2//!
3//! Automated viral tweet generation and scheduling for developer releases.
4//!
5//! Herald helps developers and teams automatically announce their work on Twitter/X
6//! by detecting events (releases, commits, PRs) and generating engaging tweets
7//! using LLMs.
8//!
9//! ## Features
10//!
11//! - **Event Detection**: Automatically detect releases from GitHub, crates.io, npm
12//! - **LLM-Powered Generation**: Generate viral tweets using Claude, GPT, or local models
13//! - **Twitter Integration**: Post directly to Twitter/X using the v2 API
14//! - **Scheduling**: Queue tweets for optimal posting times
15//! - **Templates**: Pre-built templates for common announcement types
16//!
17//! ## Quick Start
18//!
19//! ```bash
20//! # Install
21//! cargo install herald
22//!
23//! # Configure (creates ~/.config/herald/config.toml)
24//! herald init
25//!
26//! # Generate a tweet for a release
27//! herald generate --project myproject --event release
28//!
29//! # Post immediately
30//! herald post "just shipped something cool 🚀"
31//!
32//! # Schedule for later
33//! herald schedule "coming soon..." --time "2024-01-15 09:00"
34//! ```
35//!
36//! ## Configuration
37//!
38//! Herald uses a TOML configuration file:
39//!
40//! ```toml
41//! [twitter]
42//! api_key = "your-api-key"
43//! api_secret = "your-api-secret"
44//! access_token = "your-access-token"
45//! access_token_secret = "your-access-token-secret"
46//!
47//! [llm]
48//! provider = "anthropic"  # or "openai", "ollama"
49//! api_key = "your-api-key"
50//! model = "claude-sonnet-4-20250514"
51//!
52//! [defaults]
53//! emojis = true
54//! hashtags = false
55//! tone = "casual"  # casual, professional, hype, technical
56//! max_length = 280
57//!
58//! [[projects]]
59//! name = "myproject"
60//! github = "user/myproject"
61//! crates_io = "myproject"
62//! events = ["release", "major_feature"]
63//! ```
64//!
65//! ## Environment Variables
66//!
67//! Credentials can also be set via environment variables:
68//!
69//! - `TWITTER_API_KEY`
70//! - `TWITTER_API_SECRET`
71//! - `TWITTER_ACCESS_TOKEN`
72//! - `TWITTER_ACCESS_TOKEN_SECRET`
73//! - `ANTHROPIC_API_KEY` or `OPENAI_API_KEY`
74//! - `GITHUB_TOKEN` (for private repos)
75
76pub mod config;
77pub mod error;
78pub mod events;
79pub mod generator;
80pub mod interactive;
81pub mod scheduler;
82pub mod twitter;
83pub mod ui;
84
85pub use config::{Config, EventType, LlmConfig, ProjectConfig, ScheduleConfig, TweetDefaults, TwitterConfig};
86pub use error::{HeraldError, Result};
87pub use events::{Event, EventContext, EventDetector};
88pub use generator::{GeneratedTweet, TweetGenerator, TweetTemplates};
89pub use scheduler::{ScheduledTweet, ScheduleStatus, Scheduler};
90pub use twitter::{PostedTweet, TwitterClient};
91
92/// Herald version
93pub const VERSION: &str = env!("CARGO_PKG_VERSION");
94
95/// Default user agent for API requests
96pub const USER_AGENT: &str = concat!("herald/", env!("CARGO_PKG_VERSION"));
97
98#[cfg(test)]
99mod tests {
100    use super::*;
101
102    #[test]
103    fn test_version() {
104        assert!(!VERSION.is_empty());
105    }
106
107    #[test]
108    fn test_user_agent() {
109        assert!(USER_AGENT.starts_with("herald/"));
110    }
111}
112