Metadata-Version: 2.4
Name: the-notebook
Version: 1.4.1
Summary: Encrypted bilingual (English/Persian) personal journal with AI assistant and MCP server
Author-email: Bloody-Crow <bloody-crow@users.noreply.github.com>
License: MIT
Project-URL: Homepage, https://github.com/Bloody-Crow/The-Notebook
Project-URL: Repository, https://github.com/Bloody-Crow/The-Notebook
Project-URL: Issues, https://github.com/Bloody-Crow/The-Notebook/issues
Project-URL: Changelog, https://github.com/Bloody-Crow/The-Notebook/releases
Keywords: journal,diary,encryption,persian,jalali,ai,mcp
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: X11 Applications :: Qt
Classifier: Environment :: MacOS X
Classifier: Environment :: Win32 (MS Windows)
Classifier: Intended Audience :: End Users/Desktop
Classifier: License :: OSI Approved :: MIT License
Classifier: Natural Language :: English
Classifier: Natural Language :: Persian
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Text Processing :: Markup :: HTML
Classifier: Topic :: Security :: Cryptography
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: PyQt6<7,>=6.6
Requires-Dist: cryptography<46,>=42.0
Requires-Dist: jdatetime<6,>=4.1
Requires-Dist: markdown<4,>=3.5
Requires-Dist: markdownify<1,>=0.13
Requires-Dist: matplotlib<4,>=3.8
Requires-Dist: holidays<1,>=0.45
Requires-Dist: python-dateutil<3,>=2.8
Provides-Extra: ai
Requires-Dist: anthropic<1,>=0.40; extra == "ai"
Requires-Dist: openai<2,>=1.50; extra == "ai"
Requires-Dist: google-generativeai<1,>=0.8; extra == "ai"
Requires-Dist: httpx<1,>=0.27; extra == "ai"
Provides-Extra: mcp
Requires-Dist: mcp<2,>=1.0; extra == "mcp"
Provides-Extra: audio
Requires-Dist: sounddevice<1,>=0.4.6; extra == "audio"
Requires-Dist: numpy<3,>=1.26; extra == "audio"
Requires-Dist: soundfile<1,>=0.12; extra == "audio"
Provides-Extra: keyring
Requires-Dist: keyring<26,>=24.0; extra == "keyring"
Provides-Extra: spellcheck
Requires-Dist: pyspellchecker<1,>=0.8; extra == "spellcheck"
Provides-Extra: all
Requires-Dist: the-notebook[ai,audio,keyring,mcp,spellcheck]; extra == "all"
Provides-Extra: dev
Requires-Dist: pytest<10,>=8.0; extra == "dev"
Requires-Dist: the-notebook[all]; extra == "dev"
Dynamic: license-file

# 📓 The Notebook

[English](README.md) · [فارسی](README.fa.md)

A feature-rich, **encrypted**, **bilingual** (English / Persian-Farsi) personal
journal and diary application for the desktop — now with an **AI assistant**
and **MCP server** for AI agent integration.

> Your thoughts, your words, your keys.

---

## 🆕 What's New in v1.4.0

### 🤖 AI Assistant
Bring your own API key and ask questions about your journal:
- **Ask Your Journal** — query your past entries in natural language
- **Auto-generated summaries** — weekly or monthly digests
- **Sentiment analysis** — track your emotional patterns over time
- **Auto-tagging suggestions** — AI-suggested tags for new entries
- Supports **Claude (Anthropic)**, **OpenAI (GPT)**, **Google Gemini**,
  and **Ollama** (local, private, no API key needed)
- API keys are **encrypted at rest** with the same AES-GCM key as your entries

### 🔌 MCP Server (Model Context Protocol)
The first encrypted journal with MCP support. Any MCP-compatible AI client
(Claude Desktop, OpenClaw, Hermes, Cursor, etc.) can:
- List folders, entries, and tags
- Read and search entries
- Create new entries and append to existing ones
- Get journal statistics

```bash
# Start the MCP server (from the command line)
the-notebook-mcp --password YOUR_PASS

# Or via environment variable
NOTEBOOK_PASS=YOUR_PASS the-notebook-mcp
```

### 🔒 Encrypted Attachments
File attachments are now encrypted with AES-256-GCM — the same crypto that
protects your entries. Your photos, audio notes, and documents are safe at
rest. (Toggleable in Settings.)

### 📓 Multiple Notebooks
Create separate journals for Work, Personal, Dreams — each with its own
password and folder tree. Switch between them from the Data menu.

### 🏗️ Architecture Improvements
- **PyPI package** — `pip install the-notebook`
- **XDG-compliant paths** on Linux (`~/.local/share/TheNotebook/`)
- **Config migration system** — automatic upgrades between versions
- **Threaded operations** — no more UI freezes during re-encryption
- **Proper logging** — `app.log` with rotation for debugging
- **Package structure** — proper Python package, not flat scripts

---

## ✨ Features

### Security
- 🔐 **AES-256-GCM** encryption for every entry, with an additional
  **HMAC-SHA256** integrity tag (defence-in-depth).
- 🔑 **PBKDF2** key derivation (480 000 iterations) with a per-installation
  random salt.
- 🔒 **Auto-lock** after a configurable period of inactivity; keys are
  zeroed from memory on lock.
- 🛡️ **Exponential backoff** on failed unlock attempts (non-blocking).
- 🔗 Optional **OS keyring** integration.
- 🔄 **Safe password change** — setting, changing, or removing the password
  re-encrypts every entry *and* every history snapshot in place.
- 🔒 **Encrypted attachments** — files attached to entries are encrypted
  with the same AES-GCM key as the entries themselves.

### AI Assistant (NEW in v1.4.0)
- 🤖 **Ask Your Journal** — natural-language Q&A about your past entries.
- 📅 **Auto-generated summaries** — weekly or monthly digests.
- 💭 **Sentiment analysis** — track your emotional patterns.
- 🏷️ **Auto-tagging suggestions** — AI-suggested tags for new entries.
- 🔑 **Bring your own API key** — supports Claude, OpenAI, Gemini, Ollama.
- 🔒 API keys **encrypted at rest** with your journal password.
- 🤖 **No vendor lock-in** — switch providers anytime.

### MCP Server (NEW in v1.4.0)
- 🔌 Expose your journal to any MCP-compatible AI client.
- 📖 Read tools: list folders, entries, tags; search; read; statistics.
- ✏️ Write tools: create entries, append to entries.
- 🔒 Requires the journal to be unlocked (password-gated).
- 🖥️ Runs as a standalone process via `the-notebook-mcp`.

### Writing
- 📝 Rich-text editor with bold / italic / underline / strikethrough,
  bullet and numbered lists.
- 🖼️ **Drag-and-drop images** directly into entries.
- 🎙️ **Audio notes** — record voice memos inline (optional).
- 📎 **File attachments** (now encrypted!) of any type.
- 🌐 Three editor views: **WYSIWYG**, **HTML source**, **Markdown preview**.
- 🔄 **Auto-save** every 30 seconds.
- 🔤 Optional **spell check**.

### Organization
- 📁 Folders and dated entries.
- 🏷️ Tags, ⭐ favorites, 😊 mood tracking.
- 🗑️ **Soft-delete trash** with restore.
- 📜 **Version history** with one-click restore.
- 📓 **Multiple notebooks** — separate journals with separate passwords.

### Calendars & search
- 🗓️ Dual calendars: **Gregorian** and a custom **Jalali (Persian)** calendar.
- 🎉 Holiday / event labels for both Iranian and US calendars.
- 🔍 **Full-text search** via an inverted index.
- ⌨️ **Command palette** (`Ctrl+Shift+P`).
- 🔎 Quick search bar (`Ctrl+F`).

### Insights & sync
- 📊 **Statistics**: activity graph, tag cloud, per-folder breakdown, mood chart.
- 💭 **Daily writing prompts** (20 each in English and Persian).
- 📆 **"On This Day"** memories.
- 🔄 **Folder sync** via Markdown.
- 💾 **Backup & restore** to/from zip.
- 📤 **Batch export** to HTML or Markdown.

---

## 🚀 Installation

### Option 1: Download a pre-built binary (easiest)
Go to the [Releases page](https://github.com/Bloody-Crow/The-Notebook/releases)
and download the appropriate file for your platform.

### Option 2: Install from PyPI
```bash
pip install the-notebook
the-notebook   # launch the app

# With AI support:
pip install the-notebook[ai]

# With everything (AI, MCP, audio, keyring, spellcheck):
pip install the-notebook[all]

# To run the MCP server:
pip install the-notebook[mcp]
the-notebook-mcp --password YOUR_PASS
```

### Option 3: Build from source
```bash
git clone https://github.com/Bloody-Crow/The-Notebook.git
cd The-Notebook
pip install -e .
the-notebook
```

---

## 🤖 AI Assistant Setup

1. Open the app → **Settings → AI Assistant Settings...**
2. Choose your provider (Claude / OpenAI / Gemini / Ollama).
3. Paste your API key (it's encrypted with your journal password).
4. Optionally override the model name or set a custom base URL (for Ollama).
5. Use **Data → Ask Your Journal...** to ask questions about your entries.
6. Use **Data → Generate Summary...** for weekly/monthly digests.

### Supported providers
| Provider | API Key Needed | Model Example |
|----------|---------------|---------------|
| Claude (Anthropic) | Yes | `claude-sonnet-4-20250514` |
| OpenAI (GPT) | Yes | `gpt-4o` |
| Google Gemini | Yes | `gemini-1.5-pro` |
| Ollama (local) | No | `llama3.2` |

---

## 🔌 MCP Server Setup

The MCP server lets AI agents (Claude Desktop, OpenClaw, Hermes, Cursor, etc.)
read and write your journal entries.

### Starting the server
```bash
# If your journal has no password:
the-notebook-mcp

# If your journal is encrypted:
the-notebook-mcp --password YOUR_PASS

# Or via environment variable:
NOTEBOOK_PASS=YOUR_PASS the-notebook-mcp
```

### Connecting from Claude Desktop
Add to your `claude_desktop_config.json`:
```json
{
  "mcpServers": {
    "the-notebook": {
      "command": "the-notebook-mcp",
      "args": ["--password", "YOUR_PASS"]
    }
  }
}
```

### Available tools
| Tool | Description |
|------|-------------|
| `list_folders` | List all journal folders |
| `list_entries` | List entries in a folder (optionally by date) |
| `read_entry` | Read the full content of an entry |
| `search_entries` | Full-text search across all entries |
| `create_entry` | Create a new journal entry |
| `append_to_entry` | Append text to an existing entry |
| `list_tags` | List all tags |
| `get_statistics` | Get journal statistics |

---

## 📦 For Developers

### Run the test suite
```bash
pip install -e ".[dev]"
pytest tests/ -v
```

### Package structure
```
the_notebook/
├── __init__.py        # Package metadata
├── __main__.py        # python -m the_notebook entry point
├── main.py            # Application entry point
├── config.py          # Paths, config, migration, logging
├── crypto.py          # AES-GCM + HMAC encryption (text + binary)
├── models.py          # File I/O, search index, re-encryption
├── i18n.py            # Translations + Persian calendar events
├── widgets.py         # RichTextEditor + PersianCalendarWidget
├── dialogs.py         # All QDialog subclasses
├── main_window.py     # JournalApp main window
├── notebooks.py       # Multi-notebook manager
├── ai.py              # AI assistant (Claude/OpenAI/Gemini/Ollama)
├── mcp_server.py      # MCP server for AI agent integration
└── workers.py         # Threading utilities
```

---

## 🔒 Security

See **[SECURITY.md](SECURITY.md)** for the full threat model.

**Short version:**
- Entry **text** is encrypted with AES-256-GCM + HMAC-SHA256.
- **Attachments** are encrypted with the same key (new in v1.4.0).
- **Filenames, folder names, tags, moods, favorites, and the search index
  are NOT encrypted.**
- **AI API keys** are encrypted with your journal password.

---

## 📜 License

MIT — see [LICENSE](LICENSE).

Copyright © 2025 [Bloody-Crow](https://github.com/Bloody-Crow).
