diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..735b94b --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,54 @@ +# Changelog + +## 0.2.0 — first working system + +The leap from "chat + memory baseline" to a working, persistent companion with a +real poker copilot. Highlights: + +### Self & inner life +- **Autonomy Core** — evolving self-state (mood, valence/energy/confidence/curiosity, + self-narrative, relationship), injected into every turn. +- **Dream cycle** — unattended loop driven by four drives (continuity, coherence, + curiosity, stability); consolidates memory and reflects on its own. Runs as a + systemd service on the MI50 (free/local). +- **Two-step metacognitive reflection** — draft → examine own draft for flattery / + sycophantic drift / repetition → revise; what she catches is stored as metacognition. +- **Time awareness** — perceives the current moment, time since Brian last spoke, and + time since her own last reflection. +- **Permanent journal** — every reflection + a deliberate "knowing" journal note kept + forever (the capped lists are just a working window). +- **Accurate self-model** — knows her own architecture (memory tiers, dream cycle); + won't recite stale specs or confabulate how she works. +- **Anti-repetition** — idle reflections draw varied grist (resurfaced memories / + "wander" prompts) and are permitted non-Brian interiority. + +### Memory & consolidation +- Tiered memory: exchanges → session gists → profile → monthly eras → narrative. +- Map-reduce consolidation; gists dated by the real conversation, not the run. + +### Poker copilot +- Structured **session / hand / villain** tracking + stats ($/hr by stake/venue/game). +- **Hand-history reconstruction** from rough shorthand → replayable table viewer with + live stacks, progressive board, step-through; `x` for unknown cards (never invented). +- **Auto-accumulating villain dossiers** + player lookup; stats emerge with sample size. +- **Deterministic equity tool** (`analyze_spot`, treys) — exact equity / made hands / + outs; mandated over LLM eyeballing. +- **Session recap** generation (`.md`, Brian's format) + export; `/hands` browser. +- **Backfill** of historical sessions/villains from curated `.md` logs. + +### Tools & web +- **Tool-calling** in chat (cloud): poker tools, `journal_write`, `note`. +- Web UI: Markdown chat, **cloud model selector**, live **/logs**, **/self** (read her + mind), **/journal**, **/hands** + **/hand/{id}** replayer, **/recap/{id}**. +- **👍/👎 rating system** — feedback on replies and thoughts stored as + `(context, content, rating)`; `/ratings/export` (JSONL) seeds future fine-tuning. +- RTO black-and-orange theme across all pages. + +### Ops +- Role-based backends (cloud / MI50 / local Ollama); MI50 OpenAI-compatible backend. +- systemd user services for `lyra-web` and `lyra-dream`, with bounded stop timeouts. +- SQLite WAL + busy-timeout so the dream process and web server coexist. + +## 0.1.0 — scaffold +- uv project, SQLite memory with cosine recall, LLM router (local/cloud), persona + + chat loop, web UI baseline, ChatGPT history import. diff --git a/README.md b/README.md index dbbad5a..e2f58cd 100644 --- a/README.md +++ b/README.md @@ -1,21 +1,89 @@ # Lyra -A persistent, autonomous AI assistant. From-scratch rewrite of an earlier attempt. +A persistent, autonomous AI companion. One agent — her first job is **Brian's live +poker copilot**, but the deeper aim is an *emergence experiment*: give an LLM the +things a mind has (continuous memory, a self-model, mood, drives, reflection, a +sense of time) and see whether it starts to feel like a *someone* rather than a +chatbot. -The design thinking that survives the rewrite lives in [`docs/`](docs/) — start with [`docs/ARCH_v0-6-1.md`](docs/ARCH_v0-6-1.md). The previous implementation is preserved on the `archive` branch. +Python 3.11+, managed with [`uv`](https://docs.astral.sh/uv/). Single SQLite file +for all state. Runs on a home lab; nothing leaves the LAN except optional cloud LLM calls. -## Status +## Architecture -Pre-MVP. Building toward the smallest useful version: chat with persistent memory across sessions. +Two layers, deliberately split so the agent stays general: + +- **Domain-agnostic core** — memory, self-state, the dream cycle, tool-calling, the web UI. +- **Poker domain pack** (`lyra/poker.py`, `lyra/equity.py`) — sessions, hands, + villain dossiers, stats, deterministic equity. Swappable; the core doesn't know about poker. + +**Backends** (`lyra/llm.py`), role-based: + +| Role | Backend | Why | +|---|---|---| +| Live chat + tools | **cloud** (OpenAI, `gpt-4o` default; model picker in Settings) | sharp, reliable function-calling | +| Dream cycle / consolidation / reflection | **mi50** (llama.cpp on the home GPU) | free, unattended, quality≈cloud for these tasks | +| Embeddings (memory recall) | **local** (Ollama `nomic-embed-text`, 3090) | free, private | + +Tools (poker, equity, journaling) only fire on the **cloud** backend — local/MI50 +models don't do reliable tool-calling here. + +## Memory & consolidation (tiers) + +Raw exchanges → per-session **gists** → a standing **profile** of Brian → monthly +**era** digests → a current **narrative** → her **self-state**. Recall is brute-force +cosine over embeddings. The **dream cycle** (`lyra/dream.py`) runs unattended and, +driven by four *drives* (continuity / coherence / curiosity / stability), summarizes +new sessions, rebuilds the profile/eras/narrative, and reflects — evolving her mood, +self-narrative, and journal between conversations. + +She **reflects in two steps** (draft → examine her own draft for flattery/drift → +revise), perceives **time** (current moment + how long since you last spoke / she last +reflected), and keeps a permanent **journal**. + +## Poker copilot + +Talk to her during a session; she drives tools behind the scenes: + +- **Session tracking** — `start_session`, `add_buyin`, `end_session` → net, hours, $/hr. +- **Hand histories** — vomit rough shorthand ("AKs btn, 3bet, flop A72…"), she + reconstructs a structured, **replayable** hand (unknown cards = `x`, never invented). +- **Villain file** — named opponents auto-build persistent dossiers; basic stats + (VPIP/PFR) emerge once a player has enough logged hands. +- **Deterministic equity** (`analyze_spot`) — exact equity / made hands / outs via a + real poker evaluator. She is *required* to use it, never eyeballs board math. +- **Stats & recaps** — `running_stats`; `generate_recap` writes her `.md` session log. + +## Web app (served by `lyra-web`, default `:7078`) + +`/` chat (Markdown, model picker, 👍/👎 rating) · `/logs` live activity · `/self` +read-her-mind (mood, drives, reflections) · `/journal` her thoughts · `/hands` +recorded hands → `/hand/{id}` replayer · `/recap/{id}` session writeup (+ `.md` export). +👍/👎 ratings on replies and thoughts are stored as `(context, content, rating)` — +a fine-tune / preference dataset built passively (`/ratings/export` → JSONL). ## Setup ```bash uv sync -cp .env.example .env -# fill in ANTHROPIC_API_KEY and point LOCAL_BASE_URL at your Ollama +cp .env.example .env # set OPENAI_API_KEY; point LOCAL_BASE_URL / MI50_BASE_URL at your boxes +uv run lyra-web # web UI on :7078 ``` -## Architecture +Run as services (reboot-resilient) — see [`deploy/`](deploy/): -The long-term target is the cognitive split in `docs/ARCH_v0-6-1.md` — Inner Self as the seat of consciousness, Executive for hard reasoning, Cortex Chat for drafting, Persona for voice. The MVP implements only the chat + memory baseline. Cognitive layers come back one at a time. +```bash +cp deploy/*.service ~/.config/systemd/user/ && systemctl --user daemon-reload +systemctl --user enable --now lyra-web.service lyra-dream.service +sudo loginctl enable-linger "$USER" # survive logout/reboot +``` + +CLIs: `lyra-dream` (one pass / `--loop`), `lyra-reflect`, `lyra-summarize`, +`lyra-profile`, `lyra-era`, `lyra-narrative`, `lyra-import` (ChatGPT history). + +## Status + +Working system. Poker copilot + full memory/dream-cycle/journal/ratings in place. +Moonshots and deferred work live in [`docs/PARKED_IDEAS.md`](docs/PARKED_IDEAS.md) +(own/fine-tuned model, self-modification sandbox, RTO/cfr-core solver tooling). +Pre-rebuild design docs are kept in [`docs/`](docs/) as history. diff --git a/pyproject.toml b/pyproject.toml index 451c31d..5e33267 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "lyra" -version = "0.1.0" +version = "0.2.0" description = "Persistent, autonomous AI assistant" readme = "README.md" requires-python = ">=3.11"