Calibre Catalog Read
by @nextaltair
Read-only Calibre catalog lookup (including ID-based read-only lookups like "ID 1021 を確認して") and one-book analysis-comments workflow over a running Content s...
clawhub install calibre-catalog-read📖 About This Skill
name: calibre-catalog-read description: Read-only Calibre catalog lookup (including ID-based read-only lookups like "ID 1021 を確認して") and one-book analysis-comments workflow over a running Content server. Use for any list/search/id viewing even when a specific ID is mentioned. Never for title/authors/tags/series/series_index metadata edits. metadata: {"openclaw":{"requires":{"bins":["node","uv","calibredb","ebook-convert"],"env":["CALIBRE_PASSWORD"]},"optionalEnv":["CALIBRE_USERNAME"],"primaryEnv":"CALIBRE_PASSWORD","dependsOnSkills":["subagent-spawn-command-builder"],"localWrites":["skills/calibre-catalog-read/state/runs.json","skills/calibre-catalog-read/state/calibre_analysis.sqlite","skills/calibre-catalog-read/state/cache/**"],"modifiesRemoteData":["calibre:comments-metadata"]}}
calibre-catalog-read
Use this skill for:
list/search/id)export -> analyze -> cache -> comments HTML apply)Skill selection contract (strict)
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
calibre-metadata-apply and do not execute edit paths here.Do NOT use this skill for:
calibre-metadata-applyRouting: ID in request ≠ edit intent
calibre-metadata-apply へのルーティングは明示的な編集動詞がある場合のみ (修正/編集/変更/直す/fix/edit/update/change)Requirements
calibredb available on PATH in the runtime where scripts are executed.ebook-convert available for text extraction.subagent-spawn-command-builder installed (for spawn payload generation).--with-library format:http://HOST:PORT/#LIBRARY_ID
- If LIBRARY_ID is unknown, use #- once to list available IDs on the server.
HOST:PORT.--with-library can be omitted only when one of these is configured:CALIBRE_WITH_LIBRARY or CALIBRE_LIBRARY_URL or CALIBRE_CONTENT_SERVER_URL
- optional library id completion: CALIBRE_LIBRARY_ID
--with-library URL.CALIBRE_SERVER_HOSTS=host1,host2,...
- Script auto-tries candidates, including WSL host-side nameserver from /etc/resolv.conf.
/home/altair/.openclaw/.env
- CALIBRE_USERNAME=
- CALIBRE_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 explicitly.Commands
List books (JSON):
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
Search books (JSON):
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:"中公文庫"'
Get one book by id (JSON):
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
Run one-book pipeline (analyze + comments HTML apply + cache):
uv run python skills/calibre-catalog-read/scripts/run_analysis_pipeline.py \
--with-library "http://192.168.11.20:8080/#Calibreライブラリ" \
--password-env CALIBRE_PASSWORD \
--book-id 3 --lang ja
Cache DB
Initialize DB schema:
uv run python skills/calibre-catalog-read/scripts/analysis_db.py init \
--db skills/calibre-catalog-read/state/calibre_analysis.sqlite
Check current hash state:
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
Main vs Subagent responsibility (strict split)
Use this split to avoid long blocking turns on chat listeners.
Main agent (fast control plane)
book_id.model, thinking, runTimeoutSeconds.Subagent (heavy analysis plane)
Never do in main when avoidable
Turn policy
Subagent pre-flight (required)
Before first subagent run in a session, confirm once:
modelthinking (low/medium/high)runTimeoutSecondsDo 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.
references/subagent-analysis.prompt.mdreferences/subagent-input.schema.jsonreferences/subagent-analysis.schema.jsonscripts/prepare_subagent_input.mjsRules:
uv run python.references/subagent-analysis.prompt.md) as mandatory base; do not send ad-hoc relaxed read instructions.reason: low_text_requires_confirmation with prompt_en text.
node .../calibredb_read.mjs instead of direct calibredb calls.calibre-server from this skill.Connection bootstrap (mandatory)
--with-library first.list/search/id) without explicit --with-library and use saved defaults..env and resolve CALIBRE_WITH_LIBRARY / CALIBRE_CONTENT_SERVER_URL.
missing --with-library / unable to resolve usable --with-library).Language policy
lang input.Orchestration note (important)
run_analysis_pipeline.py 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 --title "" --lang ja \
--text-path /tmp/book_.txt --out-dir /tmp/calibre_subagent_
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).
4. 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)
subagent-spawn-command-builder (--profile calibre-read + run-specific --task).sessions_spawn using that payload.runId) via run_state.mjs upsert.Turn B: completion only (separate later turn)
Trigger: completion announce/event for that run.scripts/handle_completion.mjs (get -> apply -> remove, and fail on error).
runId is missing, handler returns stale_or_duplicate and does nothing.Hard rule:
Run state management (single-file, required)
For one-book-at-a-time operation, keep a single JSON state file:
skills/calibre-catalog-read/state/runs.jsonUse 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.
3. On completion announce, load record by runId and run apply.
4. On successful apply, delete that record immediately.
5. On failure, set status: "failed" + error and keep record for retry/debug.
Rules:
Use helper scripts (avoid ad-hoc env var mistakes):
# Turn A: register running task
node skills/calibre-catalog-read/scripts/run_state.mjs upsert \
--state skills/calibre-catalog-read/state/runs.json \
--run-id --book-id --title ""Turn B: completion handler (preferred)
node skills/calibre-catalog-read/scripts/handle_completion.mjs \
--state skills/calibre-catalog-read/state/runs.json \
--run-id \
--analysis-json /tmp/calibre_/analysis.json \
--with-library "http://HOST:PORT/#LIBRARY_ID" \
--password-env CALIBRE_PASSWORD --lang ja