Communitygithub.com

cli-anything-calibre

一個狀態化的 CLI 工具,用於 Calibre 電子書管理,為 AI 代理和腳本提供乾淨、結構化的介面來操作圖書館、編輯元數據和轉換格式。

cli-anything-calibre 是什麼?

cli-anything-calibre 是一個專為 AI 代理和開發者設計的命令列工具,用於管理 Calibre 電子書庫。它包裝了 Calibre 的原生工具(如 calibredb、ebook-convert 和 ebook-meta),提供一個統一且狀態化的介面。這個工具支援圖書館操作(例如連接、檢查完整性)、書籍管理(列出、搜尋、新增、刪除)、元數據編輯(取得、設定、嵌入)以及格式轉換(EPUB 轉 MOBI 等)。它還能將每章導出為單獨的 PDF。主要特點包括互動式 REPL 模式、人類可讀的輸出以及供代理程式使用的 JSON 輸出(透過 --json 旗標)。狀態管理會話會跨工作階段持久保存(例如活躍的圖書館路徑),並支援透過 CALIBRE_LIBRARY 環境變數進行覆蓋。它相容於 Linux 和 macOS,並要求系統上已安裝 Calibre。對於開發者而言,此工具簡化了電子書自動化工作流程,從批次元數據編輯到格式轉換,並可輕鬆整合到 CI/CD 管道或 AI 代理。

相容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/HKUDS/CLI-Anything/tree/main/skills/cli-anything-calibre

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

cli-anything-calibre 是做什麼的?

一個狀態化的 CLI 工具,用於 Calibre 電子書管理。包裝了真實的 Calibre 工具(calibredb、ebook-convert、ebook-meta),為 AI 代理和腳本提供乾淨、結構化的介面來處理圖書館操作、元數據編輯和格式轉換。

安裝

此 CLI 是作為 cli-anything-calibre 套件的一部分安裝的:

pip install git+https://github.com/HKUDS/CLI-Anything.git#subdirectory=calibre/agent-harness

先決條件:

  • Python 3.10+
  • 系統上必須安裝 Calibre (硬性依賴)
# Debian/Ubuntu
sudo apt-get install calibre

# macOS
brew install --cask calibre

# 確認工具在 PATH 中
which calibredb
which ebook-convert
which ebook-meta

使用方法

基本命令

# 顯示幫助
cli-anything-calibre --help

# 啟動互動式 REPL 模式
cli-anything-calibre

# 連接到 Calibre 圖書館
cli-anything-calibre library connect ~/Calibre\ Library

# 使用 JSON 輸出執行(供代理使用)
cli-anything-calibre --json books list

REPL 模式

當不帶子命令呼叫時,CLI 會進入互動式 REPL 會話:

cli-anything-calibre
# 使用 Tab 補全和歷史記錄互動地輸入命令
# 使用 'help' 檢視可用命令
# 使用 'quit' 或 'exit' 離開

命令群組

Library

圖書館管理命令。

命令說明
connect <path>設定活躍圖書館路徑
info顯示圖書館統計資訊(書籍數量、格式、資料庫大小)
check使用 calibredb check_library 驗證圖書館完整性

Books

書籍操作(包裝 calibredb)。

命令說明
list列出書籍,支援過濾和排序
search <query>使用 Calibre 查詢語言搜尋
add <files>新增書籍檔案到圖書館
remove <ids>移除書籍(移至回收筒或永久刪除)
show <id>顯示書籍的完整元數據
export <ids>將書籍匯出到目錄
export-chapters <id>將每章導出為單獨的 PDF(需要 EPUB 格式)

Meta

元數據編輯(包裝 calibredb set_metadata)。

命令說明
get <id> [field]取得元數據(全部或特定欄位)
set <id> <field> <value>設定元數據欄位
embed <ids>將元數據嵌入到書籍檔案中

Formats

格式管理(包裝 calibredb + ebook-convert)。

命令說明
list <id>列出書籍的可用格式
add <id> <file>為書籍新增格式
remove <id> <fmt>從書籍移除格式
convert <id> <input_fmt> <output_fmt>轉換書籍格式

Custom

自訂欄位(包裝 calibredb)。

命令說明
list列出所有自訂欄位
add <label> <name> <type>建立自訂欄位
remove <label>刪除自訂欄位
set <id> <label> <value>設定自訂欄位值

Catalog

目錄生成。

命令說明
catalog <output>生成圖書館目錄(EPUB、CSV 或 OPDS)

範例

連接並列出書籍

連接到你的 Calibre 圖書館並列出書籍。

cli-anything-calibre library connect ~/Calibre\ Library
cli-anything-calibre books list
# 或使用 JSON 輸出
cli-anything-calibre --json books list --search "author:asimov"

搜尋和過濾

使用 Calibre 查詢語言搜尋書籍。

cli-anything-calibre books search "title:Foundation"
cli-anything-calibre books search "author:asimov and tags:scifi"
cli-anything-calibre books search "rating:>3"

元數據編輯

設定書籍的元數據欄位。

cli-anything-calibre meta set 42 title "新標題"
cli-anything-calibre meta set 42 series "Foundation"
cli-anything-calibre meta set 42 series_index 1
cli-anything-calibre meta set 42 tags "scifi,classic"
cli-anything-calibre meta set 42 rating 5

格式轉換

在電子書格式之間轉換。

cli-anything-calibre formats convert 42 EPUB MOBI
cli-anything-calibre formats convert 42 EPUB PDF --output /tmp/book.pdf

將章節匯出為 PDF

將 EPUB 的每章節匯出為單獨的 PDF 檔案。

cli-anything-calibre books export-chapters 42 --to-dir ./pdfs
cli-anything-calibre books export-chapters 42 --to-dir ./pdfs --chapters 1-5

Calibre 查詢語言

與 books search 和 books list --search 一起使用:

author:asimov                    # 作者包含 "asimov"
title:"Foundation"               # 書名片語
tags:fiction                     # 標籤匹配
rating:>3                        # 評分大於 3
series:"Foundation"              # 系列匹配
pubdate:[2020-01-01,2021-12-31]  # 日期範圍
identifiers:isbn:1234567890      # 特定識別碼
has:cover                        # 有封面圖片
not:tags:fiction                 # 否定
author:asimov and tags:scifi     # 布林 AND

關鍵元數據欄位

欄位類型說明
titletext書名
authorstext作者姓名(以 & 分隔)
tagstext逗號分隔的標籤
seriestext系列名稱
series_indexfloat系列中的位置
ratingfloat評分 1-5
publishertext出版社名稱
pubdatedatetime出版日期
commentstext描述/評論
languagestext語言代碼
identifierstextISBN、ASIN 等 (type:value)

支援的格式

輸入: EPUB、MOBI、AZW、AZW3、PDF、HTML、DOCX、ODT、FB2、TXT、RTF、LIT 等

輸出(轉換): EPUB、MOBI、AZW3、PDF、HTML、DOCX、TXT 等

狀態管理

CLI 會保留會話狀態,包含:

  • 會話檔案:~/.cli-anything-calibre/session.json
  • 圖書館路徑持久化:活躍的圖書館會跨會話儲存
  • 環境變數覆蓋:CALIBRE_LIBRARY 環境變數

輸出格式

所有命令都支援雙重輸出模式:

  • 人類可讀(預設):表格、顏色、格式化文字
  • 機器可讀(--json 旗標):供代理使用的結構化 JSON
# 人類輸出
cli-anything-calibre books list

# 供代理使用的 JSON 輸出
cli-anything-calibre --json books list

供 AI 代理使用

當以程式化方式使用此 CLI 時:

  1. 始終使用 --json 旗標 以獲得可解析的輸出
  2. 檢查回傳碼 - 0 表示成功,非零表示錯誤
  3. 解析 stderr 以取得失敗時的錯誤訊息
  4. 驗證輸出是否存在(在匯出/轉換操作後)
  5. 使用 --library 旗標 或 CALIBRE_LIBRARY 環境變數來指定圖書館路徑
  6. 章節匯出需要 EPUB 格式 - 如有需要,先進行格式轉換

更多資訊

  • 完整文件:請參閱套件中的 README.md
  • 架構 SOP:請參閱 agent-harness 目錄中的 CALIBRE.md
  • 測試覆蓋率:請參閱 tests 目錄中的 test_core.py 和 test_full_e2e.py
  • 方法論:請參閱 cli-anything-plugin 中的 HARNESS.md

版本

1.0.0

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

cli-anything-adguardhome

>-

cli-anything-anygen

>-

cli-anything-audacity

>-

cli-anything-blender

>-

cli-anything-browser

Browser automation CLI using DOMShell MCP server. Maps Chrome

cli-anything-ccswitch

CLI interface for CC Switch — manage AI coding tool configurations from the terminal

cli-anything-chromadb

>-

cli-anything-cloudanalyzer

Command-line interface for CloudAnalyzer — Agent-friendly harness for CloudAnalyzer, a QA platform for mapping, localization, and perception outputs. Supports 27 commands across 8 groups: point cloud evaluation, trajectory evaluation, ground segmentation QA, config-driven quality gates, baseline evolution, processing, visualization, and interactive REPL.

cli-anything-cloudcompare

Command-line interface for CloudCompare — Agent-friendly harness for CloudCompare, the open-source 3D point cloud and mesh processing software. Supports 41 commands across 9 groups: project management, session control, point cloud operations (subsample, filter, segment, analyze), mesh operations, distance computation (C2C, C2M), transformations (ICP, matrix), export (LAS/LAZ/PLY/PCD/OBJ/STL/E57), and interactive REPL.

cli-anything-comfyui

>-

cli-anything-dify-workflow

Wrapper for the Dify workflow DSL CLI. Create, inspect, validate, edit, and export Dify workflow files through a CLI-Anything harness.

cli-anything-drawio

>-

cli-anything-eez-studio

Use EEZ Studio from the command line: inspect and modify native .eez-project files, edit LVGL screens/widgets, manage SCPI commands, and invoke the real EEZ Studio backend for LVGL builds.

cli-anything-eth2-quickstart

>-

cli-anything-exa

>-

cli-anything-firefly-iii

Firefly III CLI - Personal finance management via CLI-Anything

cli-anything-freecad

Complete CLI harness for FreeCAD parametric 3D CAD modeler (258 commands). Covers ALL workbenches: Part (29 primitives + boolean + mirror + loft + sweep), Sketcher (26 cmds: geometry + constraints + editing), PartDesign (38 cmds: pad/pocket/groove/fillet/chamfer/patterns/hole/datum), Assembly (11 cmds), Mesh (16 cmds), TechDraw (15 cmds: views + dimensions + PDF/SVG), Draft (33 cmds: 2D shapes + arrays + transforms), FEM (12 cmds), CAM/CNC (10 cmds), Surface (6 cmds), Spreadsheet (7 cmds), Import (13 formats), Export (17 formats), Measure (12 cmds), Materials (21 presets). Headless FreeCAD export to STEP/IGES/STL/OBJ/DXF/PDF/glTF/3MF.

cli-anything-gimp

>-

cli-anything-godot

>-

cli-anything-inkscape

>-

相關技能