Metadata-Version: 2.4
Name: vlite
Version: 0.1.1
Summary: Lightweight local cross-agent memory for Claude Code and Codex
License-Expression: AGPL-3.0-only
License-File: LICENSE
License-File: LICENSE.additional-terms
License-File: NOTICE
Requires-Dist: fastembed>=0.8.0
Requires-Python: >=3.12
Description-Content-Type: text/markdown

# VLite

**VLite learns decisions and working preferences from new Claude Code and Codex conversations and brings the few relevant memories into your next agent chat: locally on one computer for free, or synced across your computers with optional Varyz Cloud sync.**

## Get started

On Windows x64, run the VLite installer and choose **Open VLite** (or open **VLite** from the Start menu later).

For a source installation with Python 3.12 or newer and `uv`, run from the repository root:

```powershell
uv tool install ./vlite
vlite setup
```

In the setup window:

1. Select **Claude Code** and/or **Codex** (VLite shows whether each client is detected on this machine) and save connections. Restart any agent you connected or disconnected.
   - If you connect **Codex**, open Codex once and run `/hooks` to approve VLite's hook if prompted.
   - If full **Varyz** hooks are also active for a client, VLite shows a notice so you can pause or disconnect full Varyz hooks when testing VLite alone.
2. Optionally choose **Import from Varyz** to bring over confirmed rules and owner decisions from an existing Varyz archive (`varyz.db`).

Once connected, say in one agent: *“For launch, we chose email sign-in. Google can wait.”* Continue working. Start a new chat in the other agent inside the same project and ask it to build onboarding — it receives the email sign-in decision automatically. Asking about an unrelated chart or another project leaves it out of the brief.

## Incremental capture and background learning

- **Incremental from connection time**: VLite starts capturing from the moment you connect an agent (via live `UserPromptSubmit` / `Stop` / `SessionStart` hooks and incremental transcript tailing). Setup requires no old history scan and no model download.
- **Background reader modes**:
  - **Fast local extraction + optional stateless headless CLI reader (`VLITE_READER_MODE=auto`, default)**: Clear decisions and controls are extracted deterministically right away; completed exchanges can also run through a stateless, single-shot headless `claude` or `codex` CLI turn using your existing client permissions (zero API keys, zero model downloads, hook-isolated so it never pollutes your transcripts or triggers hooks). Every extracted item is verified against user-authored quotes, never assistant suggestions or pasted/quoted blocks.
  - **100% local / offline mode**: Set `VLITE_READER_MODE=local` to disable headless CLI reader calls and run only local deterministic extraction with zero external model calls.
  - **Evidence thresholds**: Clear settled decisions take effect after one clear statement (preserving project scope, conditions, and time limits). Inferred habits start as candidates and require supporting evidence across at least two independent tasks before entering future briefs.
- **Short task-start briefs**: VLite delivers at most one short brief (under 200 words) at task start when relevant, reading only local SQLite (plus the warm local loopback embedding sidecar when needed) so task-start briefs never block on remote network calls, with zero mid-task or completion checks.

## 3-layer local retrieval

VLite combines three local, privacy-preserving retrieval layers at `UserPromptSubmit`, always enforcing scope, expiry, and audience/condition safety gates first:

1. **Exact / FTS5 + write-time semantic trigger phrases**: SQLite FTS5 BM25 and concept matching over memory text, conditions, and up to 12 concise task-intent trigger phrases generated at write time (synced across machines via Varyz Cloud).
2. **Typo-tolerant trigram & Damerau-Levenshtein matching**: Pure-stdlib `<2 ms` offline matching (`vlite.fuzzy`) that handles real typos (such as `onbording`, `moblie layot`, or `existing partnr`) while rejecting false lookalikes and opposing audience conditions (`new partnr`).
3. **Local quantized ONNX embeddings (`BAAI/bge-small-en-v1.5`)**: 384-dimensional local ONNX embeddings (~67 MB) computed in the background worker (`vlite.embeddings`) and queried via a warm loopback HTTP sidecar (`vlite embed-server`, strict 150 ms hook timeout, zero ML imports in hooks) when Layers 1–2 miss on zero-overlap paraphrases. Embedding vectors stay strictly on your machine in local SQLite and are never uploaded to Varyz Cloud. Set `VLITE_EMBEDDINGS=off` to run strictly on Layers 1–2 (valid values: `auto`, `on`, `off`, `inprocess`).

## Cross-computer sync (optional, Varyz Cloud)

Local single-computer VLite stays free and offline-first (gracefully falling back to Layers 1–2 whenever `VLITE_EMBEDDINGS=off` or offline without cached ONNX weights). If you have a paid **Varyz Cloud** plan, you can connect multiple computers via OAuth 2.0 PKCE (`Connect Cloud` in `vlite setup` or `vlite cloud connect`):

- **Zero-ceremony automatic sync**: Decisions, trigger phrases, edits, permanent tombstones, and cross-machine habit evidence counts (`lite_support`) sync automatically in the background (with automatic conflict merging and no manual conflict queues or per-project upload wizards). Transcripts, raw local paths, secrets, and local embedding vectors are never uploaded.
- **Instant `SessionStart` pull + sidecar pre-warm**: Starting a Claude Code or Codex session triggers an immediate unthrottled Cloud pull (`min_interval_seconds=0`) and warms the local embedding sidecar in the background before you finish typing your first prompt.
- **Cross-computer project matching**: Projects match across machines by canonicalized Git remote (`origin` / `upstream`, stripping credentials so HTTPS and SSH clones share the same project), `.varyz-project` slug markers, or non-git folder name (while keeping same-named non-git folders on the same machine isolated locally). Memories from unvisited remote projects show a **Remote project** badge in `vlite setup` and bind automatically when you work in that project locally.
- **Offline-ready & per-computer isolation**: Task-start briefs always read local storage immediately without waiting on the network. Credentials are stored per-computer (Windows DPAPI or mode `0600` on macOS/Linux), and disconnecting one computer revokes only that computer's session while keeping all local memories intact.

## Resume work in any agent

Say "resume the importer work by Claude", "pick up where Codex left off" or "continue my last task" in Claude Code or Codex, and VLite adds a short card of that work to the prompt: the goal, a few-line summary, your last requests, the agent's last update, its plan and the files it edited. The agent then checks the current files and carries on. It is never the whole conversation.

- **Any point**: cards are built from the transcript as you work, not at the end, so they survive an interrupt, a usage limit or a crash. On the same computer the resume ask also reads the last unprocessed part of the transcript (read-only, at most 2 MB), so the card is current even if the session stopped mid-turn.
- **Any computer**: with Varyz Cloud connected, cards sync as small records (project-relative file names only, secrets redacted, no transcript) and a resume ask does a pull of at most 3 seconds first. The final turn on the first computer reaches Cloud at its next hook event, so the newest moment of a session that was cut off mid-turn can lag on the other computer.
- **Light**: normal prompts only pay a text check. A card is about 3 KB and is deleted after 30 days. The short summary is written by the background reader only when an agent finishes a task that took 2 minutes or more (never after a short reply), and follows `reader_mode`; without it, resume still works from the plain card.
- **Chains**: a session that resumed earlier work continues that card, so the next resume finds the newest link.
- **Project overview for other computers**: after a long task, the background reader also rewrites a short overview of the project (what it is, where it stands, recent work, open threads; at most 1,200 characters), built from the work cards, never from transcripts, and synced through Cloud. It is shown only on a computer where that work was not done: ask "what is this project about", "catch me up" or "what did we do last time" there, or resume work that came from another computer. On the computer that did most of the project's recent work it is never shown, because the agent there already has that history.
- `vlite work` lists saved work; `vlite work off` turns the feature off (`on` turns it back on).

## In-chat and desktop controls

Inside Claude Code or Codex, you can steer VLite directly in conversation:

- **Inspect source**: Ask `Why?` or `Why did you choose that?` to see the scope, original source, and user quote behind a surfaced memory.
- **Forget**: Say `Forget that` (or `Forget memory <id>` / `Forget <topic>`) to retire a memory with a permanent tombstone so replaying the conversation never revives it.
- **Narrow scope**: Say `That was only for that email` (retires a one-off), `That was only for existing partners`, or `Only for this project`.
- **Update a plan**: Say `We've changed the launch plan` or state the updated decision (e.g. `Google sign-in is approved for launch too`).

In the local browser window (`vlite setup`), you can review active memories, filter by project, inspect source quotes and diagnostics, edit a memory's text/scope/conditions/time limit (including re-scoping remote-project items), forget items, pause/resume VLite, or manage **Cloud sync** (`Connect Cloud`, `Sync now`, `Pause sync` / `Resume sync`, and `Disconnect`). Pausing VLite suspends learning and briefs; resuming advances cursors past paused-time conversations so paused chats are not retroactively mined.

| Command | Purpose |
|---|---|
| `vlite setup` | Open the local agent chooser, Cloud sync card, Varyz importer, memory editor, and diagnostics |
| `vlite doctor` | Print local storage, connections, hook verification, reader status, semantic status, Cloud sync status, and counts |
| `vlite semantic status` | Print local semantic embedding status, sidecar state, and embedded/active counts as JSON |
| `vlite semantic warmup` | Embed pending active memories locally and ensure the warm embedding sidecar is running |
| `vlite pause` / `vlite resume` | Suspend or resume learning and briefs (stops the embedding sidecar cleanly on pause) |
| `vlite disconnect` | Remove VLite hooks from connected agents and stop the embedding sidecar (preserves stored memories) |
| `vlite cloud connect [--url URL]` | Connect this computer to Varyz Cloud via browser OAuth 2.0 PKCE |
| `vlite cloud sync` | Pull remote changes and push local pending changes immediately |
| `vlite cloud status` | Print Cloud sync connection status and counts as JSON |
| `vlite cloud pause` / `vlite cloud resume` | Pause or resume Cloud sync without disconnecting |
| `vlite cloud disconnect` | Revoke this computer's Cloud session and reset sync state (preserves local memories) |

Set `VLITE_HOME` to isolate storage during development, `VLITE_READER_MODE` (`auto`, `local`, `claude`, `codex`, `off`) to control the background reader, and `VLITE_EMBEDDINGS` (`auto`, `on`, `off`, `inprocess`) to control local ONNX embeddings (`VLITE_EMBED_MODEL` / `VLITE_EMBED_CACHE` override the default `BAAI/bge-small-en-v1.5` model and cache directory).

## Development

Run checks from `vlite/` (using the workspace `uv` environment):

```powershell
uv run --project .. pytest
uv run --project .. ruff check src tests evals packaging
$env:MYPYPATH="src"; uv run --project .. mypy src evals packaging/build_windows.py
uv build
```

To build the per-user Windows installer, run with Windows x64 CPython 3.12:

```powershell
python packaging/build_windows.py --iscc <path-to-ISCC.exe> --output dist
```

It stages an isolated Python 3.12 runtime (`python312._pth`) with VLite and licenses, runs an isolated smoke test, and builds the Inno Setup installer. Pass `--include-semantic` to bundle `fastembed`, `onnxruntime`, `tokenizers`, and `numpy` into the staged runtime for a full semantic Windows installer.
