|
| 1 | +# AGENTS.md |
| 2 | + |
| 3 | +> How to build, test, and contribute to MemPalace. |
| 4 | +
|
| 5 | +## Setup |
| 6 | + |
| 7 | +```bash |
| 8 | +pip install -e ".[dev]" |
| 9 | +``` |
| 10 | + |
| 11 | +## Commands |
| 12 | + |
| 13 | +```bash |
| 14 | +# Run tests |
| 15 | +python -m pytest tests/ -v --ignore=tests/benchmarks |
| 16 | + |
| 17 | +# Run tests with coverage |
| 18 | +python -m pytest tests/ -v --ignore=tests/benchmarks --cov=mempalace --cov-report=term-missing |
| 19 | + |
| 20 | +# Lint |
| 21 | +ruff check . |
| 22 | + |
| 23 | +# Format |
| 24 | +ruff format . |
| 25 | + |
| 26 | +# Format check (CI mode) |
| 27 | +ruff format --check . |
| 28 | +``` |
| 29 | + |
| 30 | +## Project structure |
| 31 | + |
| 32 | +``` |
| 33 | +mempalace/ |
| 34 | +├── mcp_server.py # MCP server — all read/write tools |
| 35 | +├── miner.py # Project file miner |
| 36 | +├── convo_miner.py # Conversation transcript miner |
| 37 | +├── searcher.py # Semantic search |
| 38 | +├── knowledge_graph.py # Temporal entity-relationship graph (SQLite) |
| 39 | +├── palace.py # Shared palace operations (ChromaDB access) |
| 40 | +├── config.py # Configuration + input validation |
| 41 | +├── normalize.py # Transcript format detection + normalization |
| 42 | +├── cli.py # CLI dispatcher |
| 43 | +├── dialect.py # AAAK compression dialect |
| 44 | +├── palace_graph.py # Room traversal + cross-wing tunnels |
| 45 | +├── hooks_cli.py # Hook system for auto-save |
| 46 | +└── version.py # Single source of truth for version |
| 47 | +``` |
| 48 | + |
| 49 | +## Conventions |
| 50 | + |
| 51 | +- **Python style**: snake_case for functions/variables, PascalCase for classes |
| 52 | +- **Linter**: ruff with E/F/W rules |
| 53 | +- **Formatter**: ruff format, double quotes |
| 54 | +- **Commits**: conventional commits (`fix:`, `feat:`, `test:`, `docs:`, `ci:`) |
| 55 | +- **Tests**: `tests/test_*.py`, fixtures in `tests/conftest.py` |
| 56 | +- **Coverage**: 85% threshold (80% on Windows due to ChromaDB file lock cleanup) |
| 57 | + |
| 58 | +## Architecture |
| 59 | + |
| 60 | +``` |
| 61 | +User → CLI / MCP Server → ChromaDB (vector store) + SQLite (knowledge graph) |
| 62 | +
|
| 63 | +Palace structure: |
| 64 | + WING (person/project) |
| 65 | + └── ROOM (topic) |
| 66 | + └── DRAWER (verbatim text chunk) |
| 67 | +
|
| 68 | +Knowledge Graph: |
| 69 | + ENTITY → PREDICATE → ENTITY (with valid_from / valid_to dates) |
| 70 | +``` |
| 71 | + |
| 72 | +## Key files for common tasks |
| 73 | + |
| 74 | +- **Adding an MCP tool**: `mempalace/mcp_server.py` — add handler function + TOOLS dict entry |
| 75 | +- **Changing search**: `mempalace/searcher.py` |
| 76 | +- **Modifying mining**: `mempalace/miner.py` (project files) or `mempalace/convo_miner.py` (transcripts) |
| 77 | +- **Input validation**: `mempalace/config.py` — `sanitize_name()` / `sanitize_content()` |
| 78 | +- **Tests**: mirror source structure in `tests/test_<module>.py` |
0 commit comments