totem-mcp 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,315 @@
1
+ Metadata-Version: 2.3
2
+ Name: totem-mcp
3
+ Version: 0.1.0
4
+ Summary: Persistent memory layer for engineering agents
5
+ Author: Emiliano Gandini Outeda
6
+ Author-email: Emiliano Gandini Outeda <emiliano.gandini@protonmail.com>
7
+ Requires-Dist: pydantic>=2.0,<3.0
8
+ Requires-Dist: click>=8.0,<9.0
9
+ Requires-Dist: mcp>=1.0,<2.0
10
+ Requires-Dist: pyturso>=0.7.2
11
+ Requires-Python: >=3.13
12
+ Description-Content-Type: text/markdown
13
+
14
+ # totem
15
+
16
+ <p align="center">
17
+ <a href="https://pypi.org/project/totem-mcp/">
18
+ <img src="https://img.shields.io/pypi/v/totem-mcp?logo=pypi&logoColor=white&style=for-the-badge" alt="PyPI">
19
+ </a>
20
+ <a href="https://pypi.org/project/totem-mcp/">
21
+ <img src="https://img.shields.io/pypi/pyversions/totem-mcp?logo=python&logoColor=white&style=for-the-badge" alt="Python">
22
+ </a>
23
+ <a href="LICENSE">
24
+ <img src="https://img.shields.io/badge/License-MIT-10AC84?style=for-the-badge" alt="License">
25
+ </a>
26
+ <a href="https://modelcontextprotocol.io">
27
+ <img src="https://img.shields.io/badge/MCP-Compatible-8A2BE2?logo=modelcontextprotocol&logoColor=white&style=for-the-badge" alt="MCP">
28
+ </a>
29
+
30
+ </p>
31
+
32
+ Persistent memory layer for engineering agents. Store decisions, invariants, gotchas, and rejected ideas in a local Turso database with staleness detection, conflict detection, full-text search, and structured context assembly.
33
+
34
+ ## Why
35
+
36
+ AI coding agents lose engineering context between sessions. They re-discover the same gotchas, re-debate the same decisions, and forget invariants that were already established. `totem` persists this knowledge locally and serves it back to agents as structured context, ordered by relevance.
37
+
38
+ ## Features
39
+
40
+ - **Four memory types**: decision, invariant, gotcha, rejected_idea (each with type-specific metadata)
41
+ - **Staleness detection**: SHA256 content hashing on linked evidence; auto-transitions items to `potentially_stale` when source code changes
42
+ - **Conflict detection**: surfaces contradictory decisions or invariants on overlapping code ranges
43
+ - **Conflict resolution**: mark conflicts as resolved and pick a winner
44
+ - **Full-text search**: Turso FTS5 on title, statement, details, and tags
45
+ - **Hybrid memory**: project memories in `.totem/`, user memories in `~/.local/share/totem/`. Context assembly searches both.
46
+ - **Context assembly**: scored pipeline with token budget support, section ordering per spec
47
+ - **Workspace scoping**: auto-detects git root for correct DB placement; explicit `--project` override available
48
+ - **Export/import**: move memories between machines or seed a new project from an existing one
49
+ - **MCP server**: expose all tools via Model Context Protocol for agent use
50
+ - **CLI**: full command-line interface for manual operations
51
+
52
+ ## Install
53
+
54
+ Requires Python 3.13+.
55
+
56
+ ```bash
57
+ git clone https://github.com/emiliano-go/totem.git
58
+ cd totem
59
+
60
+ # With uv (recommended)
61
+ uv sync
62
+
63
+ # Or with pip
64
+ pip install .
65
+ ```
66
+
67
+ This installs two entry points: `totem` (CLI) and `totem-mcp` (MCP server).
68
+
69
+ ## Add to your agent
70
+
71
+ **Claude Code:**
72
+ ```bash
73
+ claude mcp add totem -- uvx totem-mcp
74
+ ```
75
+
76
+ **opencode** (add to `~/.config/opencode/opencode.json`):
77
+ ```json
78
+ {
79
+ "mcp": {
80
+ "totem": {
81
+ "type": "local",
82
+ "command": ["uvx", "totem-mcp"],
83
+ "enabled": true
84
+ }
85
+ }
86
+ }
87
+ ```
88
+
89
+ **Claude Desktop / Cursor / Windsurf** (add to config):
90
+ ```json
91
+ {
92
+ "mcpServers": {
93
+ "totem": {
94
+ "command": "uvx",
95
+ "args": ["totem-mcp"]
96
+ }
97
+ }
98
+ }
99
+ ```
100
+
101
+ **VS Code** (add to `.vscode/mcp.json`):
102
+ ```json
103
+ {
104
+ "servers": {
105
+ "totem": {
106
+ "type": "stdio",
107
+ "command": "uvx",
108
+ "args": ["totem-mcp"]
109
+ }
110
+ }
111
+ }
112
+ ```
113
+
114
+ **Project-scoped** (Claude Code / Cursor / opencode, checked into repo):
115
+
116
+ The included `.mcp.json` handles this automatically. Just open your project and the agent picks it up.
117
+
118
+ ## Quick start
119
+
120
+ ### MCP server
121
+
122
+ Start the server:
123
+
124
+ ```bash
125
+ totem-mcp
126
+ ```
127
+
128
+ Then use it from your agent. Example tool calls:
129
+
130
+ ```
131
+ memory_create_tool(type="invariant", title="No direct DB access in API layer",
132
+ statement="API handlers must use the repository layer, never sqlite3 directly",
133
+ tags=["api", "database"], metadata={"verificationMethod": "code review",
134
+ "condition": "No sqlite3 imports in src/api/*.py"})
135
+
136
+ engineering_context_tool(tags=["api", "database"], task="Refactor auth middleware")
137
+ ```
138
+
139
+ ### CLI
140
+
141
+ ```bash
142
+ # Create a memory item (rationale is optional but strongly recommended)
143
+ totem create --type decision --title "Use FTS5 for search" \
144
+ --statement "SQLite FTS5 is sufficient for our search needs" \
145
+ --tags "search,sqlite" --metadata '{"rationale": "No external search dependency needed"}'
146
+
147
+ # Get it back
148
+ totem get <ITEM_ID>
149
+
150
+ # Search (full-text + tags)
151
+ totem search --query "FTS5 search" --tags "sqlite"
152
+
153
+ # List recent items
154
+ totem recent
155
+
156
+ # Resolve a conflict
157
+ totem resolve <CONFLICT_ID> --resolution "Kept existing: Use FTS5"
158
+
159
+ # Export all memories to a file
160
+ totem export -o backup.json
161
+
162
+ # Import memories from a file
163
+ totem import backup.json
164
+
165
+ # Assemble context for a task
166
+ totem context --tags "search,sqlite" --task "Add fuzzy search" --budget 4096
167
+ ```
168
+
169
+ ## MCP tools
170
+
171
+ All tools return JSON strings. Every tool accepts an optional `project` parameter to override workspace scoping.
172
+
173
+ | Tool | Description |
174
+ |------|-------------|
175
+ | `memory_create_tool` | Create a memory item. Provide `rationale` in metadata for decisions (strongly recommended). |
176
+ | `memory_get_tool` | Retrieve by ID with staleness check |
177
+ | `memory_update_tool` | Update any field. Provide `reason` (strongly recommended for audit trail). |
178
+ | `memory_delete_tool` | Soft-delete (requires `reason`) |
179
+ | `memory_list_tool` | Filtered listing with `sort` param (`created_at`, `updated_at`, `importance`) |
180
+ | `memory_recent_tool` | List most recently created memories (default limit 5) |
181
+ | `memory_search_tool` | FTS5 full-text search (includes tags) with type/tag filters |
182
+ | `resolve_conflict_tool` | Mark a conflict as resolved with a resolution description |
183
+ | `engineering_context_tool` | Scored context assembly; searches project + user DBs |
184
+ | `memory_export_tool` | Export all memories and conflicts as portable JSON |
185
+ | `memory_import_tool` | Import memories from an export dict (skips duplicate IDs) |
186
+
187
+ ## CLI commands
188
+
189
+ All commands accept `--project <path>` to override workspace scoping.
190
+
191
+ | Command | Description |
192
+ |---------|-------------|
193
+ | `totem create` | Create a new memory item |
194
+ | `totem get <ID>` | Retrieve by ID (`--no-evidence` skips staleness check) |
195
+ | `totem update <ID>` | Update an item (`--reason` optional, defaults to "maintenance") |
196
+ | `totem delete <ID>` | Soft-delete (requires `--reason`) |
197
+ | `totem list` | List with `--sort` (`created_at`, `updated_at`, `importance`) and filters |
198
+ | `totem recent` | List most recently created memories (`--limit` default 5) |
199
+ | `totem resolve <ID>` | Mark a conflict as resolved (`--resolution` required) |
200
+ | `totem search` | Full-text search (includes tags) with type/tag filters |
201
+ | `totem export` | Export all memories and conflicts as JSON (`-o` for file output) |
202
+ | `totem import <FILE>` | Import memories from a JSON export file |
203
+ | `totem context` | Assemble scored context for a task |
204
+
205
+ All commands output JSON to stdout.
206
+
207
+ ## Workspace scoping
208
+
209
+ totem auto-detects your project root using `git rev-parse --show-toplevel`. The `.totem/totem.db` file is created relative to the git root, not your current working directory. This means the MCP server works correctly regardless of which subdirectory it starts in.
210
+
211
+ To override auto-detection, pass `--project <path>` on any CLI command or `project` parameter on any MCP tool.
212
+
213
+ ## Memory types
214
+
215
+ Each type captures a different kind of engineering knowledge:
216
+
217
+ | Type | Purpose | Metadata |
218
+ |------|---------|----------|
219
+ | `decision` | A choice that was made | `rationale` (optional, but strongly recommended: explain WHY) |
220
+ | `invariant` | A rule that must hold | `verificationMethod`, `condition` (required) |
221
+ | `gotcha` | A non-obvious pitfall discovered | (none) |
222
+ | `rejected_idea` | A proposal that was considered and declined | `proposal`, `reasonRejected` (required) |
223
+
224
+ ## Hybrid memory
225
+
226
+ totem stores memories in two locations:
227
+
228
+ - **Project memories**: `.totem/totem.db` (in your repo, checked into version control or gitignored)
229
+ - **User memories**: `~/.local/share/totem/totem.db` (personal preferences, global patterns)
230
+
231
+ `engineering_context` searches both databases, with project memories taking precedence. This means your agent remembers project-specific decisions and your personal coding preferences across all projects.
232
+
233
+ ## Export and import
234
+
235
+ Move memories between machines or seed a new project:
236
+
237
+ ```bash
238
+ # Export everything from the current project
239
+ totem export -o project-memories.json
240
+
241
+ # Import into a different project
242
+ cd /path/to/other-project
243
+ totem import ../project-memories.json
244
+ ```
245
+
246
+ Import skips items with duplicate IDs and reports counts of imported vs skipped items.
247
+
248
+ ## Context assembly
249
+
250
+ The `engineering_context` tool runs a scored pipeline across both project and user memories:
251
+
252
+ **Scoring formula:**
253
+ ```
254
+ score = 0.4 * tag_match + 0.3 * importance + 0.2 * confidence + 0.1 * recency
255
+ ```
256
+
257
+ Invariants get a 1.25x multiplier. Potentially stale items get a 0.5x penalty.
258
+
259
+ **Output section order (never truncated):**
260
+
261
+ 1. TASK (if provided)
262
+ 2. BLOCKING AMBIGUITIES (high/critical impact, always shown)
263
+ 3. CONFLICTS (always shown)
264
+ 4. CRITICAL INVARIANTS
265
+ 5. DECISIONS
266
+ 6. GOTCHAS
267
+ 7. REJECTED IDEAS
268
+ 8. STALE WARNINGS (always shown)
269
+
270
+ Conflicts and warnings are never dropped due to token budget. Item sections truncate when budget is exceeded, with a count of omitted items noted.
271
+
272
+ ## Data model
273
+
274
+ Core fields on every `MemoryItem`:
275
+
276
+ | Field | Type | Description |
277
+ |-------|------|-------------|
278
+ | `id` | UUID | Auto-generated primary key |
279
+ | `type` | enum | `decision`, `invariant`, `gotcha`, `rejected_idea` |
280
+ | `title` | str | Short title |
281
+ | `statement` | str | The factual claim |
282
+ | `details` | str? | Additional context |
283
+ | `tags` | list[str] | At least one required |
284
+ | `status` | enum | `active`, `potentially_stale`, `invalidated`, `deleted` |
285
+ | `confidence` | float | 0 to 1, default 1.0 |
286
+ | `importance` | float | 0 to 1, default 0.5 |
287
+ | `evidence` | list[Evidence] | Linked source code with content hashes |
288
+ | `metadata` | dict? | Type-specific keys (see memory types above) |
289
+
290
+ Evidence entries link to source code ranges with SHA256 hashes for staleness detection.
291
+
292
+ ## Companion skill
293
+
294
+ The [`skills/precision-first/`](skills/precision-first/SKILL.md) directory contains a precision-first software engineering methodology designed to pair with `totem`. It covers invariant management, ambiguity classification, contradiction detection, and structured code review workflows.
295
+
296
+ ## Development
297
+
298
+ ```bash
299
+ git clone https://github.com/emiliano-go/totem.git
300
+ cd totem
301
+ uv sync
302
+
303
+ # Run tests (none yet)
304
+ uv run pytest
305
+
306
+ # Run CLI
307
+ uv run totem --help
308
+
309
+ # Run MCP server
310
+ uv run totem-mcp
311
+ ```
312
+
313
+ ## License
314
+
315
+ MIT
@@ -0,0 +1,302 @@
1
+ # totem
2
+
3
+ <p align="center">
4
+ <a href="https://pypi.org/project/totem-mcp/">
5
+ <img src="https://img.shields.io/pypi/v/totem-mcp?logo=pypi&logoColor=white&style=for-the-badge" alt="PyPI">
6
+ </a>
7
+ <a href="https://pypi.org/project/totem-mcp/">
8
+ <img src="https://img.shields.io/pypi/pyversions/totem-mcp?logo=python&logoColor=white&style=for-the-badge" alt="Python">
9
+ </a>
10
+ <a href="LICENSE">
11
+ <img src="https://img.shields.io/badge/License-MIT-10AC84?style=for-the-badge" alt="License">
12
+ </a>
13
+ <a href="https://modelcontextprotocol.io">
14
+ <img src="https://img.shields.io/badge/MCP-Compatible-8A2BE2?logo=modelcontextprotocol&logoColor=white&style=for-the-badge" alt="MCP">
15
+ </a>
16
+
17
+ </p>
18
+
19
+ Persistent memory layer for engineering agents. Store decisions, invariants, gotchas, and rejected ideas in a local Turso database with staleness detection, conflict detection, full-text search, and structured context assembly.
20
+
21
+ ## Why
22
+
23
+ AI coding agents lose engineering context between sessions. They re-discover the same gotchas, re-debate the same decisions, and forget invariants that were already established. `totem` persists this knowledge locally and serves it back to agents as structured context, ordered by relevance.
24
+
25
+ ## Features
26
+
27
+ - **Four memory types**: decision, invariant, gotcha, rejected_idea (each with type-specific metadata)
28
+ - **Staleness detection**: SHA256 content hashing on linked evidence; auto-transitions items to `potentially_stale` when source code changes
29
+ - **Conflict detection**: surfaces contradictory decisions or invariants on overlapping code ranges
30
+ - **Conflict resolution**: mark conflicts as resolved and pick a winner
31
+ - **Full-text search**: Turso FTS5 on title, statement, details, and tags
32
+ - **Hybrid memory**: project memories in `.totem/`, user memories in `~/.local/share/totem/`. Context assembly searches both.
33
+ - **Context assembly**: scored pipeline with token budget support, section ordering per spec
34
+ - **Workspace scoping**: auto-detects git root for correct DB placement; explicit `--project` override available
35
+ - **Export/import**: move memories between machines or seed a new project from an existing one
36
+ - **MCP server**: expose all tools via Model Context Protocol for agent use
37
+ - **CLI**: full command-line interface for manual operations
38
+
39
+ ## Install
40
+
41
+ Requires Python 3.13+.
42
+
43
+ ```bash
44
+ git clone https://github.com/emiliano-go/totem.git
45
+ cd totem
46
+
47
+ # With uv (recommended)
48
+ uv sync
49
+
50
+ # Or with pip
51
+ pip install .
52
+ ```
53
+
54
+ This installs two entry points: `totem` (CLI) and `totem-mcp` (MCP server).
55
+
56
+ ## Add to your agent
57
+
58
+ **Claude Code:**
59
+ ```bash
60
+ claude mcp add totem -- uvx totem-mcp
61
+ ```
62
+
63
+ **opencode** (add to `~/.config/opencode/opencode.json`):
64
+ ```json
65
+ {
66
+ "mcp": {
67
+ "totem": {
68
+ "type": "local",
69
+ "command": ["uvx", "totem-mcp"],
70
+ "enabled": true
71
+ }
72
+ }
73
+ }
74
+ ```
75
+
76
+ **Claude Desktop / Cursor / Windsurf** (add to config):
77
+ ```json
78
+ {
79
+ "mcpServers": {
80
+ "totem": {
81
+ "command": "uvx",
82
+ "args": ["totem-mcp"]
83
+ }
84
+ }
85
+ }
86
+ ```
87
+
88
+ **VS Code** (add to `.vscode/mcp.json`):
89
+ ```json
90
+ {
91
+ "servers": {
92
+ "totem": {
93
+ "type": "stdio",
94
+ "command": "uvx",
95
+ "args": ["totem-mcp"]
96
+ }
97
+ }
98
+ }
99
+ ```
100
+
101
+ **Project-scoped** (Claude Code / Cursor / opencode, checked into repo):
102
+
103
+ The included `.mcp.json` handles this automatically. Just open your project and the agent picks it up.
104
+
105
+ ## Quick start
106
+
107
+ ### MCP server
108
+
109
+ Start the server:
110
+
111
+ ```bash
112
+ totem-mcp
113
+ ```
114
+
115
+ Then use it from your agent. Example tool calls:
116
+
117
+ ```
118
+ memory_create_tool(type="invariant", title="No direct DB access in API layer",
119
+ statement="API handlers must use the repository layer, never sqlite3 directly",
120
+ tags=["api", "database"], metadata={"verificationMethod": "code review",
121
+ "condition": "No sqlite3 imports in src/api/*.py"})
122
+
123
+ engineering_context_tool(tags=["api", "database"], task="Refactor auth middleware")
124
+ ```
125
+
126
+ ### CLI
127
+
128
+ ```bash
129
+ # Create a memory item (rationale is optional but strongly recommended)
130
+ totem create --type decision --title "Use FTS5 for search" \
131
+ --statement "SQLite FTS5 is sufficient for our search needs" \
132
+ --tags "search,sqlite" --metadata '{"rationale": "No external search dependency needed"}'
133
+
134
+ # Get it back
135
+ totem get <ITEM_ID>
136
+
137
+ # Search (full-text + tags)
138
+ totem search --query "FTS5 search" --tags "sqlite"
139
+
140
+ # List recent items
141
+ totem recent
142
+
143
+ # Resolve a conflict
144
+ totem resolve <CONFLICT_ID> --resolution "Kept existing: Use FTS5"
145
+
146
+ # Export all memories to a file
147
+ totem export -o backup.json
148
+
149
+ # Import memories from a file
150
+ totem import backup.json
151
+
152
+ # Assemble context for a task
153
+ totem context --tags "search,sqlite" --task "Add fuzzy search" --budget 4096
154
+ ```
155
+
156
+ ## MCP tools
157
+
158
+ All tools return JSON strings. Every tool accepts an optional `project` parameter to override workspace scoping.
159
+
160
+ | Tool | Description |
161
+ |------|-------------|
162
+ | `memory_create_tool` | Create a memory item. Provide `rationale` in metadata for decisions (strongly recommended). |
163
+ | `memory_get_tool` | Retrieve by ID with staleness check |
164
+ | `memory_update_tool` | Update any field. Provide `reason` (strongly recommended for audit trail). |
165
+ | `memory_delete_tool` | Soft-delete (requires `reason`) |
166
+ | `memory_list_tool` | Filtered listing with `sort` param (`created_at`, `updated_at`, `importance`) |
167
+ | `memory_recent_tool` | List most recently created memories (default limit 5) |
168
+ | `memory_search_tool` | FTS5 full-text search (includes tags) with type/tag filters |
169
+ | `resolve_conflict_tool` | Mark a conflict as resolved with a resolution description |
170
+ | `engineering_context_tool` | Scored context assembly; searches project + user DBs |
171
+ | `memory_export_tool` | Export all memories and conflicts as portable JSON |
172
+ | `memory_import_tool` | Import memories from an export dict (skips duplicate IDs) |
173
+
174
+ ## CLI commands
175
+
176
+ All commands accept `--project <path>` to override workspace scoping.
177
+
178
+ | Command | Description |
179
+ |---------|-------------|
180
+ | `totem create` | Create a new memory item |
181
+ | `totem get <ID>` | Retrieve by ID (`--no-evidence` skips staleness check) |
182
+ | `totem update <ID>` | Update an item (`--reason` optional, defaults to "maintenance") |
183
+ | `totem delete <ID>` | Soft-delete (requires `--reason`) |
184
+ | `totem list` | List with `--sort` (`created_at`, `updated_at`, `importance`) and filters |
185
+ | `totem recent` | List most recently created memories (`--limit` default 5) |
186
+ | `totem resolve <ID>` | Mark a conflict as resolved (`--resolution` required) |
187
+ | `totem search` | Full-text search (includes tags) with type/tag filters |
188
+ | `totem export` | Export all memories and conflicts as JSON (`-o` for file output) |
189
+ | `totem import <FILE>` | Import memories from a JSON export file |
190
+ | `totem context` | Assemble scored context for a task |
191
+
192
+ All commands output JSON to stdout.
193
+
194
+ ## Workspace scoping
195
+
196
+ totem auto-detects your project root using `git rev-parse --show-toplevel`. The `.totem/totem.db` file is created relative to the git root, not your current working directory. This means the MCP server works correctly regardless of which subdirectory it starts in.
197
+
198
+ To override auto-detection, pass `--project <path>` on any CLI command or `project` parameter on any MCP tool.
199
+
200
+ ## Memory types
201
+
202
+ Each type captures a different kind of engineering knowledge:
203
+
204
+ | Type | Purpose | Metadata |
205
+ |------|---------|----------|
206
+ | `decision` | A choice that was made | `rationale` (optional, but strongly recommended: explain WHY) |
207
+ | `invariant` | A rule that must hold | `verificationMethod`, `condition` (required) |
208
+ | `gotcha` | A non-obvious pitfall discovered | (none) |
209
+ | `rejected_idea` | A proposal that was considered and declined | `proposal`, `reasonRejected` (required) |
210
+
211
+ ## Hybrid memory
212
+
213
+ totem stores memories in two locations:
214
+
215
+ - **Project memories**: `.totem/totem.db` (in your repo, checked into version control or gitignored)
216
+ - **User memories**: `~/.local/share/totem/totem.db` (personal preferences, global patterns)
217
+
218
+ `engineering_context` searches both databases, with project memories taking precedence. This means your agent remembers project-specific decisions and your personal coding preferences across all projects.
219
+
220
+ ## Export and import
221
+
222
+ Move memories between machines or seed a new project:
223
+
224
+ ```bash
225
+ # Export everything from the current project
226
+ totem export -o project-memories.json
227
+
228
+ # Import into a different project
229
+ cd /path/to/other-project
230
+ totem import ../project-memories.json
231
+ ```
232
+
233
+ Import skips items with duplicate IDs and reports counts of imported vs skipped items.
234
+
235
+ ## Context assembly
236
+
237
+ The `engineering_context` tool runs a scored pipeline across both project and user memories:
238
+
239
+ **Scoring formula:**
240
+ ```
241
+ score = 0.4 * tag_match + 0.3 * importance + 0.2 * confidence + 0.1 * recency
242
+ ```
243
+
244
+ Invariants get a 1.25x multiplier. Potentially stale items get a 0.5x penalty.
245
+
246
+ **Output section order (never truncated):**
247
+
248
+ 1. TASK (if provided)
249
+ 2. BLOCKING AMBIGUITIES (high/critical impact, always shown)
250
+ 3. CONFLICTS (always shown)
251
+ 4. CRITICAL INVARIANTS
252
+ 5. DECISIONS
253
+ 6. GOTCHAS
254
+ 7. REJECTED IDEAS
255
+ 8. STALE WARNINGS (always shown)
256
+
257
+ Conflicts and warnings are never dropped due to token budget. Item sections truncate when budget is exceeded, with a count of omitted items noted.
258
+
259
+ ## Data model
260
+
261
+ Core fields on every `MemoryItem`:
262
+
263
+ | Field | Type | Description |
264
+ |-------|------|-------------|
265
+ | `id` | UUID | Auto-generated primary key |
266
+ | `type` | enum | `decision`, `invariant`, `gotcha`, `rejected_idea` |
267
+ | `title` | str | Short title |
268
+ | `statement` | str | The factual claim |
269
+ | `details` | str? | Additional context |
270
+ | `tags` | list[str] | At least one required |
271
+ | `status` | enum | `active`, `potentially_stale`, `invalidated`, `deleted` |
272
+ | `confidence` | float | 0 to 1, default 1.0 |
273
+ | `importance` | float | 0 to 1, default 0.5 |
274
+ | `evidence` | list[Evidence] | Linked source code with content hashes |
275
+ | `metadata` | dict? | Type-specific keys (see memory types above) |
276
+
277
+ Evidence entries link to source code ranges with SHA256 hashes for staleness detection.
278
+
279
+ ## Companion skill
280
+
281
+ The [`skills/precision-first/`](skills/precision-first/SKILL.md) directory contains a precision-first software engineering methodology designed to pair with `totem`. It covers invariant management, ambiguity classification, contradiction detection, and structured code review workflows.
282
+
283
+ ## Development
284
+
285
+ ```bash
286
+ git clone https://github.com/emiliano-go/totem.git
287
+ cd totem
288
+ uv sync
289
+
290
+ # Run tests (none yet)
291
+ uv run pytest
292
+
293
+ # Run CLI
294
+ uv run totem --help
295
+
296
+ # Run MCP server
297
+ uv run totem-mcp
298
+ ```
299
+
300
+ ## License
301
+
302
+ MIT
@@ -0,0 +1,24 @@
1
+ [project]
2
+ name = "totem-mcp"
3
+ version = "0.1.0"
4
+ description = "Persistent memory layer for engineering agents"
5
+ readme = "README.md"
6
+ requires-python = ">=3.13"
7
+ dependencies = [
8
+ "pydantic>=2.0,<3.0",
9
+ "click>=8.0,<9.0",
10
+ "mcp>=1.0,<2.0",
11
+ "pyturso>=0.7.2",
12
+ ]
13
+
14
+ [[project.authors]]
15
+ name = "Emiliano Gandini Outeda"
16
+ email = "emiliano.gandini@protonmail.com"
17
+
18
+ [project.scripts]
19
+ totem = "totem_mcp.cli:main"
20
+ totem-mcp = "totem_mcp.cli:mcp_main"
21
+
22
+ [build-system]
23
+ requires = ["uv_build>=0.12.5,<0.13.0"]
24
+ build-backend = "uv_build"
@@ -0,0 +1,23 @@
1
+ [project]
2
+ name = "totem-mcp"
3
+ version = "0.1.0"
4
+ description = "Persistent memory layer for engineering agents"
5
+ readme = "README.md"
6
+ authors = [
7
+ { name = "Emiliano Gandini Outeda", email = "emiliano.gandini@protonmail.com" }
8
+ ]
9
+ requires-python = ">=3.13"
10
+ dependencies = [
11
+ "pydantic>=2.0,<3.0",
12
+ "click>=8.0,<9.0",
13
+ "mcp>=1.0,<2.0",
14
+ "pyturso>=0.7.2",
15
+ ]
16
+
17
+ [project.scripts]
18
+ totem = "totem_mcp.cli:main"
19
+ totem-mcp = "totem_mcp.cli:mcp_main"
20
+
21
+ [build-system]
22
+ requires = ["uv_build>=0.12.5,<0.13.0"]
23
+ build-backend = "uv_build"
@@ -0,0 +1,3 @@
1
+ """totem: persistent memory for engineering agents."""
2
+
3
+ __version__ = "0.1.0"
@@ -0,0 +1,3 @@
1
+ from .server import main
2
+
3
+ main()