Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ build/
*.jsonl
!tests/fixtures/**/*.jsonl
.env
.coverage
20 changes: 17 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ memories ("you prefer direct, practical feedback"), keeps the exact quote each o
and serves only what you allow back to your assistants over MCP. Everything runs on your own
machine. There is no PersonaKit server and no account.

> **Status: pre-release (0.1 in progress).** This repository is being built in public.
> **Status: pre-release (0.2 in progress).** This repository is being built in public.
> See [docs/ROADMAP.md](docs/ROADMAP.md) for what exists and what is planned.

## Why PersonaKit
Expand All @@ -53,11 +53,14 @@ personakit sweep --cli claude --model <model-name> --max-calls 20 # read sessi
personakit review # optional: approve, restrict, hide, forget
personakit list # see what is stored
personakit stats # counts only, never memory text
personakit tidy # plan: fold same-session twins, archive stale memories
personakit tidy --apply # carry the plan out (reverse any step with `personakit undo <id>`)
personakit digest # what changed in the last 7 days (local, prints memory text)
personakit serve # MCP server over stdio for your assistants
personakit forget <memory-id> # delete a memory and its quotes for good
```

`sweep`, `list` and `stats` also take `--json` for stable, sorted machine-readable output.
`sweep`, `list`, `stats`, `tidy` and `digest` also take `--json` for stable, sorted machine-readable output.

The model name is always yours to choose. Nothing leaves your machine except the turns you wrote,
sent to the model you named. See [docs/PRIVACY.md](docs/PRIVACY.md).
Expand Down Expand Up @@ -101,6 +104,9 @@ Your assistant gets two tools:
4. **Review** is optional. Memories you never review are served marked *unconfirmed*; you
can approve, restrict, hide or forget any of them at any time.
5. **Serve** exposes the store to assistants over MCP, with the evidence attached.
6. **Tidy** (on request) folds near-identical memories from the same session into one, and
archives unconfirmed memories not seen again for 90 days. It shows a plan first; nothing
changes without `--apply`, nothing is deleted, and `personakit undo <id>` reverses a step.

A memory is always in one of four states:

Expand All @@ -111,7 +117,7 @@ A memory is always in one of four states:
| `restricted` | Never |
| `archived` | Never |

## Limits in 0.1
## Limits in 0.2

Stated plainly, so you know what you are installing:

Expand All @@ -120,6 +126,12 @@ Stated plainly, so you know what you are installing:
in other scripts are not matched yet; approved memories are still returned as standing context.
- **A decision cannot be changed, only undone by forgetting.** `review` shows unconfirmed memories;
there is no command yet to edit a memory's wording or move a decided memory to another state.
- **Twin detection compares words, not meaning.** It folds memories phrased almost the same way,
from the same session, and misses paraphrases on purpose: a missed merge costs nothing, a wrong
one costs trust. Memories from different sessions are never merged.
- **Decay looks only at time.** An unconfirmed memory not extracted again for 90 days is archived
(reversible); that says nothing about whether it is still true. Approved and restricted
memories never decay.
- **A memory an assistant already received stays in that conversation.** Restricting it applies to
future reads.
- **Paste and credential detection is by shape**, not by meaning. Look before you share a store.
Expand All @@ -131,13 +143,15 @@ Stated plainly, so you know what you are installing:
| Claude Code sessions | Available in 0.1 |
| Codex sessions | Available in 0.1 |
| Any MCP client (read and propose) | Available in 0.1 |
| Merge same-session twins, decay stale memories, weekly digest | Available in 0.2 |
| ChatGPT, claude.ai and Gemini export import | Planned for 0.3 |

## Documentation

- [personakit.me/docs](https://personakit.me/docs/): guides, concepts, and the MCP tools reference.
- [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md): the design, module by module.
- [docs/PRIVACY.md](docs/PRIVACY.md): exactly what is sent where.
- [docs/PLUGINS.md](docs/PLUGINS.md): the two extension points and what a plugin cannot do.
- [docs/ROADMAP.md](docs/ROADMAP.md): what exists and what is planned.

## Contributing
Expand Down
37 changes: 31 additions & 6 deletions docs/ARCHITECTURE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Architecture (v0.1 design)
# Architecture (v0.2 design)

PersonaKit is a small local pipeline with one database. Each stage has one job and talks to
the next only through the store.
Expand All @@ -17,6 +17,8 @@ flowchart TB
RV[review: CLI]
MCP[mcp_server]
SS[stats: local counts]
TD[tidy: twins + decay, on request]
DG[digest: last days, local]
end
CC --> IN
CX --> IN
Expand All @@ -26,6 +28,8 @@ flowchart TB
ST <--> RV
ST --> MCP
ST --> SS
ST <--> TD
ST --> DG
MCP --> AS[Assistants]
```

Expand All @@ -42,6 +46,11 @@ flowchart TB
| `store` | The only module that touches SQLite. Schema, migrations, queries, state changes. | `model` |
| `review` | Terminal UI over the store: approve, restrict, hide, forget. Optional by design. | `store` |
| `mcp_server` | Two tools for assistants: `personakit_read` and `personakit_propose`. Holds no read-policy constants of its own. Assistants cannot approve, restrict, hide or forget; only the owner can, in `review`. | `store`, `retrieve`, `extract` |
| `twins` | Finds near-identical unconfirmed memories that rest on the same single session. Word-based, deliberately cautious (numbers, negation and the order of shared words must agree). Pure functions. | `model`, `retrieve` |
| `decay` | Finds unconfirmed memories not seen again for a long time (90 days by default). Pure functions. | `model` |
| `tidy` | Turns `twins` and `decay` into a plan (read-only), applies it only on request, and reverses single steps. | `twins`, `decay`, `store` |
| `digest` | A summary of the last days: new, merged and archived memories, what awaits review, read counts. Prints memory text, never quotes, to your terminal only. | `store`, `decay` |
| `plugins` | Two extension points, `relevance` and `similarity`, loaded only when the owner names them in `PERSONAKIT_PLUGINS`. A plugin scores; policy stays in `retrieve`, `twins` and `store`. See [PLUGINS.md](PLUGINS.md). | `retrieve`, `twins` |
| `stats` | Counts only (memories by state, sessions extracted, reads and how many returned something). Never content. | `store` |
| `cli` | Argument parsing and wiring; no logic. | all |

Expand All @@ -51,7 +60,12 @@ model, only `ingest` reads session files.** A second implementation of any of th
## Data model

- **Turn**: `(source, session_id, index, timestamp, text)`. Only owner-authored turns exist here.
- **Memory**: `id, text, category, scope, state, created_at, decided_at, decided_by`.
- **Memory**: `id, text, category, scope, state, created_at, last_seen_at, decided_at, decided_by`.
`last_seen_at` moves forward each time the same statement is extracted again.
- **Merge**: a folded memory keeps its own row and evidence and points at the memory it was folded
into (`merged_into`, `merged_at`). It is not listed or served on its own; the surviving memory
shows the evidence of both. `undo` clears the pointer, so it is exact, and remembers the pair so
it is not proposed again. `forget` on either memory removes that memory's rows for good.
- **Evidence**: `memory_id, session_id, turn_index, quote`. Every memory has at least one.
- **State**: `unconfirmed` (default, served with a label) -> `approved` | `restricted` |
`archived`. Nothing is ever hard-deleted without an explicit `forget` by the owner.
Expand All @@ -60,13 +74,24 @@ model, only `ingest` reads session files.** A second implementation of any of th

1. A memory with no evidence is not stored.
2. Unconfirmed memories are served, labelled as unconfirmed. Review is a quality tool, not a gate.
3. The system never changes a memory's state or deletes a memory on its own. Extracting the same
statement again adds evidence to the existing memory and leaves your decision alone. Merging
near-duplicates and archiving stale items are planned for 0.2 and will be reversible.
3. The system never deletes a memory, and never touches a memory you have decided on. Extracting
the same statement again adds evidence to the existing memory and leaves your decision alone.
Two things change unconfirmed memories, and only when you run `personakit tidy --apply`
(the default is a plan that changes nothing): folding same-session twins together, and
archiving memories not seen again for 90 days. Both are reversible with `personakit undo <id>`.
A memory that decay archived comes back by itself if the statement is extracted again from
your own words. An assistant proposing the same text does not bring it back and does not
reset its age.
4. Only text the owner wrote is sent to a model.
5. Statistics are counts, never content, and are local unless the owner chooses to share them.

## Out of scope for 0.1
## Out of scope for now

Hosted service, accounts, sync, ChatGPT/Gemini/claude.ai import and third-party name detection.
See the roadmap for what is planned.

## Limits in 0.2

Twin detection compares words, not meaning. It catches the same statement phrased almost the
same way and misses paraphrases; it is built to miss rather than to merge wrongly. Decay looks
only at how long ago a statement was last extracted, not at whether it is still true.
54 changes: 54 additions & 0 deletions docs/PLUGINS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Plugins

PersonaKit has two extension points. Both replace a scoring function and nothing else.

| Hook | Signature | Built-in | Used by |
|---|---|---|---|
| `relevance` | `(question: str, memories: Sequence[Memory]) -> Sequence[float]` | word overlap | `personakit serve` (which memories answer a question, and in what order) |
| `similarity` | `(a: str, b: str) -> float` between 0 and 1 | shared words, with number, negation and order guards | `personakit tidy` (which same-session memories are twins) |

## What a plugin cannot do

Policy stays in the core, whatever a plugin returns:

- Restricted and archived memories are never served. A relevance score only orders what the read
policy already allows.
- Only unconfirmed memories from the same single session, with the same category and scope, can
be proposed as twins. Merging still needs `personakit tidy --apply` and is reversible.
- No hook can approve, restrict, archive, restore or forget.

A plugin is still Python code running as you, with access to your store file. Enable only
plugins you trust and have read.

## Enabling one

Nothing is loaded just because it is installed. Name the plugins you want:

```sh
pip install some-personakit-plugin
export PERSONAKIT_PLUGINS=some-name # comma separated for several, applied in order
personakit tidy
```

A name that is not installed is an error, not a silent fallback.

## Writing one

Register a function in the `personakit.plugins` entry-point group. It receives a `Hooks` object
and replaces what it provides:

```toml
# pyproject.toml of the plugin
[project.entry-points."personakit.plugins"]
some-name = "some_package:register"
```

```python
# some_package/__init__.py
def register(hooks):
hooks.similarity = my_similarity # leave hooks.relevance alone to keep the built-in
```

For anything beyond scoring, use PersonaKit as a library: `personakit.store.Store` is the one
place that reads and writes the database, and `Store.merge`, `Store.undo_merge`,
`Store.set_state` and `Store.restore` are the same reversible operations the CLI uses.
11 changes: 11 additions & 0 deletions docs/PRIVACY.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,14 @@
- **Statistics:** `personakit stats` prints counts to your terminal. It never includes memory text.
Sharing the output is your choice.
- **Deletion:** `personakit forget` removes a memory and its evidence from the store.
- **Tidy and undo:** `personakit tidy` reads your store and, only with `--apply`, folds
near-identical memories together and archives stale ones. A folded memory stays in your store
with its own quotes, so `personakit undo` restores it exactly. `personakit forget` on a folded
memory deletes it and every quote it brought; `forget` on the memory it was folded into deletes
both, since they are the same statement. Nothing leaves your machine, and nothing here calls a
model. Assistants cannot merge, undo, archive or restore.
- **Digest:** `personakit digest` prints memory ids and text (never evidence quotes) to your
terminal. Unlike `stats` it is not counts-only, so look before pasting it anywhere.
- **Plugins:** none are loaded unless you name them in `PERSONAKIT_PLUGINS`. A plugin replaces
how relevance or similarity is scored and cannot change what is served or merged, but it is code
you installed, running as you. What it does with your data is up to that plugin; read it first.
5 changes: 5 additions & 0 deletions docs/REVIEW-LOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,8 @@ duplicated logic. Each entry records the result.
| `personakit/store.py` (changes) | 2026-11-08 | added `reads` table via migration 2; list order now insertion order | clean |
| `personakit/extract.py` (changes) | 2026-11-08 | shared text checks moved into `text_problem` so extraction and assistant proposals use one rule | clean |
| `tests/*` (new) | 2026-11-08 | invented data; a key-shaped string is assembled at runtime | clean |
| `personakit/twins.py`, `decay.py`, `tidy.py`, `digest.py` | 2026-11-13 | none; written for this repository, word-based only (no model call), thresholds chosen from invented examples; no ids or text from any real store | clean |
| `personakit/store.py`, `model.py`, `retrieve.py`, `review.py`, `cli.py` (0.2 changes) | 2026-11-13 | migration 3 (`last_seen_at`, `merged_into`, `merge_vetoes`); a folded memory keeps its own rows, so forget leaves nothing behind; assistant proposals cannot revive or refresh a memory; `PROPOSED_BY_ASSISTANT` moved to `model` | clean |
| `tests/test_twins.py`, `test_decay.py`, `test_merge_store.py`, `test_tidy.py`, `test_cli.py` (changes) | 2026-11-13 | invented sentences only | clean |
| 0.2 changes, second pass | 2026-11-14 | security and code review run on the branch: quotes could outlive `forget` through chained merges, an assistant proposal could revive a decay-archived memory, short words and typographic apostrophes slipped past twin checks. All fixed, each with a regression test | clean |
| `personakit/plugins.py`, `docs/PLUGINS.md`, `tests/test_plugins.py` | 2026-11-14 | none; opt-in by name, scoring only, policy tests prove a plugin cannot widen what is served or merged | clean |
2 changes: 1 addition & 1 deletion docs/ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
| Release | Scope | Target |
|---|---|---|
| 0.1 | Claude Code + Codex ingest, extract, store, CLI review, MCP server, local stats | day 10 |
| 0.2 | Merge same-session duplicates (reversible), weekly digest, decay to archive | day 14 |
| 0.2 | Merge same-session duplicates (reversible), weekly digest, decay to archive | in review |
| 0.3 | Import from ChatGPT / claude.ai / Gemini exports | after launch |
| 0.4 | Third-party name guard | after launch |

Expand Down
Loading
Loading