card-news
v1.0.0
Published
๐จ Transform news articles into beautiful Instagram card news with AI-powered summarization
Maintainers
Readme
๐จ card-news CLI
Transform news articles into beautiful Instagram card news with AI-powered summarization.
A CLI tool that extracts articles from any URL, generates 5-line summaries using Claude AI, and creates stunning Instagram-ready PNG cards (1080x1350px).
๐ Features
- ๐ฐ Article Extraction - Parse articles from any URL
- ๐ค AI Summarization - Generate concise 5-line summaries using Claude
- ๐จ Beautiful Cards - Create 5 Instagram-ready PNG cards
- ๐ฏ Customizable - Magazine name, color, hashtags
- ๐พ Local Storage - Keep your config safe locally
- โก Fast - Generate cards in 6-15 seconds
- ๐ง CLI-JAW Style - Use your own API keys (zero hosting cost)
๐ Quick Start
Installation
npm install -g card-newsFirst Time Setup
card-news initYou'll be prompted for:
- Claude API Key (from https://console.anthropic.com/)
- Magazine name
- Primary color (hex code)
- Hashtags
Generate Card News
card-news generate https://example.com/articleOutput:
๐ card-news-output/
โโโ 01_cover.png (Magazine name + Title)
โโโ 02_content.png (Main topic)
โโโ 03_content.png (Key points)
โโโ 04_content.png (Details)
โโโ 05_end.png (Call-to-action)Other Commands
# View your magazine settings
card-news config
# Test Claude API connection
card-news test
# Show help
card-news --help๐ง Configuration
Settings are stored in ~/.card-news/config.json:
{
"apiKey": "sk-ant-...",
"magazineName": "My Magazine",
"color": "#FF6B6B",
"hashtags": ["๋ด์ค", "ํซ์ด์"]
}๐ Options
generate command
card-news generate <url> [options]
Options:
-o, --output <dir> Output directory (default: ./card-news-output)Example:
card-news generate https://example.com/article -o ./my-cards๐ Getting Your Claude API Key
- Visit https://console.anthropic.com/
- Create an account or log in
- Navigate to API Keys
- Click Create Key
- Copy your API key
- Use it in
card-news init
๐ก Tip: You can also set
CLAUDE_API_KEYas an environment variable:export CLAUDE_API_KEY=sk-ant-...
๐ How It Works
URL โ Extract Article โ AI Summarization โ Generate Cards
โ โ โ
Get title, Create 5 lines Beautiful
content, of concise text PNG images
metadata (30 chars) (1080x1350px)
each๐ก Use Cases
- Content Creators - Turn articles into visual posts
- News Aggregators - Summarize and showcase articles
- Social Media - Quick Instagram content generation
- Marketing - Transform blog posts into social graphics
- Education - Summarize research and news
โ๏ธ Technical Stack
| Component | Technology | |-----------|-----------| | Language | TypeScript 5+ | | CLI Framework | Commander.js | | HTML Parsing | Cheerio | | AI Engine | Claude 3 Opus (Anthropic) | | Image Generation | Canvas | | HTTP Requests | Axios | | CLI Colors | Chalk |
๐ System Requirements
- Node.js 18+
- npm or yarn
- Internet connection
- Claude API key
Canvas Dependencies
macOS
brew install pkg-config cairo libpng jpeg giflibUbuntu/Debian
sudo apt-get install build-essential libcairo2-dev libpango1.0-dev libjpeg-dev libgif-dev librsvg2-devCentOS/RHEL
sudo yum install gcc-c++ cairo-devel libjpeg-turbo-devel giflib-devel๐ Performance
| Metric | Time | |--------|------| | CLI startup | <1s | | Article extraction | 2-5s | | AI summarization | 3-8s | | Card generation | 1-2s | | Total | 6-15s |
๐ Troubleshooting
"Config not found"
card-news init"API connection failed"
- Check your Claude API key is valid
- Ensure you have internet connection
- Verify you have API credits
"Failed to extract article"
- Try a different article URL
- Some websites may block scraping
- Ensure the URL is accessible
Canvas build errors
See Canvas dependencies section above.
๐ฎ Roadmap
Phase 2 (Coming Soon)
- [ ] Multiple card templates
- [ ] ZIP export
- [ ] Batch processing (multiple articles)
- [ ] Advanced customization
- [ ] Preview mode
Phase 3
- [ ] npm package release
- [ ] Web UI (optional)
- [ ] Instagram API integration
- [ ] Community templates
๐ค Contributing
Contributions are welcome! Please feel free to:
- Report bugs
- Suggest features
- Submit pull requests
- Share feedback
๐ License
MIT License - see LICENSE file for details.
๐ FAQ
Q: Is this free? A: The tool is free, but you need a Claude API account. You use your own API key (your cost, not ours).
Q: Can I use this commercially? A: Yes! You can use this for commercial purposes as long as you comply with Claude's terms of service.
Q: How do I update my settings?
A: Run card-news init again to change your magazine settings.
Q: Does it work offline? A: No, you need internet to extract articles and call the Claude API.
Q: Can I use a different AI model? A: Currently it uses Claude 3 Opus. We may add support for other models in future versions.
๐ Support
- Issues & Bugs: GitHub Issues
- Discussions: GitHub Discussions
- Feature Requests: GitHub Issues (with label: feature)
๐ฏ Why card-news?
Unlike web-based alternatives that charge per generation or token:
- โ Zero hosting cost - You run it locally
- โ Infinite sustainability - Your own API key
- โ Full customization - It's open source
- โ Learning value - High-quality TypeScript code
- โ Portfolio ready - Impress potential employers
Made with โค๏ธ for content creators and developers
๐ Phase 2 Features (In Progress)
ZIP Export
Export all generated cards as a ZIP archive with metadata:
card-news generate https://example.com --zip
# โ card-news-output.zipThe ZIP file includes:
- All 5 PNG cards
- metadata.json with generation info
Upcoming Features
- Multiple card templates (minimal, detailed, colorful)
- Batch processing (multiple articles)
- Advanced customization (fonts, gradients, logos)
- Preview mode
๐ Security
We take security seriously:
- โ No hardcoded secrets or API keys
- โ Input validation for URLs and file paths
- โ Protection against directory traversal attacks
- โ Sensitive info never exposed in error messages
- โ User API keys stored locally only (not our servers)
- โ Safe file handling with proper cleanup
See SECURITY_CHECKLIST.md for details.
๐จ Templates
Choose from multiple pre-built templates:
# List all available templates
card-news templates
# Generate with specific template
card-news generate https://example.com -t detailedAvailable Templates
- minimal - Clean white design with black text (default)
- detailed - Light gray with more text space, elegant
- colorful - Vibrant red background with white text
Each template includes optimized:
- Colors and contrast
- Font sizes and spacing
- Card layout and proportions
Create Custom Templates
Templates are JSON files in templates/ directory. Copy an existing template and modify:
{
"name": "my-template",
"description": "My custom design",
"backgroundColor": "#FFFFFF",
"textColor": "#000000",
"accentColor": "#FF6B6B",
...
}๐งช Testing
Unit Tests
Run automated tests with Jest:
# Run all tests
npm test
# Watch mode (re-run on changes)
npm run test:watch
# Coverage report
npm run test:coverageTests include:
- URL validation
- Path security (traversal prevention)
- Template loading and configuration
- Filename sanitization
Manual Testing
Test the CLI directly:
# Set up API key
export CLAUDE_API_KEY="sk-ant-..."
# Initialize
card-news init
# Test API connection
card-news test
# Generate cards
card-news generate https://www.bbc.com/news
card-news generate https://techcrunch.com/
# Test templates
card-news generate https://example.com -t colorful
card-news generate https://example.com -t detailed
# Test ZIP export
card-news generate https://example.com --zip
# List templates
card-news templatesTesting Checklist
- [x] Unit tests with Jest
- [x] URL validation
- [x] Path security
- [x] Template system
- [ ] Integration tests (requires API key)
- [ ] E2E tests
- [ ] Performance tests
