This is a fully functional AI-assisted writing skill that can generate a book outline based on the prompt provided by the user, progressively expand the content of each chapter, and support inserting formulas, charts, tables, code, and other elements into the content.
Features
📚 Outline Generation Capability
- Intelligent Outline Generation: Automatically generate a structured book outline based on the prompt
- Multi-level Structure: Support multi-level structures such as chapters, sections, and subsections
- Content Planning: Provide content summaries and key points for each chapter
- Style Adaptation: Adjust the outline structure according to the book type
✍️ Content Expansion Capability
- Progressive Expansion: Gradually expand from chapter titles to specific content
- Rich Content: Automatically add elements such as formulas, charts, tables, and code
- Citation Management: Automatically generate and manage bibliographic citations
- Format Standards: Follow academic or publishing format standards
🧩 Multimedia Support
- Mathematical Formulas: Insert mathematical formulas in LaTeX format
- Chart Generation: Generate chart descriptions based on content needs
- Code Snippets: Support code insertion in multiple programming languages
- Table Design: Creation and filling of structured tables
📖 Type Adaptation
- Academic Works: Comply with academic writing standards
- Technical Books: Include code examples and technical diagrams
- Novel Creation: Support plot development and character description
- Textbooks: Include exercises and summaries of key knowledge points
Quick Start
1. Install the Skill
# 进入技能目录
cd book-writer
# 安装依赖
python scripts/install_dependencies.py
2. Set the API Key
# 设置环境变量
export OPENAI_API_KEY="your_openai_api_key"
export GOOGLE_CSE_ID="your_google_cse_id" # 用于搜索素材
export GOOGLE_API_KEY="your_google_api_key" # 用于搜索素材
3. Generate Your First Book
# 生成大纲
python scripts/book_writer.py --action outline --prompt "机器学习入门教程"
# 扩写前三章
python scripts/book_writer.py --action expand --book-path "ml_intro_tutorial" --chapters 1,2,3
Core Components
Book Generator (scripts/book_writer.py)
The main generation module, responsible for coordinating the entire book generation process.
Main Features:
- Parse user prompts
- Generate book outlines
- Progressive content expansion
- Manage multimedia elements
Usage:
from scripts.book_writer import BookWriter
writer = BookWriter()
# 生成大纲
outline = writer.generate_outline("深度学习理论与实践")
# 扩写内容
book = writer.expand_book(outline, max_chapters=3)
# 保存书籍
writer.save_book(book, "deep_learning_book")
Content Optimizer (scripts/content_optimizer.py)
Optimize the quality of generated content.
Main Features:
- Grammar and style optimization
- Citation and reference management
- Formula and code validation
- Chart description generation
Material Searcher (scripts/material_searcher.py)
Search for relevant materials from the web.
Main Features:
- Search for images based on content needs
- Find relevant data and statistical information
- Search for code examples
- Obtain cited references
Configuration Instructions
Configuration File (config.yaml)
# API配置
openai:
api_key: ${OPENAI_API_KEY}
model: gpt-4o
max_tokens: 4000
temperature: 0.7
# 搜索API配置
google:
cse_id: ${GOOGLE_CSE_ID}
api_key: ${GOOGLE_API_KEY}
# 书籍生成默认参数
defaults:
max_chapters: 10
max_sections_per_chapter: 5
content_length: "medium" # short, medium, long
include_formulas: true
include_code: true
include_figures: true
include_tables: true
# 存储设置
storage:
output_dir: "generated_books"
temp_dir: "temp_files"
max_storage_gb: 10
Usage Examples
Example 1: Generate a Technical Book Outline
python scripts/book_writer.py --action outline --prompt "Python Web开发实战指南" --output my_web_dev_book
Example 2: Expand a Specified Chapter
python scripts/book_writer.py --action expand --book-path my_web_dev_book --chapters 1,2,3 --include-code true
Example 3: Generate an Academic Work
python scripts/book_writer.py --action full --prompt "量子计算基础理论" --chapters 3 --include-formulas true --citation-style "apa"
Deploy to OpenClaw
Copy the entire book-writer directory into OpenClaw's skills directory to use it.
License
This skill uses the MIT License. See the LICENSE file in the project root directory for details.