book-mirror
它能做什么
这项技能把一本书转化为个人化的分析,包括每章的摘要,以及它如何与你的生活相联系。适合希望把所读内容应用到生活中的读者。
适用场景
- ✓当你想对一本 EPUB 或 PDF 格式的书进行逐章分析时。
- ✓当你希望把每一章与你知识库中的情境和人物联系起来时。
- ✓当你想要一个个人化的阅读伙伴,而不只是平淡的书籍摘要时。
技能链接
https://github.com/garrytan/gbrain/blob/master/plugin/skills/book-mirror/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请逐章分析这本书,并把每一章与我自己生活中正在发生的事情联系起来。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会阅读这本书,详细总结每一章。然后它会利用你的知识库笔记,指出这些观点与你自身处境吻合的地方,而决定权留给你。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
book-mirror — Personalized Chapter-by-Chapter Book Analysis
Convention: see _brain-filing-rules.md for the sanctioned
media/<format>/<slug>exception this skill files under.Convention: see conventions/quality.md for citation rules, back-link enforcement, and output quality bars.
Convention: see conventions/brain-first.md for the lookup chain (brain → search → external) the context-gathering phase follows.
What this does
Given a book (EPUB or PDF), produce a brain page where every chapter is
summarized in detail on one side ("The Chapter") and mirrored back to the
reader's actual life on the other ("The Mirror"), using their own words,
situations, people, and patterns from the brain. Output is a brain page at
media/books/<slug>-personalized.md.
This is NOT a generic book summary. The mirror is the value: it makes the book read like a smart friend who happens to know the reader's life deeply is pointing things out in the margins. The mirror's job is recognition — "that's exactly me" — and then getting out of the way. If the user wants a flat summary instead, route them to a different skill.
Trust contract (read this before running)
book-mirror runs as a CLI command (gbrain book-mirror), NOT as a pure
markdown skill that the agent dispatches via tools. The CLI is the trusted
runtime; the skill is the orchestration prose around it.
What this means for the agent:
- The CLI submits N read-only subagent jobs (one per chapter). Each subagent
has
allowed_tools: ['get_page', 'search']only. They CANNOT call put_page or any mutating op. They produce markdown analysis via their final message. - The CLI reads each child's
job.result, assembles the final page, and writes it via a single operator-trustput_page. - This means untrusted EPUB/PDF content cannot prompt-inject any
people/*page. The trust narrowing happens at the tool allowlist, not at the slug-prefix layer.
The pipeline
1. ACQUIRE → User has the EPUB/PDF locally (manual; book-acquisition is
not currently shipped — see "Acquiring the book" below).
2. EXTRACT → Pull chapter text from EPUB/PDF into one .txt per chapter.
3. CONTEXT → Gather everything the brain knows about the reader.
4. ANALYZE → `gbrain book-mirror` fans out N read-only subagents.
5. ASSEMBLE → CLI reads each child result and writes one put_page.
6. PDF → Optional: render via skills/brain-pdf for delivery.
1. Acquiring the book
book-acquisition (legal-grey-area downloader) was deliberately not shipped in this skill wave. The user drops the EPUB/PDF manually. Common paths the user might use:
# User-supplied path
ls path/to/book.epub
ls path/to/book.pdf
# Or already in the brain repo (recommended for tracking)
ls $BRAIN_DIR/media/books/
Resolve $BRAIN_DIR from the gbrain config (gbrain config get sync.repo_path)
or accept it from the user.
2. Text extraction
Goal: one .txt file per chapter under a temp directory. The agent has
shell + python access; the CLI is downstream of this and takes the
extracted directory as input.
EPUB
SLUG="this-book" # kebab-case
WORK="$(mktemp -d)/$SLUG"
mkdir -p "$WORK/chapters"
unzip -o path/to/book.epub -d "$WORK/unpacked"
# Find content files (XHTML/HTML), sorted (chapter order = sort order)
find "$WORK/unpacked" -name "*.xhtml" -o -name "*.html" | sort > "$WORK/files.txt"
# Strip HTML to text per chapter
python3 - <<'PY'
from bs4 import BeautifulSoup
import os, sys
work = os.environ['WORK']
files = open(f'{work}/files.txt').read().splitlines()
for i, path in enumerate(files, 1):
html = open(path, encoding='utf-8', errors='replace').read()
text = BeautifulSoup(html, 'html.parser').get_text('\n')
text = '\n'.join(line.strip() for line in text.splitlines() if line.strip())
with open(f'{work}/chapters/{i:02d}.txt', 'w') as f:
f.write(text)
PY
If bs4 is missing: pip3 install beautifulsoup4 lxml.
Inspect the chapter files to identify which are real chapters vs front
matter (TOC, copyright, acknowledgments). Often the EPUB ships one file
per chapter; sometimes multiple chapters per file. Use
head -5 "$WORK/chapters/"*.txt to spot-check.
pdftotext -layout path/to/book.pdf "$WORK/full.txt"
Then split by chapter heading (look for "Chapter N", "CH
常见问题
这只是普通的书籍摘要吗?
不是。个人联系是最主要的价值,因此每一章都与你自己的生活相关联。
它会告诉我该怎么做吗?
不会。它只指出相似之处,由你决定如何应对。
分析保存在哪里?
它会作为一个页面保存在你知识库的书籍部分下。
详情
作者的原始描述
Take any book (EPUB/PDF), produce a personalized chapter-by-chapter analysis. Each chapter is preserved in detail (The Chapter) and mirrored back to the reader's actual life (The Mirror) using brain context. The mirror observes and resonates — a friend pointing out parallels, NOT a consultant rearranging the reader's life, NOT a therapist assigning homework. The reader decides what to do about it. Layout is a top-aligned HTML table or stacked sections, never a bare markdown pipe table (pipe tables center-misalign uneven columns). Output is a single brain page at media/books/<slug>-personalized
repo: garrytan/gbrain
热度
- GitHub 星标
- 31k
- 排名
- #9288
- 许可证
- MIT
- 更新时间
- 2026/11/2
评论
- …