Metadata-Version: 2.4
Name: libra-ebook
Version: 0.1.0
Summary: AI-powered personal ebook library manager
Project-URL: Homepage, https://github.com/balusch/libra
Project-URL: Repository, https://github.com/balusch/libra
Author-email: Jianyong Chen <baluschch@gmail.com>
License: MIT
License-File: LICENSE
Keywords: ai,cli,ebook,library,search,tagging
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Console
Classifier: Intended Audience :: End Users/Desktop
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Utilities
Requires-Python: >=3.11
Requires-Dist: beautifulsoup4>=4.12
Requires-Dist: ebooklib>=0.18
Requires-Dist: openai>=1.0
Requires-Dist: pymupdf>=1.25
Requires-Dist: python-pptx>=1.0
Requires-Dist: pyyaml>=6.0.3
Requires-Dist: rich>=13
Requires-Dist: sqlite-vec>=0.1
Requires-Dist: tomli>=2.0; python_version < '3.12'
Requires-Dist: typer>=0.15
Description-Content-Type: text/markdown

# Libra

AI-powered personal ebook library manager. Scan your collection, auto-tag with
AI, search by meaning, clean up messy filenames.

## Features

- **AI tagging** — auto-generate tags, clean titles, detect authors from messy filenames
- **Semantic search** — find files by concept, not just keywords ("那篇讲垃圾回收的论文")
- **Three-layer search** — FTS5 keyword + vector similarity + path matching
- **Multi-version grouping** — automatically groups editions and formats of the same work
- **Rename** — batch rename files based on canonical metadata, cross-platform safe
- **fzf integration** — interactive browse with preview, open, edit, copy path
- **Controlled vocabulary** — tags from a predefined taxonomy, extensible

## Install

```bash
# From PyPI
pip install libra-ebook

# From source
git clone https://github.com/balusch/libra && cd libra
uv sync
```

## Quick Start

```bash
# Set your OpenAI API key
export OPENAI_API_KEY="sk-..."

# Scan your library
libra scan ~/Documents/EBooks

# Search
libra search "distributed systems"
libra search "垃圾回收" --fzf

# Browse interactively
libra browse --tag ai

# See what you have
libra stats
libra tags
libra dupes
```

## Commands

| Command | Description |
|---------|-------------|
| `libra scan [PATH]` | Scan directory, AI tag & embed (`--limit N` to cap) |
| `libra search QUERY` | Three-layer search (FTS + semantic + path) |
| `libra browse` | Interactive fzf browser |
| `libra list` | List files with filters |
| `libra show ID\|PATH` | Show file details (by ID or path) |
| `libra open ID` | Open file with system app |
| `libra edit ID` | Edit tags/metadata |
| `libra related ID` | Find similar files |
| `libra prefer ID` | Mark preferred version |
| `libra retag` | Re-run AI tagging on selected files |
| `libra summarize` | Generate AI summaries from file content |
| `libra rename [PATH]` | Rename files from metadata (`--id ID` for single file) |
| `libra tags` | List tags with counts |
| `libra dupes` | Find duplicates + versions |
| `libra stats` | Library statistics |
| `libra export` | Export index (JSON/CSV) |

## Configuration

```toml
# ~/.config/libra/config.toml

[api]
openai_key = "sk-..."          # or use OPENAI_API_KEY env var

[library]
paths = ["~/Documents/EBooks"]

[search]
weight_fts = 0.4                 # keyword search weight
weight_semantic = 0.5            # semantic search weight
weight_path = 0.1                # path match weight
```

The database is stored at `{library_path}/.libra/libra.db`.

## Shell Completion

```bash
# bash
libra --install-completion bash

# zsh
libra --install-completion zsh

# fish
libra --install-completion fish
```

## Development

```bash
uv sync --all-groups   # install with dev deps
make check             # lint + typecheck + test
make format            # auto-format
make build             # build distribution
```

## License

MIT
