Skip to main content
The Watercooler Python API provides programmatic access to thread management, commands, data models, and configuration.

Package Structure

watercooler/
├── __init__.py          # Public exports (AdvisoryLock, read, write, thread_path)
├── commands.py          # Management commands (list_threads, search, reindex)
├── commands_graph.py    # Graph-canonical thread commands (say, ack, handoff)
├── models.py            # Model registry and resolution
├── config_schema.py     # Configuration classes
└── fs.py                # File system operations

Installation

pip install watercooler

Main Entry Points

Core Exports

The main package exports these utilities from watercooler/__init__.py:
from watercooler import (
    AdvisoryLock,      # File locking for thread safety
    read,              # Read thread files
    write,             # Write thread files
    thread_path,       # Get thread file paths
    __version__,       # Package version
)

Command Functions

Thread commands are available from two modules: Graph-canonical commands (recommended, primary implementation):
from watercooler.commands_graph import (
    init_thread,    # Initialize new thread
    say,            # Add entry with auto-ball-flip
    ack,            # Acknowledge without ball flip
    handoff,        # Explicit handoff to counterpart
    set_status,     # Update thread status
    set_ball,       # Update ball owner
)
Management commands:
from watercooler.commands import (
    list_threads,   # List all threads
    list_entries,   # List entries for a thread
    search,         # Search thread content
    reindex,        # Generate markdown index
    web_export,     # Export HTML index
    unlock,         # Clear advisory locks
)

Model Resolution

from watercooler.models import (
    # Embedding models
    resolve_embedding_model,
    ensure_model_available,
    get_model_dimension,
    # LLM models
    resolve_llm_gguf_model,
    ensure_llm_model_available,
    get_response_field,
)

Configuration

from watercooler.config_schema import (
    WatercoolerConfig,
    McpConfig,
    GraphConfig,
    MemoryConfig,
)

Quick Start Example

from pathlib import Path
from watercooler.commands_graph import init_thread, say

# Initialize a new thread
threads_dir = Path("~/threads").expanduser()
topic = "implement-user-auth"

thread_path = init_thread(
    topic,
    threads_dir=threads_dir,
    title="Implement User Authentication",
    status="OPEN",
    ball="codex"
)

# Add an entry
say(
    topic,
    threads_dir=threads_dir,
    agent="Claude Code",
    role="implementer",
    title="Starting OAuth implementation",
    body="Planning to use OAuth2 with JWT tokens...",
    entry_id="entry-001"
)

Thread Safety

All write operations use advisory file locking via AdvisoryLock:
from watercooler import AdvisoryLock
from pathlib import Path

lock_path = Path(".locks/my-thread.lock")

with AdvisoryLock(lock_path, timeout=2, ttl=10):
    # Perform thread operations
    pass

Graph-Canonical Architecture

Watercooler uses a graph-first architecture where:
  1. Data is written to graph storage (nodes.jsonl, edges.jsonl)
  2. Markdown files are projected as derived views
  3. The graph is the single source of truth
This ensures consistency and enables rich queries across thread data.

Next Steps

Build docs developers (and LLMs) love