Multi Search Engine
一个面向 Research 场景的 Agent 技能。原始说明:Multi search engine integration with 16 engines (7 CN + 9 Global). Supports advanced search operators, time filters, site search, privacy engines, and Wolfra...
name: make-textbook
description: "Research a subject via web search and produce a comprehensive, graduate-level university textbook as a professionally formatted PDF with table of contents, citations, worked examples, misconceptions, data tables, glossary, and references."
Activation: "make a textbook", "write a textbook", "generate a textbook",
"create a university textbook", "build a textbook", "write a comprehensive textbook",
"graduate-level textbook", "academic textbook", "comprehensive learning material".
Build a comprehensive graduate-level university textbook on any subject, complete
with chapter outlines, worked examples, misconceptions, data tables, citations,
glossary, and an index. Output: a professionally formatted PDF (~40-100 KB per book).
Invoke when the user asks to "make a textbook," "write a textbook," "create a
comprehensive learning resource" on any topic — from quantum mechanics to local
AI agent infrastructure.
SUBJECT → OUTLINE → CHAPTER RESEARCH → CONTENT DRAFTING → QA → PDF GENERATION → DELIVER
Part I / Section heading
Chapter 1. [Title] — 1-2 sentence description
Chapter 2. [Title] — ...
Search strategy: Use batch_web_search for 8-10 concurrent searches per chapter.
Combine broad searches with specific sub-topic queries.
Each chapter follows this structure:
CHAPTER N. [Title]
|- N.0 Introduction (overview, prerequisites)
|- N.1 [Core concept] — definitions, explanation, worked examples
|- N.2 [Next concept] — ...
|- [MISCONCEPTION] Common Misconceptions (callout box)
|- N.3 Data Table (comparison or structured data)
\- References (IEEE numbered)
Every chapter must include:
After drafting all chapters:
The PDF generator is at scripts/textbook_generator.py. It reads the JSON content
file and produces a professional academic PDF with:
Run it:
python3 scripts/textbook_generator.py textbook_content.json output/book.pdf
The textbook_content.json file must conform to this schema:
{
"title": "Topic Title",
"subtitle": "Optional Subtitle",
"date": "May 2026",
"preface": "How to use this book...",
"chapters": [
{
"number": 1,
"title": "Chapter Title",
"intro": "Chapter banner subtitle (optional)",
"sections": [
{"type": "heading", "level": 1, "content": "Major Heading"},
{"type": "heading", "level": 2, "content": "Sub-heading"},
{"type": "text", "content": "Body text with **bold**, *italic*, `code` markup."},
{"type": "example", "title": "Example 1.1", "problem": "...", "solution": "..."},
{"type": "misconception", "title": "Misconception: ...", "explanation": "..."},
{"type": "table", "title": "My Data Table", "header": true,
"data": [["Col1","Col2","Col3"],["A","B","C"],["D","E","F"]]},
{"type": "divider", "content": ""}
],
"summary": "- Key takeaway 1\n- Key takeaway 2"
}
],
"glossary": [
{"term": "Term", "definition": "Definition sentence."}
],
"full_references": [
"[1] A. Author, Title, Source, Year."
]
}
| type | Fields | Notes |
|----------------|-------------------------------------------------------------|-------|
| heading | level (1/2/3), content | Level 1 adds a gold rule above |
| text | content | Body text with markup |
| example | title, problem, solution | Blue callout box |
| misconception| title, explanation | Orange callout box |
| table | data (array of arrays — row 0 is headers), header (bool, default: true) | Use data, NOT headers+rows |
| divider | none | Full-width gold rule |
text content| Syntax | Result |
|---------------|---------------------------------|
| **text** | Bold |
| *text* | Italic |
| __text__ | Underline |
| ` code | Courier / monospace |~~text~~` | Strikethrough |
|
The generator is resilient to malformed input:
data in a table section → table skipped silently, no crashThe generator's make_table() expects this exact format:
{"type": "table", "title": "My Table", "header": true,
"data": [["Column A", "Column B"], ["Value 1", "Value 2"]]}
Common mistake: using separate headers + rows fields. That format is not read by the generator — tables will silently produce empty output.
If your source data has separate header/row arrays, combine them:
section["data"] = [section["headers"]] + section["rows"]
section["header"] = True
del section["headers"]; del section["rows"]
The generator reads data['title'] from the top-level JSON key, not from a nested metadata object. Always include these at the root level:
{
"title": "My Actual Title",
"subtitle": "My Subtitle",
"date": "May 2026",
"metadata": { ... },
"chapters": [ ... ]
}
If your source data has title only inside metadata, copy it to the root before running the generator.
Give every section an explicit "type": "text" field. Sections without a type field fall through to a default, but explicit is more reliable.
Before delivering, always verify:
Quick Python verification:
from textbook_generator import build_styles, make_table
styles = build_styles()
for chapter in data['chapters']:
for s in chapter['sections']:
if s.get('type') == 'table' and 'data' in s:
result = make_table(s, styles, 16.0)
tbl = result[0]
print(f"Table '{s['title']}': {tbl._nrows} rows x {tbl._ncols} cols")
When producing documents (PDF, DOCX, or any format), treat readability as a requirement, not an afterthought.
Readability rules for every document:
| Rule | Why it matters |
|------|---------------|
| Use tables for structured comparisons | Tables are 5x easier to scan than columns of bullet points |
| Convert flat bullet lists to visual rows | E.g., "Feature: X / Y: Z" becomes a grid row, not a line of bullets |
| Use infographics for multi-category data | When comparing 5+ items across 3+ attributes, always use a table |
| Color-code section headers | Each chapter/section gets a distinct colored header band |
| Group by category | Keep related items together — no item should appear alone |
| Use type: "table" for ALL structured data | Never use bullet lists for data that has a natural row/column structure |
| Prefer prose paragraphs over bullet fragments | Each section should read as a short paragraph, not a list of fragments |
| Add URL links inline | Every source should be clickable — not pasted as a raw string |
Examples of what to fix in bad output:
For DOCX output specifically:
When in doubt: ask yourself "can I scan this in 10 seconds and find what I need?" If the answer is no, restructure it as a table or heading group.
Comparison content (e.g. "University X: feature Y") reads far better as a formatted table than as a bullet list. When a text section lists items in the pattern "Name | Description | Category", convert it to a table:
{"type": "table", "title": "...", "header": true,
"data": [["Name","Description","Category"],
["Item 1","Desc 1","Cat A"],
["Item 2","Desc 2","Cat B"]]}
textbook_generator.py is pure Python 3, no external API callscanvas.showPage() on page 1 to advance to page 2 for TOCmake_example, make_table, etc.) return a list offlowables; empty list means "skip gracefully" — never raise from a renderer
textbook_generator.py for detailed per-function docs