Complete the module consolidation planned in REFACTORING_PLAN.md: Modules merged: - work_orders/ + task_queue/ → swarm/ (subpackages) - self_modify/ + self_tdd/ + upgrades/ → self_coding/ (subpackages) - tools/ → creative/tools/ - chat_bridge/ + telegram_bot/ + shortcuts/ + voice/ → integrations/ (new) - ws_manager/ + notifications/ + events/ + router/ → infrastructure/ (new) - agents/ + agent_core/ + memory/ → timmy/ (subpackages) Updated across codebase: - 66 source files: import statements rewritten - 13 test files: import + patch() target strings rewritten - pyproject.toml: wheel includes (28→14), entry points updated - CLAUDE.md: singleton paths, module map, entry points table - AGENTS.md: file convention updates - REFACTORING_PLAN.md: execution status, success metrics Extras: - Module-level CLAUDE.md added to 6 key packages (Phase 6.2) - Zero test regressions: 1462 tests passing https://claude.ai/code/session_01JNjWfHqusjT3aiN4vvYgUk
3.7 KiB
3.7 KiB
CLAUDE.md — AI Assistant Guide for Timmy Time
Tech stack: Python 3.11+ · FastAPI · Jinja2 + HTMX · SQLite · Agno · Ollama · pydantic-settings · WebSockets · Docker
For agent roster and conventions, see AGENTS.md.
Architecture Patterns
Config access
from config import settings
url = settings.ollama_url # never use os.environ.get() directly in app code
Singletons
from dashboard.store import message_log
from infrastructure.notifications.push import notifier
from infrastructure.ws_manager.handler import ws_manager
from swarm.coordinator import coordinator
HTMX response pattern
return templates.TemplateResponse(
"partials/chat_message.html",
{"request": request, "role": "user", "content": message}
)
Graceful degradation
Optional services (Ollama, Redis, AirLLM) degrade gracefully — log the error, return a fallback, never crash.
Route registration
New routes: src/dashboard/routes/<name>.py → register in src/dashboard/app.py.
Testing
make test # Quick run (no Ollama needed)
make test-cov # With coverage (term-missing + XML)
- Stubs in conftest:
agno,airllm,pyttsx3,telegram,discordstubbed viasys.modules.setdefault()— tests run without those packages - Test mode:
TIMMY_TEST_MODE=1set automatically in conftest - FastAPI testing: Use the
clientfixture - Async:
asyncio_mode = "auto"— async tests detected automatically - Coverage threshold: 60% (
fail_underinpyproject.toml)
Key Conventions
- Tests must stay green. Run
make testbefore committing. - No cloud AI dependencies. All inference on localhost.
- Keep the root directory clean. No new top-level files without purpose.
- Follow existing patterns — singletons, graceful degradation, pydantic config.
- Security defaults: Never hard-code secrets.
- XSS prevention: Never use
innerHTMLwith untrusted content. - Keep routes thin — business logic lives in the module, not the route.
- Prefer editing existing files over creating new ones.
- Use
from config import settingsfor all env-var access.
Security-Sensitive Areas
src/swarm/coordinator.py— requires review before changessrc/timmy_serve/l402_proxy.py— Lightning payment gatingsrc/lightning/— payment backend abstraction- Any file handling secrets or authentication tokens
Entry Points
| Command | Module | Purpose |
|---|---|---|
timmy |
src/timmy/cli.py |
Chat, think, status |
timmy-serve |
src/timmy_serve/cli.py |
L402-gated API server (port 8402) |
self-tdd |
src/self_coding/self_tdd/watchdog.py |
Continuous test watchdog |
self-modify |
src/self_coding/self_modify/cli.py |
Self-modification CLI |
Module Map (14 packages)
| Package | Purpose |
|---|---|
timmy/ |
Core agent, personas, agent interface, semantic memory |
dashboard/ |
FastAPI web UI, routes, templates |
swarm/ |
Multi-agent coordinator, task queue, work orders |
self_coding/ |
Self-modification, test watchdog, upgrade queue |
creative/ |
Media generation, MCP tools |
infrastructure/ |
WebSocket, notifications, events, LLM router |
integrations/ |
Discord, Telegram, Siri Shortcuts, voice NLU |
lightning/ |
L402 payment gating (security-sensitive) |
mcp/ |
MCP tool registry and discovery |
spark/ |
Event capture and advisory engine |
hands/ |
6 autonomous Hand agents |
scripture/ |
Biblical text integration |
timmy_serve/ |
L402-gated API server |
config.py |
Pydantic settings (foundation for all modules) |