Metadata-Version: 2.3
Name: takopi-memory
Version: 0.1.0
Summary: Cross-session memory engine plugin for Takopi.
Keywords: takopi,memory,engine,plugin
Author: takopi contributors
License: MIT License
         
         Copyright (c) 2026 takopi contributors
         
         Permission is hereby granted, free of charge, to any person obtaining a copy
         of this software and associated documentation files (the "Software"), to deal
         in the Software without restriction, including without limitation the rights
         to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
         copies of the Software, and to permit persons to whom the Software is
         furnished to do so, subject to the following conditions:
         
         The above copyright notice and this permission notice shall be included in all
         copies or substantial portions of the Software.
         
         THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
         IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
         FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
         AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
         LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
         OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
         SOFTWARE.
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Operating System :: OS Independent
Requires-Dist: takopi>=0.22,<0.23
Requires-Python: >=3.14
Project-URL: Homepage, https://github.com/banteg/takopi
Project-URL: Repository, https://github.com/richardliang/takopi-memory
Description-Content-Type: text/markdown

# takopi-memory

A Takopi engine plugin that adds cross-session memory on top of an existing engine.

It is inspired by OpenClaw's file-first memory model:
- persistent memories in project files,
- relevance-based retrieval each turn,
- write-back after each completed response.

## What it does

When you set `memory` as your engine:
1. It reads prior memory records from disk.
2. It retrieves the most relevant records for the current prompt.
3. It prepends a compact "recalled memory" block to the prompt sent to the base engine.
4. It stores a new memory record after each completed run.

Memory is persisted under `.takopi/memory` (by default) next to your `takopi.toml`.

## Install

```sh
uv pip install takopi-memory
```

## Configure

Set Takopi to use the `memory` engine and choose the wrapped base engine.

```toml
default_engine = "memory"

[memory]
base_engine = "codex"
store_dir = ".takopi/memory"
max_results = 6
scan_limit = 500
snippet_chars = 240
max_prompt_chars = 2800
persist_failures = false
persist_empty_answers = false
min_score = 0.08
```

## Config reference

- `base_engine` (string, default: `"codex"`): underlying engine id to run.
- `store_dir` (string, default: `".takopi/memory"`): relative to config directory unless absolute.
- `max_results` (int, default: `6`): max recalled memories injected per prompt.
- `scan_limit` (int, default: `500`): max recent records scanned at retrieval time.
- `snippet_chars` (int, default: `240`): max characters shown per recalled memory.
- `max_prompt_chars` (int, default: `2800`): max total memory block size injected.
- `persist_failures` (bool, default: `false`): store failed runs too.
- `persist_empty_answers` (bool, default: `false`): store runs with empty answers.
- `min_score` (float, default: `0.08`): minimum retrieval score threshold.

## Memory files

- `memories.jsonl`: compact memory records used for retrieval.
- `sessions.jsonl`: full prompt/answer journal for audit and deeper debugging.

## Notes

- The plugin does not call external vector databases; everything is file-based.
- Retrieval is lexical+recency scoring for deterministic behavior.
- If memory write fails, the run still completes; a warning action event is emitted.
