Metadata-Version: 2.4
Name: koi-quipu
Version: 0.2.0
Summary: Quipu — a human-first synthesis brain that any of your agents can read from and write to. Part of the KOI suite.
Author: Gia Khanh Nguyen
License: MIT License
        
        Copyright (c) 2026 Gia Khanh Nguyen
        
        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.
        
Project-URL: Homepage, https://github.com/kernel-of-inteligence/quipu
Project-URL: Repository, https://github.com/kernel-of-inteligence/quipu
Project-URL: Issues, https://github.com/kernel-of-inteligence/quipu/issues
Keywords: memory,rag,retrieval,knowledge-management,agents,mcp,embeddings,zettelkasten,pgvector
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Text Processing :: Indexing
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: pyyaml>=6.0
Requires-Dist: numpy>=1.23
Requires-Dist: click>=8.1
Requires-Dist: tomli>=2.0; python_version < "3.11"
Provides-Extra: mcp
Requires-Dist: mcp>=1.2; extra == "mcp"
Provides-Extra: local
Requires-Dist: sentence-transformers>=2.7; extra == "local"
Provides-Extra: hosted
Requires-Dist: psycopg[binary]>=3.1; extra == "hosted"
Provides-Extra: watch
Requires-Dist: watchdog>=4.0; extra == "watch"
Provides-Extra: dev
Requires-Dist: pytest>=8.0; extra == "dev"
Requires-Dist: mcp>=1.2; extra == "dev"
Dynamic: license-file

<div align="center">

<img src="./docs/assets/quipu-icon.png" alt="Quipu" width="96" height="96" />

# Quipu

**A human-first synthesis brain that any of your AI agents can read from and write to.**

Your notes stay as plain Markdown in your own git repo. Every agent you use reads and writes the
same brain through one gateway. A nightly pass turns your raw conversations into clean, linked
notes — that *you* approve before they become truth.

[![PyPI](https://img.shields.io/pypi/v/koi-quipu?color=D9542B)](https://pypi.org/project/koi-quipu/)
[![Python](https://img.shields.io/pypi/pyversions/koi-quipu?color=D9542B)](https://pypi.org/project/koi-quipu/)
[![License: MIT](https://img.shields.io/badge/license-MIT-D9542B)](./LICENSE)

*Part of the **KOI** ("Kernel of Intelligence") suite.*

</div>

---

Quipu is named after the [quipu](https://en.wikipedia.org/wiki/Quipu) — the knotted-cord records
of the Inca. Knots on a string, each meaningful in relation to the others. That's the model:
atomic ideas, tied together, so understanding *compounds* instead of piling up.

> **Markdown files in git are the only source of truth.** The search index, the Postgres mirror,
> the capture lake — all of it is a disposable cache you can delete and rebuild from the files at
> any time.

## The loop

```mermaid
flowchart LR
    A["you + your agents<br/>(conversations)"] -->|firehose| L["the lake<br/>(raw captures, decays)"]
    L -->|"nightly dream<br/>cluster + draft"| D["note drafts<br/>(provisional)"]
    D -->|"you approve<br/>(merge a PR)"| N["notes<br/>(confirmed truth)"]
    N -->|"auto-recall every turn"| A
    L -.->|"working memory"| A
```

You talk to your agents. Every exchange is captured. Overnight, the **dream** proposes a handful
of clean notes from the noise and opens a pull request. You merge the keepers. From then on, those
notes are recalled into every conversation automatically — so the brain sharpens the more you use
it, without you filing anything by hand.

## Why Quipu

- **🗂️ You own your data.** Plain Markdown in your own git repo — diff-able, openable in Obsidian,
  no lock-in, yours forever. The database is just a fast mirror you can throw away.
- **🔌 One brain, every agent.** A single MCP gateway. Claude Code, Codex, and anything that speaks
  MCP read and write the same notes you edit by hand.
- **🕸️ Synthesis over storage.** Typed links make a graph, not a folder — retrieval can follow
  relationships, not just match keywords.
- **✋ The human stays in charge.** Agents *propose*; you *dispose*. An agent never edits your
  words, and nothing becomes truth until you merge a pull request.
- **🎚️ As strong as your machine allows.** `quipu init` probes your box and picks the best local
  retrieval it can carry — a 1024-dim embedder **+ cross-encoder reranker** on a capable machine, a
  light 384-dim embedder on a lean one. All on-device, no server to run; degrades to real keyword
  search with zero dependencies installed.

## Quickstart

```bash
pip install 'koi-quipu[local]'    # local = the on-device embedder (gte-small / bge-m3 + reranker)
quipu init --demo                 # probes your machine, picks a retrieval tier, wires your agents
quipu doctor                      # verify everything end-to-end
quipu search "atomic notes"
```

```
✓ config       vault /Users/you/quipu
✓ embedder     bge-m3 (local, dim 1024) + bge reranker
✓ backend      sqlite, 5 notes   ·  add Supabase to share across machines
✓ claude code  recall + capture-turn hooks wired
✓ codex        [mcp_servers.quipu] present
```

Connect an agent (below) and the read/write loop becomes automatic — you stop typing `quipu`
commands and just talk.

## Three homes for your memory

Quipu deliberately spreads memory across three places, each with a different job:

| Home | What lives there | Lifetime |
|---|---|---|
| **Git** (Markdown) | confirmed notes — **the truth** | permanent, versioned |
| **Database** (SQLite or Postgres) | a searchable mirror of the notes + the lake | disposable, rebuildable |
| **The lake** (capture rows) | raw conversation exchanges | decays over weeks |

Git is slow, durable, and human-reviewable — perfect for truth. The database is fast and
disposable — perfect for search. The lake is cheap and forgetful — perfect for raw material.
Nothing important is ever *only* in the disposable layers.

## How it works

**Notes vs. captures.** *Notes* are curated, confirmed ideas — the `.md` files in your vault.
*Captures* are a raw firehose of your recent agent conversations: cheap to write, allowed to be
wrong, and they decay. The nightly dream mines the lake into note drafts; the rest is forgotten.

**The nightly dream.** The *intelligence* — clustering captures and drafting notes — is an **agent
skill**, not Python. It searches for an existing home before drafting anything new, never rewrites
a human's note (additions and corrections become *separate* linked notes), drops anything
work-derived, and opens one `dream/<date>` pull request. Merging it is how you confirm; a CI action
then syncs the database and deletes the consumed captures (an approved note is the durable record).

**Retrieval.** Both halves are searched by one pipeline: keyword (FTS5 / `tsvector`) + vector →
Reciprocal Rank Fusion → an optional **cross-encoder reranker** (on by default on the power tier) →
an abstention gate that returns *nothing* rather than a confidently-wrong nearest neighbour. The
embedder + reranker run on-device whether the store is SQLite or Supabase. No separate graph server.

## Connect an agent

```bash
quipu wire claude     # adds recall + capture-turn hooks to Claude Code
quipu wire codex      # adds the MCP server to Codex
```

In Claude Code, two hooks make the loop fully automatic: a `UserPromptSubmit` hook
(`quipu recall`) injects relevant notes + working memory before every turn, and a `Stop` hook
(`quipu capture-turn`) firehoses each exchange into the lake. Other MCP clients call the
[tools](./docs/reference/mcp-tools.mdx) on demand — paste the
[ready-made agent prompt](./docs/guides/connect-agents.mdx#a-prompt-for-your-agents) into their
instructions so they know how.

## Storage: shared by default, solo when offline

The brain wants to follow you across machines, so **Supabase Postgres + pgvector** is the default
when `quipu init` can provision or find one. With no account or no network it falls back to
**SQLite** — zero setup, offline, private (fine to ~10k notes). 

```bash
quipu provision supabase     # creates a free project, writes the DSN, loads your notes
# or, with an existing project:
quipu db use postgres        # persists the choice, creates tables, rebuilds from the vault
quipu db use sqlite          # …or go local/offline anytime
```

The two are interchangeable — notes always rebuild from the Markdown truth. Full walkthrough:
**[Run on Supabase](./docs/guides/setup-supabase.mdx)**.

## Documentation

Detailed guides with diagrams live in [`docs/`](./docs):

- [Introduction](./docs/introduction.mdx) · [Quickstart](./docs/quickstart.mdx)
- [Concepts](./docs/concepts.mdx) · [Architecture](./docs/architecture.mdx) · [Retrieval](./docs/concepts/retrieval.mdx)
- Guides: [the dream](./docs/guides/the-dream.mdx) · [connect an agent](./docs/guides/connect-agents.mdx) · [the lens](./docs/guides/the-lens.mdx)
- Reference: [CLI](./docs/reference/cli.mdx) · [MCP tools](./docs/reference/mcp-tools.mdx) · [config](./docs/reference/configuration.mdx) · [data model](./docs/reference/data-model.mdx)

Also: **[DESIGN.md](./DESIGN.md)** (rationale) · **[ROADMAP.md](./ROADMAP.md)** (where it's headed).

## Contributing

Small, dependency-light Python — see [CONTRIBUTING.md](./CONTRIBUTING.md). Tests are hermetic:

```bash
pip install -e '.[dev]' && pytest -q
```

## License

[MIT](./LICENSE). The PyPI package is `koi-quipu`; the CLI command is `quipu`.
