calibre-catalog-read
Use this skill for:
- - Read-only catalog lookup (
list/search/id) - ID-based read-only lookups: "ID 1021 を確認して", "1021番の詳細", "show me book 1021", "ID 1021 の情報を見せて"
- One-book AI reading workflow (
export -> analyze -> cache -> comments HTML apply) - Natural conversational book-reference turns where a lightweight read-only lookup would improve the reply
- Examples: the user mentions a book that may exist in the library, suggests "if you're interested, read it", asks whether it is in the library, or continues a reading-related conversation without using explicit command wording
Skill selection contract (strict)
- - This skill is read-only for catalog lookup + analysis workflow.
- This skill may also be selected from natural conversation when the likely user need is a lightweight library check or book lookup, even if the user does not use explicit command-style wording.
- In such conversational cases, prefer the smallest useful action first:
- first choice:
id/search/list style read-only lookup
- do not jump directly into heavy analysis unless the user clearly asks for it
- do not treat casual book talk as metadata-edit intent
- - If user intent includes metadata edit/fix/update (title/authors/series/series_index/tags/publisher/pubdate/languages),
route to
calibre-metadata-apply and do not execute edit paths here.
Do NOT use this skill for:
- - Editing title/authors/series/series_index/tags/publisher/pubdate/languages
- Any user request that says "metadata edit", "title fix", "ID指定で編集"
- Heavy one-book analysis when the user only made a casual conversational reference and did not ask for reading/analysis
- Those must use INLINECODE4
Routing: ID in request ≠ edit intent
- - ID が含まれるリクエストはデフォルトで読み取り専用 → このスキル
- INLINECODE5 へのルーティングは明示的な編集動詞がある場合のみ (修正/編集/変更/直す/fix/edit/update/change)
- 確認/見せて/教えて/詳細/check/show/view は読み取り → このスキル
Requirements
- -
calibredb available on PATH in the runtime where scripts are executed. - INLINECODE7 available for text extraction.
- INLINECODE8 installed (for spawn payload generation).
- Reachable Calibre Content server URL in
--with-library format:
-
http://HOST:PORT/#LIBRARY_ID
- If
LIBRARY_ID is unknown, use
#- once to list available IDs on the server.
- - Do not assume localhost/127.0.0.1; always pass explicit reachable
HOST:PORT. - INLINECODE14 can be omitted only when one of these is configured:
- env:
CALIBRE_WITH_LIBRARY or
CALIBRE_LIBRARY_URL or
CALIBRE_CONTENT_SERVER_URL
- optional library id completion:
CALIBRE_LIBRARY_ID
- - Read the "Calibre Content Server" section of TOOLS.md for the correct
--with-library URL. - Host failover (IP change resilience):
- Optional env:
CALIBRE_SERVER_HOSTS=host1,host2,...
- Script auto-tries candidates, including WSL host-side
nameserver from
/etc/resolv.conf.
- Preferred: set in
/home/altair/.openclaw/.env
-
CALIBRE_USERNAME=<user>
-
CALIBRE_PASSWORD=<password>
- Auth scheme policy for this workflow:
- Non-SSL deployment assumes
Digest authentication.
- Do not pass auth mode arguments such as
--auth-mode /
--auth-scheme.
- Then pass only
--password-env CALIBRE_PASSWORD (username auto-loads from env)
- You can still override with
--username <user> explicitly.
Commands
List books (JSON):
CODEBLOCK0
Search books (JSON):
CODEBLOCK1
Get one book by id (JSON):
CODEBLOCK2
Run one-book pipeline (analyze + comments HTML apply + cache):
CODEBLOCK3
Cache DB
Initialize DB schema:
CODEBLOCK4
Check current hash state:
CODEBLOCK5
Main vs Subagent responsibility (strict split)
Use this split to avoid long blocking turns on chat listeners.
Main agent (fast control plane)
- - Validate user intent and target
book_id. - Confirm subagent runtime knobs:
model, thinking, runTimeoutSeconds. - Start subagent and return a short progress reply quickly.
- After subagent result arrives, run DB upsert + Calibre apply.
- Report final result to user.
Subagent (heavy analysis plane)
- - Read extracted source payload.
- Generate analysis JSON strictly by schema.
- Do not run metadata apply or user-facing channel actions.
Never do in main when avoidable
- - Long-form content analysis generation.
- Multi-step heavy reasoning over full excerpts.
Turn policy
- - One book per run.
- Prefer asynchronous flow: quick ack first, final result after analysis.
- If analysis is unavailable, either ask user or use fallback only when explicitly acceptable.
Subagent pre-flight (required)
Before first subagent run in a session, confirm once:
- - INLINECODE34
- INLINECODE35 (
low/medium/high) - INLINECODE39
Do not ask on every run. Reuse the confirmed settings for subsequent books in the same session unless the user asks to change them.
Subagent support (model-agnostic)
Book-reading analysis is a heavy task. Use a subagent with a lightweight model for analysis generation, then return results to main agent for cache/apply steps.
- - Prompt template: INLINECODE40
- Input schema: INLINECODE41
- Output schema: INLINECODE42
- Input preparation helper: INLINECODE43
- Splits extracted text into multiple files to avoid read-tool single-line size issues.
Rules:
- - Use subagent only for heavy analysis generation; keep main agent lightweight and non-blocking.
- In this environment, Python commands must use
uv run python. - Use the strict prompt template (
references/subagent-analysis.prompt.md) as mandatory base; do not send ad-hoc relaxed read instructions. - Keep final DB upsert and Calibre metadata apply in main agent.
- Process one book per run.
- Confirm model/thinking/timeout once per session, then reuse; do not hardcode provider-specific model IDs in the skill.
- Configure callback/announce behavior and rate-limit fallbacks using OpenClaw default model/subagent/fallback settings (not hardcoded in this skill).
- Exclude manga/comic-centric books from this text pipeline (skip when title/tags indicate manga/comic).
- If extracted text is too short, stop and ask user for confirmation before continuing.
- The pipeline returns
reason: low_text_requires_confirmation with
prompt_en text.
- - For read operations in agent/chat, prefer
node .../calibredb_read.mjs instead of direct calibredb calls. - Never run
calibre-server from this skill.
- This workflow always connects to an already-running Calibre Content server.
Connection bootstrap (mandatory)
- - Do not ask the user for
--with-library first. - First, run read commands (
list/search/id) without explicit --with-library and use saved defaults.
- Scripts auto-load
.env and resolve
CALIBRE_WITH_LIBRARY /
CALIBRE_CONTENT_SERVER_URL.
- - This same rule applies to conversational lookup turns: try the lightweight read-only check first before asking the user for connection details.
- Ask user for URL only if resolution fails (
missing --with-library / unable to resolve usable --with-library).
Language policy
- - Do not hardcode user-language prose in pipeline scripts.
- Generate user-visible analysis text from subagent output, with language controlled by user-selected settings and
lang input. - Fallback local analysis in scripts is generic/minimal; preferred path is subagent output following the prompt template.
Orchestration note (important)
INLINECODE60 is a local script and does not call OpenClaw tools by itself.
Subagent execution must be orchestrated by the agent layer using sessions_spawn.
Required runtime sequence:
- 1. Main agent prepares
subagent_input.json + chunked source_files from extracted text.
- Use:
node skills/calibre-catalog-read/scripts/prepare_subagent_input.mjs \
--book-id <id> --title "<title>" --lang ja \
--text-path /tmp/book_<id>.txt --out-dir /tmp/calibre_subagent_<id>
- 2. Main agent uses the shared builder skill
subagent-spawn-command-builder to generate the sessions_spawn payload, then calls sessions_spawn.
- Build with profile
calibre-read and run-specific analysis task text.
- Use the generated JSON as-is (or merge minimal run-specific fields such as label/task text).
- 3. Subagent reads all
source_files and returns analysis JSON (schema-conformant). - Main agent passes that file via
--analysis-json to run_analysis_pipeline.py for DB/apply.
If step 2 is skipped and --analysis-json is not provided, the pipeline returns updated: false, analysis_mode: fallback without writing to DB or Calibre comments. Pass --allow-fallback to force-persist local analysis (testing only).
Chat execution model (required, strict)
For Discord/chat, always run as two separate turns.
Turn A: start only (must be fast)
- - Select one target book.
- Build spawn payload with
subagent-spawn-command-builder (--profile calibre-read + run-specific --task). - Call
sessions_spawn using that payload. - Record run state (
runId) via run_state.mjs upsert. - Reply to user with selected title + "running in background".
- Stop turn here.
Turn B: completion only (separate later turn)
Trigger: completion announce/event for that run.
- - Run one command only (completion handler):
-
scripts/handle_completion.mjs (
get -> apply -> remove, and
fail on error).
- - If
runId is missing, handler returns stale_or_duplicate and does nothing. - Send completion/failure reply from handler result.
Hard rule:
- - Never poll/wait/apply in Turn A.
- Never keep a chat listener turn open waiting for subagent completion.
Run state management (single-file, required)
For one-book-at-a-time operation, keep a single JSON state file:
Use runId as the primary key (subagent execution id).
Lifecycle:
- 1. On spawn acceptance, upsert one record:
-
runId,
book_id,
title,
status: "running",
started_at
- 2. Do not wait/poll inside the same chat turn.
- On completion announce, load record by
runId and run apply. - On successful apply, delete that record immediately.
- On failure, set
status: "failed" + error and keep record for retry/debug.
Rules:
- - Keep this file small and operational (active/failed records only).
- Ignore duplicate completion events when record is already removed.
- If record is missing at completion time, report as stale/unknown run and do not apply blindly.
Use helper scripts (avoid ad-hoc env var mistakes):
CODEBLOCK7
calibre-catalog-read
使用此技能的场景:
- - 只读目录查询(list/search/id)
- 基于ID的只读查询:ID 1021 を確認して、1021番の詳細、show me book 1021、ID 1021 の情報を見せて
- 单本书AI阅读工作流(export -> analyze -> cache -> comments HTML apply)
- 自然对话式书籍引用场景,轻量级只读查询可提升回复质量
- 示例:用户提及可能存在于图书馆中的书籍,建议如果你感兴趣,可以读一读,询问该书是否在图书馆中,或继续与阅读相关的对话而未使用明确的命令措辞
技能选择契约(严格)
- - 此技能仅用于目录查询+分析工作流的只读操作。
- 即使未使用明确的命令式措辞,当用户需求可能为轻量级图书馆查询或书籍查找时,也可从自然对话中选择此技能。
- 在此类对话场景中,优先执行最小的有用操作:
- 首选:id/search/list 风格的只读查询
- 除非用户明确要求,否则不要直接跳转到繁重的分析
- 不要将随意的书籍讨论视为元数据编辑意图
- - 如果用户意图包含元数据编辑/修复/更新(标题/作者/丛书/丛书索引/标签/出版商/出版日期/语言),
则路由至 calibre-metadata-apply,且不在此处执行编辑路径。
请勿将此技能用于:
- - 编辑标题/作者/丛书/丛书索引/标签/出版商/出版日期/语言
- 任何包含metadata edit、title fix、ID指定で編集的用户请求
- 当用户仅进行随意的对话引用且未要求阅读/分析时的单本书繁重分析
- 这些必须使用 calibre-metadata-apply
路由规则:请求中包含ID ≠ 编辑意图
- - 包含ID的请求默认为只读 → 此技能
- 路由至 calibre-metadata-apply 仅在有明确编辑动词时(修正/編集/変更/直す/fix/edit/update/change)
- 确认/見せて/教えて/詳細/check/show/view 为读取 → 此技能
要求
- - 脚本执行环境中 calibredb 需在PATH中可用。
- 文本提取需要 ebook-convert。
- 已安装 subagent-spawn-command-builder(用于生成spawn负载)。
- 可访问的Calibre内容服务器URL,格式为 --with-library:
- http://HOST:PORT/#LIBRARY_ID
- 如果 LIBRARY_ID 未知,使用 #- 一次列出服务器上可用的ID。
- - 不要假定localhost/127.0.0.1;始终传递明确可访问的 HOST:PORT。
- 仅在配置了以下任一条件时,可省略 --with-library:
- 环境变量:CALIBRE
WITHLIBRARY 或 CALIBRE
LIBRARYURL 或 CALIBRE
CONTENTSERVER_URL
- 可选的库ID补全:CALIBRE
LIBRARYID
- - 阅读TOOLS.md中的Calibre Content Server部分,了解正确的 --with-library URL。
- 主机故障转移(IP变更弹性):
- 可选环境变量:CALIBRE
SERVERHOSTS=host1,host2,...
- 脚本自动尝试候选主机,包括来自 /etc/resolv.conf 的WSL主机端 nameserver。
- 首选:在 /home/altair/.openclaw/.env 中设置
- CALIBRE_USERNAME=
- CALIBRE_PASSWORD=
- 此工作流的认证方案策略:
- 非SSL部署假定使用 Digest 认证。
- 不要传递 --auth-mode / --auth-scheme 等认证模式参数。
- 然后仅传递 --password-env CALIBRE_PASSWORD(用户名自动从环境变量加载)
- 仍可显式使用 --username 覆盖。
命令
列出书籍(JSON):
bash
node skills/calibre-catalog-read/scripts/calibredb_read.mjs list \
--with-library http://192.168.11.20:8080/#Calibreライブラリ \
--password-env CALIBRE_PASSWORD \
--limit 50
搜索书籍(JSON):
bash
node skills/calibre-catalog-read/scripts/calibredb_read.mjs search \
--with-library http://192.168.11.20:8080/#Calibreライブラリ \
--password-env CALIBRE_PASSWORD \
--query series:中公文庫
按ID获取单本书(JSON):
bash
node skills/calibre-catalog-read/scripts/calibredb_read.mjs id \
--with-library http://192.168.11.20:8080/#Calibreライブラリ \
--password-env CALIBRE_PASSWORD \
--book-id 3
运行单本书流水线(分析 + comments HTML应用 + 缓存):
bash
uv run python skills/calibre-catalog-read/scripts/runanalysispipeline.py \
--with-library http://192.168.11.20:8080/#Calibreライブラリ \
--password-env CALIBRE_PASSWORD \
--book-id 3 --lang ja
缓存数据库
初始化数据库模式:
bash
uv run python skills/calibre-catalog-read/scripts/analysis_db.py init \
--db skills/calibre-catalog-read/state/calibre_analysis.sqlite
检查当前哈希状态:
bash
uv run python skills/calibre-catalog-read/scripts/analysis_db.py status \
--db skills/calibre-catalog-read/state/calibre_analysis.sqlite \
--book-id 3 --format EPUB
主代理与子代理职责(严格分离)
使用此分离方式避免聊天监听器上的长时间阻塞轮次。
主代理(快速控制平面)
- - 验证用户意图和目标 book_id。
- 确认子代理运行时参数:model、thinking、runTimeoutSeconds。
- 启动子代理并快速返回简短进度回复。
- 子代理结果到达后,执行数据库更新插入 + Calibre应用。
- 向用户报告最终结果。
子代理(繁重分析平面)
- - 读取提取的源负载。
- 严格按照模式生成分析JSON。
- 不执行元数据应用或面向用户的通道操作。
主代理应避免的操作
- - 长格式内容分析生成。
- 对完整摘录进行多步繁重推理。
轮次策略
- - 每次运行一本书。
- 优先异步流程:先快速确认,分析后返回最终结果。
- 如果分析不可用,询问用户或仅在明确可接受时使用回退方案。
子代理预检(必需)
在会话中首次运行子代理前,确认一次:
- - model
- thinking(low/medium/high)
- runTimeoutSeconds
不要在每次运行时询问。除非用户要求更改,否则在同一会话中对后续书籍复用已确认的设置。
子代理支持(模型无关)
书籍阅读分析是一项繁重任务。使用轻量级模型的子代理进行分析生成,然后将结果返回给主代理进行缓存/应用步骤。
- - 提示模板:references/subagent-analysis.prompt.md
- 输入模式:references/subagent-input.schema.json
- 输出模式:references/subagent-analysis.schema.json
- 输入准备辅助脚本:scripts/preparesubagentinput.mjs
- 将提取的文本分割成多个文件,避免读取工具的单行大小问题。
规则:
- - 仅将子代理用于繁重分析生成;保持主代理轻量且非阻塞。
- 在此环境中,Python命令必须使用 uv run python。
- 使用严格的提示模板(references/subagent-analysis.prompt.md)作为强制性基础;不要发送临时宽松的读取指令。
- 将最终数据库更新插入和Calibre元数据应用保留在主代理中。
- 每次运行处理一本书。
- 每个会话确认一次model/thinking/timeout,然后复用;不要在技能中硬编码特定提供商的模型ID。
- 使用OpenClaw默认模型/子代理/回退设置(而非在此技能中硬编码)配置回调/通知行为和速率限制回退。
- 从此文本流水线中排除以漫画/连环画为中心的书籍(当标题/标签指示为漫画/连环画时跳过)。
- 如果提取的文本过短,停止并询问用户确认后再继续。
- 流水线返回 reason: lowtextrequires_confirmation 并附带 prompt