Skip to content

Commit 215b3d4

Browse files
committed
✨ feat: core engine hardening, console UX overhaul, and Pydantic v2 migration
- Pydantic v2 config with strict validation; session store abstraction (JSON + MongoDB) - Tool-use loop: synthesis on step-limit, centralized path safety, drop_params fix - Console: syntax highlighting, styled tables, responsive bubbles, resizable panels - Console: session context hydration, model badge in NavBar and per-turn footer - Chronological session ordering; docker-compose path externalization
1 parent 4f6509d commit 215b3d4

56 files changed

Lines changed: 2933 additions & 578 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.env.example

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,15 @@ MEESEEKS_CONTEXT_SELECTION=1
5959
# STEP_REFLECTION_MODEL=openai/gpt-5.2
6060

6161

62+
# * Storage Backend
63+
# - MEESEEKS_STORAGE_DRIVER: 'json' (filesystem, default) or 'mongodb'
64+
# - MEESEEKS_MONGODB_URI: MongoDB connection string (used when driver is 'mongodb')
65+
# - MEESEEKS_MONGODB_DATABASE: MongoDB database name
66+
MEESEEKS_STORAGE_DRIVER=json
67+
# MEESEEKS_MONGODB_URI=mongodb://meeseeks:password@localhost:27017/meeseeks?authSource=admin
68+
# MEESEEKS_MONGODB_DATABASE=meeseeks
69+
70+
6271
# * MCP Configuration (optional)
6372
# - MESEEKS_MCP_CONFIG: Path to MCP servers JSON config for external tools
6473
# - Manifests are auto-generated and cached under ~/.meeseeks when MESEEKS_MCP_CONFIG is set

.github/workflows/docs.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,10 @@ jobs:
3939
SHORT_SHA=$(git rev-parse --short HEAD)
4040
printf '{\"commit\":\"%s\"}\n' "$SHORT_SHA" > docs/build-info.json
4141
42-
- name: Build docs
43-
run: .venv/bin/mkdocs build
42+
- name: Generate config schema into docs/
43+
run: |
44+
.venv/bin/python scripts/ci/generate_config_schema.py || true
45+
cp configs/app.schema.json docs/app.schema.json
4446
4547
- name: Configure git for mike
4648
run: |

.github/workflows/uv-lock-refresh.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ on:
55
- cron: "0 4 * * 1"
66
workflow_dispatch:
77
push:
8+
branches: [main]
89
paths:
910
- "pyproject.toml"
1011
- "**/pyproject.toml"

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ repo-to-prompt.codemod.js
44
# MCP config (contains auth tokens)
55
.mcp.json
66

7+
# Node / JavaScript
8+
node_modules/
9+
*.tsbuildinfo
10+
711
# macOS resource forks / metadata
812
._*
913
.DS_Store
@@ -179,5 +183,6 @@ cython_debug/
179183
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
180184
#.idea/
181185
docker.env
186+
docker-compose.override.yml
182187
/.claude/settings.json
183188
/.playwright-mcp

CLAUDE.md

Lines changed: 83 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Agents Guide - Personal Assistant (Meeseeks)
22

3+
> **⚠️ MANDATORY — HYDRATE CONTEXT WITH DEEPWIKI FIRST ⚠️**
4+
>
5+
> Before reading files, writing code, or even asking clarifying questions — **use DeepWiki to hydrate yourself with project context**. This is non-negotiable. DeepWiki (`mcp__deepwiki__Deepwiki-OSS-ask_question` on `bearlike/Assistant`) gives you an instant architecture map, deep relationship understanding between components, and answers about how subsystems interact — all without reading a single file. **Do this at the start of every conversation and every non-trivial task.**
6+
>
7+
> Quick-start: `ask_question` with your task context → then `read_wiki_structure` to find relevant sections → then `read_wiki_contents` for details. Only after this should you touch local files.
8+
39
## What this codebase is
410
Meeseeks is a multi-agent LLM personal assistant with an async sub-agent hypervisor. The core engine uses a single async `ToolUseLoop` that the LLM drives via native `bind_tools` / `tool_use`. Sub-agents are spawned via a `spawn_agent` tool, tracked by an `AgentHypervisor`, and cleaned up via structured concurrency. It ships multiple interfaces (CLI, web console, REST API, Home Assistant) that share the same core engine.
511

@@ -28,25 +34,49 @@ Meeseeks is a multi-agent LLM personal assistant with an async sub-agent hypervi
2834
- `meeseeks_ha_conversation/`: Home Assistant integration
2935

3036
## How to get context fast
31-
1. Use the DeepWiki MCP tool on `bearlike/Assistant` for a fast architecture map.
32-
2. Read `README.md` and component READMEs for configuration/runtime details.
33-
3. Use `rg` to locate specific behavior and follow the exact file path.
34-
4. For CI issues, use GitHub Actions logs (GH CLI or MCP GitHub tools).
35-
36-
## MCP tools (use first for external research)
37-
When you need external context (other repos, CI failures, specs, APIs), prefer MCP tools instead of guessing.
38-
39-
### DeepWiki (`mcp__deepwiki__Deepwiki-OSS-*`)
40-
Fast AI-powered Q&A about any public GitHub repository without cloning or loading large files.
41-
- **`read_wiki_structure`**: Get the table of contents for a repo wiki. Use this first to discover what sections exist. Pass `repoName` in `owner/repo` format (e.g., `bearlike/Personal-Assistant`, `anthropics/claude-code`).
42-
- **`read_wiki_contents`**: Get the full wiki page content for a repo. Use after `read_wiki_structure` to read specific sections.
43-
- **`ask_question`**: Ask any question about a repo and get a grounded, cited answer. Supports passing a single repo or a list of up to 10 repos for cross-repo questions.
44-
- **When to use**: Architecture overviews, understanding how another project works, comparing implementations, finding specific patterns in large repos you haven't cloned.
45-
- **Tip**: Start with `read_wiki_structure` to see available topics, then use `ask_question` with targeted questions. For this project, use `bearlike/Personal-Assistant`.
37+
38+
**DeepWiki is your primary context source. Use it before touching local files.**
39+
40+
1. **DeepWiki first (always)**: Use `ask_question` on `bearlike/Assistant` to understand the area you're about to work on. Ask about architecture, data flow, component relationships, and hidden dependencies. This is faster and more comprehensive than reading files piecemeal.
41+
2. **DeepWiki wiki structure**: Use `read_wiki_structure` on `bearlike/Assistant` to discover what sections exist, then `read_wiki_contents` to read specific sections relevant to your task.
42+
3. **Cross-repo context**: When your task involves external libraries or integrations, use `ask_question` with multiple repos (up to 10) to understand compatibility and relationships between projects.
43+
4. Read `README.md` and component READMEs for configuration/runtime details.
44+
5. Use `rg` to locate specific behavior and follow the exact file path.
45+
6. For CI issues, use GitHub Actions logs (GH CLI or MCP GitHub tools).
46+
47+
**Example hydration workflow** (do this at conversation start):
48+
```
49+
# 1. Ask DeepWiki about the area you're working on
50+
ask_question(repo="bearlike/Assistant", question="How does the tool-use loop interact with the agent hypervisor?")
51+
52+
# 2. Browse wiki structure for related sections
53+
read_wiki_structure(repoName="bearlike/Assistant")
54+
55+
# 3. Read specific sections
56+
read_wiki_contents(repoName="bearlike/Assistant", page="...")
57+
58+
# 4. NOW read local files with full context
59+
```
60+
61+
## MCP tools (use first — for both internal and external context)
62+
**DeepWiki is not just for external repos — it is the fastest way to understand THIS project too.** Use `ask_question` on `bearlike/Assistant` before diving into local files. It understands component relationships, data flows, and architectural decisions that you would otherwise need to read dozens of files to piece together. When you need external context (other repos, CI failures, specs, APIs), prefer MCP tools instead of guessing.
63+
64+
### DeepWiki (`mcp__deepwiki__Deepwiki-OSS-*`) — YOUR PRIMARY CONTEXT HYDRATION TOOL
65+
Fast AI-powered Q&A about any public GitHub repository without cloning or loading large files. **This is the single most valuable tool for understanding this codebase quickly.** Use it at the start of every task to build a mental model before touching code.
66+
67+
- **`ask_question`**: Ask any question about a repo and get a grounded, cited answer. Supports passing a single repo or a list of up to 10 repos for cross-repo questions. **Use this as your first action** when starting any non-trivial task — ask about the subsystem you're about to modify, its dependencies, and how it connects to other components.
68+
- **`read_wiki_structure`**: Get the table of contents for a repo wiki. Use this to discover what sections exist and find relevant deep-dives. Pass `repoName` in `owner/repo` format (e.g., `bearlike/Assistant`, `anthropics/claude-code`).
69+
- **`read_wiki_contents`**: Get the full wiki page content for a repo. Use after `read_wiki_structure` to read specific sections for detailed context.
70+
- **When to use**:
71+
- **Start of every conversation**: Hydrate yourself with architecture context before reading files.
72+
- **Before modifying any subsystem**: Ask how it works, what depends on it, and what invariants it maintains.
73+
- **Cross-repo understanding**: Compare implementations across repos, check compatibility between libraries, understand how external projects work.
74+
- **Debugging**: Ask about expected behavior of a component before investigating what went wrong.
75+
- **Tip**: Start with `ask_question` for targeted context (e.g., "How does the ToolUseLoop handle sub-agent spawning?"), then use `read_wiki_structure``read_wiki_contents` for broader exploration. For this project, always use `bearlike/Assistant`.
4676

4777
### Devin Wiki (`mcp__devin__Devin-Wiki-Personal-*`)
4878
Devin-hosted wiki with the same structure as DeepWiki but from Devin's index. Also provides session management, knowledge notes, and scheduling.
49-
- **`read_wiki_structure`** / **`read_wiki_contents`** / **`ask_question`**: Same as DeepWiki but uses Devin's index. Use `bearlike/Personal-Assistant` for this project.
79+
- **`read_wiki_structure`** / **`read_wiki_contents`** / **`ask_question`**: Same as DeepWiki but uses Devin's index. Use `bearlike/Assistant` for this project.
5080
- **`devin_session_create`**: Spawn child Devin sessions for complex tasks. Pass `sessions: [{prompt: "...", title: "..."}]`. Returned `session_id` values need `devin-` prefix for subsequent calls.
5181
- **`devin_session_interact`**: Interact with a running session — `action: "get"` (status), `"message"` (send message), `"terminate"`, `"archive"`, `"get_messages"`, `"get_attachments"`, `"set_tags"`. Always include the `devin-` prefix on `session_id`.
5282
- **`devin_session_events`**: Inspect session event timeline — `action: "list"` (summaries), `"details"` (full content), `"search"` (full-text). Filter by `categories` (shell, file, browser, git, message, etc.) or `event_types`.
@@ -102,14 +132,48 @@ Official library/framework documentation and code examples.
102132
- **When to use**: Looking up API signatures, configuration options, or usage examples for dependencies like LangChain, Pydantic, LiteLLM, Textual, etc.
103133

104134
### General MCP investigation tips
135+
- **DeepWiki before local reads**: When starting any task, use DeepWiki `ask_question` to understand the relevant subsystem BEFORE reading local files. This gives you architectural context that makes file reads far more productive.
105136
- **Parallel queries**: When investigating, fire multiple MCP calls in parallel (e.g., DeepWiki for architecture + Langfuse for traces + SearXNG for docs).
106137
- **Cross-reference**: Use DeepWiki/Devin wiki for "how should it work" and Langfuse for "how did it actually work" during debugging.
107138
- **Session IDs bridge Meeseeks and Langfuse**: The `session_id` from `SessionStore` is the same ID used in Langfuse traces. Use it to jump between local transcript analysis and Langfuse observability.
108139
- **Trace names in Meeseeks**: Tool-use loop traces use `user_id="meeseeks-tool-use"`, planning uses `user_id="meeseeks-task-master"`, context selection uses `user_id="meeseeks-context"`. Sub-agent traces share the same session_id but have distinct agent_id tags in event payloads.
109140
- **Age parameter**: Langfuse tools use `age` in minutes (not timestamps). Common values: 60 (1h), 1440 (24h), 10080 (7 days max).
110141

111142
## Engineering principles (project-specific)
112-
- KISS and DRY: prefer small, obvious changes; remove redundancy instead of adding layers.
143+
144+
### KISS & DRY — keep the codebase lean
145+
This is the core philosophy. Every decision — from picking a dependency to writing a single function — should bias toward less code, not more. KISS means writing code that does real work at the point of definition (validates itself, constrains its inputs, encodes the logic once) so callers stay simple. DRY means that logic lives in exactly one place and everything else just calls it. These aren't just infrastructure concerns — they apply equally when writing everyday application code.
146+
147+
**What this looks like in practice:**
148+
149+
- **Research before building**: Before writing a custom solution, search for well-reputed existing libraries or tools that solve the problem. Use DeepWiki (`ask_question`) to check how similar projects handle it, SearXNG to find established packages, and Context7 to check library APIs. A well-maintained dependency with a clear API beats a hand-rolled implementation every time.
150+
- **Write code that carries its own weight**: Every function, model, or class should validate, constrain, and make sense at the point of definition — not push that burden to callers. Example: `AppConfig` uses Pydantic not just to define the config shape but to validate values at load time (`field_validator`, `ConfigDict(extra=”forbid”)`) so invalid config fails immediately instead of causing mysterious runtime errors downstream. That's KISS — the config is simple to *use* because it's smart where it's *defined*.
151+
- **Define logic once, call it everywhere**: When a piece of logic applies in multiple contexts, encode it in one place. Example: `filter_specs()` encodes allowlist/denylist tool scoping once and is called by spawn_agent, skills, and the API — not reimplemented at each call site. That's DRY.
152+
- **Prefer small, obvious changes**: The best diff is the smallest one that solves the problem. Remove redundancy instead of adding layers.
153+
- **Do not over-engineer**: No speculative abstractions, no premature generalization, no “just in case” flexibility. Build what the task requires — nothing more.
154+
- **Reuse before creating**: Check what already exists in the codebase (grep first) and in the ecosystem (search first). Only create new utilities, helpers, or abstractions when there is genuinely nothing suitable.
155+
- **Lean dependencies**: When adding a dependency, prefer well-reputed, actively maintained packages with minimal transitive dependencies. Check download counts, maintenance status, and whether the project already uses something similar. Don't add a library for something the stdlib or an existing dependency already handles.
156+
157+
**Precedents — decisions already made in this codebase that embody this philosophy:**
158+
159+
| What we needed | What we use | What we did NOT build |
160+
|---|---|---|
161+
| Multi-provider LLM calls | **LiteLLM via LangChain** (`ChatLiteLLM`) — one adapter for OpenAI, Claude, Gemini, etc. | Custom provider adapters, API client wrappers, or model routing logic |
162+
| Terminal UI (panels, spinners, layout) | **Rich** (`Console`, `Panel`, `Live`, `Syntax`) | Custom ANSI escape sequences, manual box-drawing, terminal width math |
163+
| Full-screen CLI dialogs & REPL history | **Textual** + **Prompt-toolkit** (`PromptSession`, `FileHistory`) | Custom TTY handling, modal rendering, history file management |
164+
| Data validation & serialization | **Pydantic** (`BaseModel`, `field_validator`, `ConfigDict`) | Hand-written validators, manual JSON parsing, custom schema generation |
165+
| REST API | **Flask + Flask-RESTX** | Custom HTTP server, manual route dispatch, hand-written API docs |
166+
| LLM observability & tracing | **Langfuse** (`CallbackHandler`) — plugs into LangChain callbacks | Custom telemetry pipeline, manual trace correlation |
167+
| Prompt templating | **Jinja2** (`Environment`, `PackageLoader`) | Custom string interpolation or fragile f-string assembly |
168+
| Token counting | **Tiktoken** — OpenAI's tokenizer | Heuristic character-ratio guessing |
169+
| Structured logging | **Loguru** — one-liner config with color, context, formatting | Custom log handlers, formatters, rotation logic |
170+
| MCP protocol integration | **langchain-mcp-adapters** (`MultiServerMCPClient`) | Custom MCP protocol client from scratch |
171+
| MongoDB access | **PyMongo** — connection pooling, indexing, CRUD | Custom database driver or raw socket queries |
172+
173+
The pattern: **proven library for infrastructure, custom code only for business logic** (orchestration, agent state, tool coordination). When in doubt, check if a library already does it.
174+
175+
### Other principles
176+
- **Context before code**: Use DeepWiki (`ask_question` on `bearlike/Assistant`) to understand the subsystem before modifying it. Uninformed changes waste everyone's time.
113177
- KRY: keep requirements and acceptance criteria in view; do not drift.
114178
- Keep tool contracts stable (`AbstractTool`, `ActionStep`, `TaskQueue`) and the tool field names (`tool_id`, `operation`, `tool_input`).
115179
- Favor composition and reuse across interfaces; avoid duplicating core logic.
@@ -189,6 +253,7 @@ Official library/framework documentation and code examples.
189253
- Pre-commit hooks are defined in `.pre-commit-config.yaml` (install with `make precommit-install`).
190254

191255
## Expectations for agents
192-
- Start with DeepWiki for overview, then verify details in code.
256+
- **DeepWiki first, always**: Before reading files or writing code, use DeepWiki `ask_question` on `bearlike/Assistant` to understand the area you're about to work on. Ask about architecture, data flow, component relationships, and invariants. Then verify details in local code. Skipping this step wastes time and leads to uninformed changes.
257+
- **Hydrate subagents too**: When spawning subagents or parallel agents, include instructions to use DeepWiki for context hydration in their prompts.
193258
- Keep changes minimal, readable, and well‑scoped.
194259
- Document assumptions in PRs/notes when behavior is inferred.

0 commit comments

Comments
 (0)