Skip to content

Sync #73

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 32 commits into from
Jun 19, 2025
Merged

Sync #73

Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
c3b4f0c
claude code is crazy
Jun 17, 2025
03a89a3
cleanup
rmusser01 Jun 17, 2025
29984de
tests
rmusser01 Jun 17, 2025
40eac8f
Merge branch 'dev' of https://github.com/rmusser01/tldw_chatbook into…
rmusser01 Jun 17, 2025
73c8e39
CC
rmusser01 Jun 17, 2025
6481c40
Merge branch 'dev' of https://github.com/rmusser01/tldw_chatbook into…
rmusser01 Jun 17, 2025
b694c0a
cc
rmusser01 Jun 17, 2025
6d5a50c
cc2
rmusser01 Jun 18, 2025
eaecf08
cc3
rmusser01 Jun 18, 2025
865564d
CC4
rmusser01 Jun 18, 2025
09a6927
cc5
rmusser01 Jun 18, 2025
32bc2f8
before the wave
rmusser01 Jun 18, 2025
f91a007
Note templates
rmusser01 Jun 18, 2025
5c538d6
command palette actions
rmusser01 Jun 18, 2025
62cac8d
overnight"
rmusser01 Jun 18, 2025
2d59d09
cc6
rmusser01 Jun 19, 2025
e9a3137
c
rmusser01 Jun 19, 2025
3325b15
cc7
rmusser01 Jun 19, 2025
4be83c1
RAG deps fix
rmusser01 Jun 19, 2025
8e84537
Merge branch 'dev' of https://github.com/rmusser01/tldw_chatbook into…
rmusser01 Jun 19, 2025
456d0d1
test fixes
rmusser01 Jun 19, 2025
f10e320
Merge branch 'dev' of https://github.com/rmusser00/tldw_chatbook into…
rmusser01 Jun 19, 2025
e8da096
cc8
rmusser01 Jun 19, 2025
c137cd5
cc9
rmusser01 Jun 19, 2025
77a1e36
cc10
rmusser01 Jun 19, 2025
ac0791e
uhhh, notes sync and?
rmusser01 Jun 19, 2025
8d3bc99
notes upgrade
rmusser01 Jun 19, 2025
59b3141
notes+
rmusser01 Jun 19, 2025
8e62f79
notes++
rmusser01 Jun 19, 2025
d3aad3e
well, sync crashes but notes UX is nicer...
rmusser01 Jun 19, 2025
f7883a2
Notes ++++
rmusser01 Jun 19, 2025
455814d
First stab at a vibe coded notes syncing implementation.
rmusser01 Jun 19, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
claude code is crazy
Robert Musser authored and Robert Musser committed Jun 17, 2025
commit c3b4f0c1235324f0018e39fe49202eb5fb085bf7
156 changes: 156 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
# CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

## Project Overview

**tldw_chatbook** is a Terminal User Interface (TUI) application built with the Textual framework for interacting with various Large Language Model APIs. It provides conversation management, character/persona chat, notes, media ingestion, and RAG capabilities.

**License**: AGPLv3+
**Python Version**: ≥3.11
**Main Framework**: Textual (≥3.3.0)

## Common Development Commands

### Running the Application
```bash
# Activate virtual environment first
source .venv/bin/activate # On Windows: .venv\Scripts\activate

# Run the application
python3 -m tldw_chatbook.app
```

### Installation and Dependencies
```bash
# Create and activate virtual environment
python3 -m venv .venv
source .venv/bin/activate

# Install core dependencies
pip install -r requirements.txt

# Install with development dependencies
pip install -e ".[dev]"

# Install optional feature sets
pip install -e ".[embeddings_rag]" # For RAG functionality
pip install -e ".[websearch]" # For web search
pip install -e ".[local_vllm]" # For vLLM support
```

### Testing
```bash
# Run all tests
pytest ./Tests

# Run specific test modules
pytest ./Tests/Chat/
pytest ./Tests/Media_DB/
pytest ./Tests/Character_Chat/

# Run only unit tests
pytest -m unit

# Run a single test file
pytest ./Tests/Chat/test_chat_functions.py

# Run a specific test function
pytest ./Tests/Chat/test_chat_functions.py::test_specific_function
```

### Building
```bash
# Build the package
python -m build

# Install in development mode
pip install -e .

# Install with specific optional dependencies
pip install -e ".[dev,embeddings_rag,websearch]"
```

## Architecture Overview

The codebase follows a modular architecture with clear separation of concerns:

### Core Structure
- **`tldw_chatbook/app.py`** - Main entry point, initializes Textual app and global state
- **`App_Functions/UI/`** - Main window components for different tabs (Chat, Character, Notes, etc.)
- **`Widgets/`** - Reusable UI components (buttons, inputs, lists, etc.)
- **`Event_Handlers/`** - Decoupled event handling logic for UI interactions
- **`App_Functions/Chat/`** - Core chat functionality and conversation management
- **`App_Functions/Character_Chat/`** - Character/persona management and chat
- **`App_Functions/Notes/`** - Notes creation and management
- **`App_Functions/LLM_Calls/`** - LLM provider integrations (commercial and local)
- **`App_Functions/DB/`** - Database layer with SQLite implementations

### Key Databases
1. **ChaChaNotes_DB** - Characters, Chats, and Notes storage
2. **Media_DB_v2** - Ingested media files and metadata
3. **Prompts_DB** - User prompt templates

### Configuration System
- **Config File**: `~/.config/tldw_cli/config.toml` (created on first run)
- **User Data**: `~/.share/tldw_cli/` directory
- **Environment Variables**: Supported for API keys (e.g., `OPENAI_API_KEY`)

### Event-Driven Architecture
The app uses Textual's event system extensively:
- UI components emit custom events
- Event handlers in `Event_Handlers/` process these events
- Clear separation between UI and business logic

## LLM Provider Integration

The app supports multiple LLM providers through a unified interface:

### Commercial Providers
Located in `App_Functions/LLM_Calls/Commercial_APIs/`:
- OpenAI, Anthropic, Cohere, Google, Groq, Mistral, DeepSeek, HuggingFace, OpenRouter

### Local Providers
Located in `App_Functions/LLM_Calls/Local_APIs/`:
- Llama.cpp, Ollama, Kobold.cpp, vLLM, Aphrodite, Custom OpenAI-compatible

### Adding New Providers
1. Create a new module in the appropriate directory
2. Implement the standard interface methods (chat completion, streaming)
3. Add provider configuration to the config system
4. Update UI components to include the new provider

## Key Development Patterns

### Database Operations
- All database operations use context managers for connection handling
- FTS5 search capabilities for text search
- Soft deletion pattern with `deleted_at` timestamps
- Conversation versioning and forking support

### UI Component Structure
- Components inherit from Textual's Widget classes
- Use reactive attributes for state management
- Emit custom events for decoupled communication
- Follow Textual's CSS styling conventions

### Error Handling
- Comprehensive logging using loguru
- User-friendly error messages in the UI
- Fallback mechanisms for API failures

### Testing Approach
- Unit tests for core functionality
- Use temporary in-memory SQLite databases for testing (not mocks)
- Test fixtures in `Tests/fixtures/`

## Important Notes

- **Development Branch**: Submit PRs to `dev` branch, not `main`
- **Code Style**: No enforced linter/formatter currently - follow existing patterns
- **Dependencies**: Keep core dependencies minimal, use optional dependencies for features
- **Configuration**: Always check config.toml for feature flags and settings
- **API Keys**: Never hardcode API keys - use environment variables or config file
- **Database Migrations**: No formal migration system - handle schema changes carefully
- **Entry Point**: Main CLI command is `tldw-cli` (defined in pyproject.toml)
- **Package Structure**: Main package is `tldw_chatbook` with modular subpackages
Loading