Open-source Python toolkit for AI-powered blog creation. Automates research, outlines, and drafting to deliver publish-ready posts.
Project description
๐ Pencraft
AI-powered blog writing toolkit that automates research, planning, and content creation
Features โข Installation โข Quick Start โข Configuration โข Documentation โข Contributing
โจ Features
| Feature | Description |
|---|---|
| ๐ Automated Research | Gathers information from the web with source citations |
| ๐ Google Trends | Validates topics and finds rising/related search queries |
| ๐ Smart Outlining | Dynamically chooses layout (Listicle, Deep Dive, Tutorial) |
| โ๏ธ Premium Writing | WSJ-style prose, human-like flow, and anti-AI-detection |
| ๐ Blog Enhancement | Improve existing blogs with SEO, content expansion, and fixes |
| ๐ Hugo Compatible | Outputs markdown with YAML/TOML frontmatter & cover images |
| โ๏ธ Fully Configurable | Custom API endpoints, models, prompts, and more |
| ๐ OpenAI Compatible | Works with any OpenAI-compatible API (local or cloud) |
| ๐จ Beautiful CLI | Rich terminal output with real-time progress indicators |
๐ฆ Installation
From Source
# Clone the repository
git clone https://github.com/suhaibbinyounis/pencraft.git
cd pencraft
# Install the package
pip install -e .
# Or with development dependencies
pip install -e ".[dev]"
From PyPI (Coming Soon)
pip install pencraft
๐ Quick Start
CLI Usage
# Generate a complete blog post
# Generate a premium blog post with cover image
pencraft write "The Future of Remote Work" \
--words 2000 \
--cover-image "https://images.unsplash.com/photo-1234.jpg" \
--output ./blogs \
--verbose
# Research a topic only
# Research a topic (includes Google Trends analysis)
pencraft research "AI in Healthcare"
# Generate an outline only
pencraft outline "Getting Started with Docker"
# View current configuration
pencraft config --show
# Create a config file
pencraft config --init
# Enhance existing blogs (SEO, content expansion, fixes)
pencraft enhance ./my-blog.md --words 3000
# Enhance entire directory
pencraft enhance ./blogs/ --recursive --words 3000
Python API
from pencraft import Settings
from pencraft.generator import BlogGenerator
# Create generator with custom settings
generator = BlogGenerator(settings=Settings(
llm={"base_url": "http://localhost:3030/v1", "api_key": "your-key"}
))
# Generate a blog post
blog = generator.generate(
topic="Introduction to Python",
target_word_count=2000,
tags=["python", "programming"],
output_dir="./output"
)
print(f"Generated: {blog.title} ({blog.word_count} words)")
print(f"Saved to: {blog.file_path}")
Enhance Existing Blogs
from pencraft import BlogEnhancer, Settings
enhancer = BlogEnhancer(settings=Settings())
# Enhance single file
result = enhancer.enhance(
Path("./my-blog.md"),
target_word_count=3000,
improve_seo=True,
use_trends=True,
)
print(f"Enhanced: {result.original_word_count} โ {result.enhanced_word_count} words")
# Batch enhance directory
results = enhancer.enhance_directory(Path("./blogs/"), pattern="*.md")
โ๏ธ Configuration
Pencraft supports multiple configuration methods:
1. Environment Variables
export PENCRAFT_LLM__BASE_URL="http://localhost:3030/v1"
export PENCRAFT_LLM__API_KEY="your-api-key"
export PENCRAFT_LLM__MODEL="gpt-4"
2. Configuration File
Create pencraft.yaml:
llm:
base_url: "http://localhost:3030/v1"
api_key: "your-api-key"
model: "gpt-4"
temperature: 0.7
blog:
min_word_count: 1500
include_toc: true
include_citations: true
hugo:
frontmatter_format: "yaml"
Use with: pencraft write "Topic" --config pencraft.yaml
LLM Provider Setup
LM Studio
- Download LM Studio
- Load a model and start the local server
- Configure:
base_url: "http://localhost:1234/v1"
Ollama
- Install Ollama
- Run:
ollama run llama2 - Configure:
base_url: "http://localhost:11434/v1"
OpenAI
llm:
base_url: "https://api.openai.com/v1"
api_key: "sk-your-key"
model: "gpt-4"
๐ Documentation
Project Structure
pencraft/
โโโ src/pencraft/
โ โโโ agents/ # AI agents (research, planner, writer)
โ โโโ config/ # Configuration management
โ โโโ formatters/ # Markdown, frontmatter, citations
โ โโโ llm/ # OpenAI-compatible client
โ โโโ tools/ # DuckDuckGo search, web scraper
โ โโโ cli.py # CLI interface
โ โโโ generator.py # Main orchestrator
โโโ tests/ # Unit tests
โโโ examples/ # Usage examples
โโโ pyproject.toml # Project configuration
CLI Commands
| Command | Description |
|---|---|
pencraft write <topic> |
Generate a complete blog post |
pencraft research <topic> |
Research a topic only |
pencraft outline <topic> |
Create a blog outline |
pencraft enhance <path> |
Enhance existing blog(s) with SEO & content improvements |
pencraft config --show |
Display current settings |
pencraft config --init |
Create a config file |
Output Example
Generated blogs include proper Hugo frontmatter:
---
title: "Introduction to Machine Learning"
date: 2024-01-15T10:30:00+00:00
draft: false
tags: ["machine-learning", "ai", "tutorial"]
categories: ["Technology"]
toc: true
author: "Pencraft"
---
# Introduction to Machine Learning
## Table of Contents
- [What is Machine Learning?](#what-is-machine-learning)
- [Types of Machine Learning](#types-of-machine-learning)
...
## What is Machine Learning?
Machine learning is a subset of artificial intelligence...
## References
1. [Machine Learning Basics](https://example.com) - Official documentation
๐งช Development
# Install dev dependencies
pip install -e ".[dev]"
# Run tests
pytest tests/ -v
# Run linting
ruff check src/ tests/
ruff format src/ tests/
# Type checking
mypy src/
๐ค Contributing
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Run tests and linting
- Commit (
git commit -m 'feat: add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐ Acknowledgments
- Built with LangChain for AI orchestration
- CLI powered by Typer and Rich
- Web search via DuckDuckGo
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pencraft-0.1.0.tar.gz.
File metadata
- Download URL: pencraft-0.1.0.tar.gz
- Upload date:
- Size: 67.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eabbc29da30f62ba7633d69637abeceaae9255dcd5955972b7c73fd922ea4b61
|
|
| MD5 |
e8feefad134eeb23411d9691c4153dc8
|
|
| BLAKE2b-256 |
974c7e8c85090f5bf330fe6a839ec4124f05fc4edac22b0aed216b688d198716
|
File details
Details for the file pencraft-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pencraft-0.1.0-py3-none-any.whl
- Upload date:
- Size: 62.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a76e4c67b564d24a0ae40ae2eb4481eb42e1245a491d7051eee7d1cffeb40737
|
|
| MD5 |
6c671c44cb6ecaaed2461c522c2d7b52
|
|
| BLAKE2b-256 |
e5e9cbe3834119be7b900762807caac08f4d00b09f195075b93a57b3ed03eb78
|