Communitygithub.com

cli-anything-calibre

一个为Calibre电子书管理提供有状态CLI的工具,包装真实Calibre命令,为AI代理和脚本提供结构化接口。

cli-anything-calibre 是什么?

cli-anything-calibre 是一个有状态的 CLI 工具,专为 Calibre 电子书管理设计。它包装了真实的 Calibre 工具(如 calibredb、ebook-convert 和 ebook-meta),为 AI 代理和脚本提供一个干净、结构化的接口,用于执行库操作、元数据编辑和格式转换。该工具支持 REPL 交互模式、JSON 输出格式,并提供丰富的命令组,包括库管理、图书操作、元数据编辑、格式转换、自定义列和目录生成。AI 代理可以使用 --json 标志来获取机器可解析的输出,并通过返回码和 stderr 进行错误处理。它要求 Python 3.10+ 和系统中安装的 Calibre,并支持 session 状态持久化,通过环境变量 CALIBRE_LIBRARY 或 --library 标志指定库路径。

兼容平台~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 是做什么的?

一个为 Calibre 电子书管理设计的有状态 CLI 工具。它包装了真实的 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 输出运行(供 AI 代理使用)
cli-anything-calibre --json books list

REPL 模式

不带子命令调用时,CLI 会进入交互式 REPL 会话:

cli-anything-calibre
# 使用 Tab 补全和历史记录交互式输入命令
# 输入 'help' 查看可用命令
# 输入 'quit' 或 'exit' 退出

命令组

库管理

库管理命令。

命令描述
connect <path>设置活动库路径
info显示库统计信息(图书数量、格式、数据库大小)
check使用 calibredb check_library 验证库完整性

图书操作

图书操作(包装 calibredb)。

命令描述
list列出图书,支持过滤和排序
search <query>使用 Calibre 查询语言搜索
add <files>向库中添加图书文件
remove <ids>删除图书(移到回收站或永久删除)
show <id>显示图书的完整元数据
export <ids>将图书导出到目录
export-chapters <id>将每个章节导出为单独的 PDF(需要 EPUB 格式)

元数据编辑

元数据编辑(包装 calibredb set_metadata)。

命令描述
get <id> [field]获取元数据(全部或特定字段)
set <id> <field> <value>设置元数据字段
embed <ids>将元数据嵌入到图书文件中

格式管理

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

命令描述
list <id>列出图书的可用格式
add <id> <file>为图书添加格式
remove <id> <fmt>从图书中删除格式
convert <id> <input_fmt> <output_fmt>转换图书格式

自定义列

自定义列(包装 calibredb)。

命令描述
list列出所有自定义列
add <label> <name> <type>创建自定义列
remove <label>删除自定义列
set <id> <label> <value>设置自定义字段值

目录生成

目录生成。

命令描述
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 "New 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 标志):用于 AI 代理消费的结构化 JSON
# 人类输出
cli-anything-calibre books list

# 为 AI 代理准备的 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

>-

相关技能