README.md

Ceridwen #

Ceridwen is a local terminal assistant built with LangChain and Ollama. Bring your own model, keep conversation state on your computer, and use tools for web research, file editing, calculations, and desktop tasks. Its name comes from the Welsh goddess of inspiration and knowledge.

Install and launch #

Requires Python 3.13+. Ollama and a tool-capable model are needed for chatting, but the app opens without either being configured.

git clone https://tangled.org/liampallett.space/ceridwen
cd ceridwen
python3 -m venv .venv
source .venv/bin/activate
python -m pip install .
ceridwen

Alternatively, with uv:

uv sync
uv run ceridwen

Start Ollama, install a model with ollama pull <model>, then run /model inside Ceridwen to select it. /model <name> selects one directly. The model must support tool calling.

Ceridwen remembers your last successfully selected model. OLLAMA_MODEL remains an optional startup override. If the remembered model is missing or Ollama is offline, the CLI stays open so you can use local commands and configure another model. With no selection, it displays:

No model selected! Run /model to configure one, or run `ollama pull <model>` to pull one to your computer.

Run /doctor to check the connection, installed packages, selected model capabilities, data directory, and optional tools. rg accelerates code search. Calendar and Reminders require icalBuddy on macOS; clipboard and file-launch tools are also macOS-only.

Releases #

The first release candidate is 0.1.0. Check an installed version with ceridwen --version or python -m ceridwen --version.

Tangled-native checks and annotated-tag artifact publishing are configured in .tangled/workflows/. See the release guide for building, clean-install verification, publishing prerequisites, and installing release wheels.

Commands #

Command Behaviour
/help List commands.
/exit Quit; Ctrl+C or Ctrl+D at the prompt also exits.
/model [name] Choose a model; failed switches preserve the working selection.
/thinking [off|low|medium|high|max] Toggle reasoning or set a level supported by your model.
/new [label] Start a conversation, optionally labelled.
/threads [query] List workspace threads or search titles and retained message context.
/switch [id] Select a conversation and show its six most recent non-empty user/assistant messages.
/rename <id> <label> Rename a conversation.
/delete <id> Delete a conversation after confirmation; deleting the active thread starts a replacement.
/ghost Toggle temporary conversations; each toggle starts a fresh thread.
/retry Resume the last failed or interrupted request in the current thread.
/tool-outputs Toggle detailed tool output.
/permissions [category mode] View or set session permissions.
/status Show estimated context usage and distance to automatic summarisation.
/compact Summarise earlier context now, preserving the latest exchange.
/skills List workspace skills and reload them into the prompt.
/latex [on|off|raw] Toggle terminal maths approximation, or print the last saved answer unchanged.
/doctor Diagnose the local installation.

The last conversation used in each working directory resumes on startup, with a recent-message preview. Search covers the latest retained context, including summaries; it does not search every historical checkpoint.

File edits and tool permissions #

edit_file replaces exact text fragments and rejects ambiguous matches unless an explicit match count is supplied. write_file creates or replaces whole text files. Both show a unified diff before applying changes, preserve existing file permissions, and reject edits if the file changes during approval. File tools restrict paths to the workspace, including resolved symlinks.

Permissions default to ask and reset at the next launch:

/permissions
/permissions files allow
/permissions shell deny
/permissions clipboard ask

Categories are files, shell, clipboard, and desktop; modes are ask, allow, and deny. File writes still display their diffs in allow mode. Clipboard permissions apply to both reading and replacing its contents. Shell approval shows the command and working directory. These controls govern built-in tools: an approved shell command can access anything available to your operating-system account.

Failures and context management #

Model and tool failures are reported without closing the CLI. Individual tool exceptions become error results the model can respond to. Discovery calls have a 10-second timeout; model calls have a 120-second HTTP timeout. There is no automatic retry of side-effecting tools.

Use /retry to resume a pending checkpoint. If the request failed before its first checkpoint, the same message ID is reused to avoid duplicating the user message. A pending tool can run again on explicit retry if it failed before recording completion; check external side effects after an interrupted action.

The configured context window is 65,536 tokens. Automatic summarisation begins around 40,000 tokens and preserves recent messages. A warning appears near that threshold, and a notice confirms when summarisation happens. /compact performs a manual summary and retains the latest exchange. Failed compaction leaves the existing checkpoint intact. Token estimates vary by model and do not include tool-schema overhead.

Terminal LaTeX #

Replies stream as formatted text. Long replies use a bounded live viewport, then print the complete answer once at completion so scrolling does not leave repeated panel frames.

Maths approximation is enabled by default. Supported delimiters are $...$, $$...$$, \(...\), and \[...\]. For example:

$x^{2} + \alpha$        → x² + α
$\frac{a+b}{c+d}$       → (a+b)/(c+d)
$\sqrt{x}$              → √(x)

Conversion uses pylatexenc locally. Common bare logic commands such as \neg, \land, \lor, and \iff also become Unicode symbols, including in tables. Code spans and fenced code stay unchanged. Unknown commands and complicated nested scripts remain visible as source. /latex off disables approximation; /latex raw shows the last saved answer's original Markdown and LaTeX.

This is a one-dimensional Unicode approximation, not graphical typesetting. Complex notation and terminal font coverage vary. Original messages remain unchanged in conversation storage; no browser, remote renderer, or TeX installation is used.

Storage, privacy, and customisation #

Normal threads and checkpoints use SQLite in the platform-specific Ceridwen data directory. That directory also contains settings.json (model and workspace resume preferences) and .history (normal prompt history).

Ghost threads, checkpoints, and prompt history stay in memory. Leaving ghost mode discards that temporary conversation; exit ghost mode before switching to a saved thread. Ghost mode does not undo explicit tool actions such as writing a file or copying text, and terminal scrollback can retain displayed text. Inference is local when using a local Ollama model; tools can make network requests.

The packaged ceridwen/CERIDWEN.md provides the default system prompt. A CERIDWEN.md in your working directory adds project context. Markdown files in skills/ appear in the available-skills index; the assistant reads their instructions through read_file. Use create_skill to save a workflow and /skills to reload it.

Development #

uv sync --extra dev
uv run pytest -q
uv run ruff check ceridwen tests scripts
uv run ruff format --check ceridwen tests scripts

Without uv, install the development extra with python -m pip install -e '.[dev]'. requirements-dev.txt points to that extra; uv.lock records the resolved environment.

The offline suite covers model selection and persistence, recovery and retry, permissions and diff review, thread navigation, ghost privacy, compaction, LaTeX display, and video URL parsing. A GitHub Actions workflow runs tests and lint/format checks on Linux and macOS when this repository is hosted on GitHub. No live Ollama server or network service is required for those checks.

ceridwen/
├── main.py          # CLI and command dispatch
├── agent.py         # model inspection and agent construction
├── context.py       # context estimates and manual compaction
├── doctor.py        # installation diagnostics
├── math_display.py  # terminal LaTeX approximation
├── permissions.py   # session tool permissions
├── settings.py      # saved preferences
├── threads.py       # SQLite and ephemeral conversation storage
├── tools.py         # assistant tools
├── ui.py            # streaming display and inline selectors
└── CERIDWEN.md      # default system prompt
tests/               # offline tests