mipmem 1.0.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.
- mipmem-1.0.0/LICENSE +21 -0
- mipmem-1.0.0/PKG-INFO +294 -0
- mipmem-1.0.0/README.md +266 -0
- mipmem-1.0.0/pyproject.toml +48 -0
- mipmem-1.0.0/setup.cfg +4 -0
- mipmem-1.0.0/src/mipmem/__init__.py +6 -0
- mipmem-1.0.0/src/mipmem/__main__.py +17 -0
- mipmem-1.0.0/src/mipmem/adapters/__init__.py +1 -0
- mipmem-1.0.0/src/mipmem/adapters/agy_cli.py +437 -0
- mipmem-1.0.0/src/mipmem/adapters/agy_ide.py +459 -0
- mipmem-1.0.0/src/mipmem/adapters/base.py +90 -0
- mipmem-1.0.0/src/mipmem/adapters/hook_io.py +855 -0
- mipmem-1.0.0/src/mipmem/adapters/plugin_manifest.py +273 -0
- mipmem-1.0.0/src/mipmem/adapters/slash_mem.py +794 -0
- mipmem-1.0.0/src/mipmem/cli.py +209 -0
- mipmem-1.0.0/src/mipmem/cli_commands.py +974 -0
- mipmem-1.0.0/src/mipmem/config.py +687 -0
- mipmem-1.0.0/src/mipmem/core/__init__.py +1 -0
- mipmem-1.0.0/src/mipmem/core/brainstorms.py +607 -0
- mipmem-1.0.0/src/mipmem/core/diagnostics.py +276 -0
- mipmem-1.0.0/src/mipmem/core/fts_recall.py +2065 -0
- mipmem-1.0.0/src/mipmem/core/migrate_v2.py +452 -0
- mipmem-1.0.0/src/mipmem/core/mipmap.py +453 -0
- mipmem-1.0.0/src/mipmem/core/redactor.py +171 -0
- mipmem-1.0.0/src/mipmem/core/salience.py +127 -0
- mipmem-1.0.0/src/mipmem/core/sessions.py +386 -0
- mipmem-1.0.0/src/mipmem/core/subapps.py +805 -0
- mipmem-1.0.0/src/mipmem/core/updater.py +712 -0
- mipmem-1.0.0/src/mipmem/core/vault.py +468 -0
- mipmem-1.0.0/src/mipmem/core/workstreams.py +307 -0
- mipmem-1.0.0/src/mipmem/i18n/__init__.py +118 -0
- mipmem-1.0.0/src/mipmem/i18n/en.py +162 -0
- mipmem-1.0.0/src/mipmem/i18n/vi.py +136 -0
- mipmem-1.0.0/src/mipmem/mcp/__init__.py +1 -0
- mipmem-1.0.0/src/mipmem/mcp/server.py +517 -0
- mipmem-1.0.0/src/mipmem/mcp/tools.py +423 -0
- mipmem-1.0.0/src/mipmem/sync/__init__.py +1 -0
- mipmem-1.0.0/src/mipmem/sync/base.py +229 -0
- mipmem-1.0.0/src/mipmem/sync/folder_backend.py +334 -0
- mipmem-1.0.0/src/mipmem/sync/git_backend.py +552 -0
- mipmem-1.0.0/src/mipmem.egg-info/PKG-INFO +294 -0
- mipmem-1.0.0/src/mipmem.egg-info/SOURCES.txt +61 -0
- mipmem-1.0.0/src/mipmem.egg-info/dependency_links.txt +1 -0
- mipmem-1.0.0/src/mipmem.egg-info/entry_points.txt +2 -0
- mipmem-1.0.0/src/mipmem.egg-info/top_level.txt +1 -0
- mipmem-1.0.0/tests/test_adapters.py +534 -0
- mipmem-1.0.0/tests/test_brainstorms_and_mipmap.py +407 -0
- mipmem-1.0.0/tests/test_cleanroom_and_pyz.py +188 -0
- mipmem-1.0.0/tests/test_cli.py +699 -0
- mipmem-1.0.0/tests/test_config_and_policy.py +360 -0
- mipmem-1.0.0/tests/test_diagnostics.py +251 -0
- mipmem-1.0.0/tests/test_fts_recall.py +716 -0
- mipmem-1.0.0/tests/test_hooks.py +1187 -0
- mipmem-1.0.0/tests/test_i18n_and_salience.py +403 -0
- mipmem-1.0.0/tests/test_mcp_server.py +498 -0
- mipmem-1.0.0/tests/test_migrate_v2.py +295 -0
- mipmem-1.0.0/tests/test_plugin_bundle.py +237 -0
- mipmem-1.0.0/tests/test_redactor.py +161 -0
- mipmem-1.0.0/tests/test_release_readiness.py +338 -0
- mipmem-1.0.0/tests/test_subapps.py +619 -0
- mipmem-1.0.0/tests/test_sync.py +609 -0
- mipmem-1.0.0/tests/test_updater.py +527 -0
- mipmem-1.0.0/tests/test_vault_and_mutations.py +472 -0
mipmem-1.0.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Pageel
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
mipmem-1.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: mipmem
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Zero-Token, Zero-Dependency 4-Layer Mipmapped Cognitive Memory Engine for AI Agents
|
|
5
|
+
Author: Pageel Contributors
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/pageel/mipmem
|
|
8
|
+
Project-URL: Repository, https://github.com/pageel/mipmem
|
|
9
|
+
Project-URL: Issues, https://github.com/pageel/mipmem/issues
|
|
10
|
+
Project-URL: Changelog, https://github.com/pageel/mipmem/blob/main/CHANGELOG.md
|
|
11
|
+
Keywords: ai-agents,memory,mcp,sqlite,fts5,antigravity,cognitive-memory
|
|
12
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
13
|
+
Classifier: Environment :: Console
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Operating System :: OS Independent
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
23
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
24
|
+
Requires-Python: >=3.9
|
|
25
|
+
Description-Content-Type: text/markdown
|
|
26
|
+
License-File: LICENSE
|
|
27
|
+
Dynamic: license-file
|
|
28
|
+
|
|
29
|
+
# MipMem
|
|
30
|
+
|
|
31
|
+
[](https://github.com/pageel/mipmem/actions/workflows/ci.yml)
|
|
32
|
+
[](LICENSE)
|
|
33
|
+
|
|
34
|
+
[English](README.md) | [Tiếng Việt](README.vi.md)
|
|
35
|
+
|
|
36
|
+
<!-- ⚠️ SOURCE-VERIFIED — Cross-referenced with src/mipmem/, plugin.json, hooks.json, mcp_config.json, scripts/, .github/workflows/ on 2026-11-25 -->
|
|
37
|
+
|
|
38
|
+
**Zero-dependency, zero-LLM-cost 4-layer mipmapped cognitive memory engine with a conflict-free sharded multi-host vault, multi-host Git/folder sync, RCE-safe private sub-apps, opt-in self-update, sub-5ms bilingual SQLite FTS5 recall, Native Antigravity Plugin, and Universal Local stdio MCP server.**
|
|
39
|
+
|
|
40
|
+
MipMem is built strictly on the **Python >= 3.9 standard library** (`dependencies = []`) and ships across both PyPI and standalone single-file `.pyz` zipapp bundles engineered for sub-25ms hot-path CLI and hook execution.
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## Key Architecture & Safety Guarantees (`v1.0.0`)
|
|
45
|
+
|
|
46
|
+
- **Zero External Dependencies & Zero LLM Cost:** Runs anywhere Python `>= 3.9` is installed with zero runtime packages (`dependencies = []`) and zero embedding or LLM API calls.
|
|
47
|
+
- **4-Layer Mipmap Engine (`L0 → L3`):**
|
|
48
|
+
- `L0` startup radar strictly bounded by `budget.l0_max_tokens` (default `300`), incorporating collapsed or alert-driven Sub-App telemetry and sync conflict warnings.
|
|
49
|
+
- `L1` structural skeleton cards with `#Lstart-Lend` pointers strictly bounded by `budget.l1_max_tokens` (default `450`), truncated on line boundaries without ever leaving unclosed Markdown fenced code blocks.
|
|
50
|
+
- `L2` surgical section (`§k`) and line-range (`#Lstart-Lend`) slicing, plus lossless `L3` full-document access.
|
|
51
|
+
- **Per-Host Private Sub-Apps Contract (`core/subapps.py`):**
|
|
52
|
+
- Keeps core OS-agnostic while allowing machine-specific health monitors (`hosts/<host_id>/telemetry/<app_id>.status.json` + safe `detail_file` path guard inside `host_dir`) to surface in `L0 Radar`, `/mem fleet`, `mipmem fleet --json`, and `mem_fleet_status`.
|
|
53
|
+
- Allows machine-local `/mem <app>` delegates via `<config_dir>/apps.d/*.json` only (never read from the synced Vault), verifying POSIX UID ownership, non-group/world-writable permissions (`mode & 0o022 == 0`), `shell=False`, timeout caps (`5s` default, `15s` hard max), secret redaction, and collision protection against core `/mem` commands.
|
|
54
|
+
- **Conflict-Free Multi-Host Vault & Git/Folder Sync (`mipmem.sync`):**
|
|
55
|
+
- Strict single-writer layout (`hosts/<host_id>/`, `shared/brainstorms/by-host/<host_id>/`) with local gitignored `.cache/global_fts.db`.
|
|
56
|
+
- **`GitSyncBackend`:** Uses `GIT_TERMINAL_PROMPT=0` (OS SSH-Agent / Credential Helper, zero stored PATs), `fcntl.flock` on `<cache_dir>/sync.lock`, `core.filemode=false`, single-writer staging, `git pull --rebase --autostash`, automatic `git rebase --abort` + `sync_status.json` conflict alert on manual shared edits, and detached `Stop`-hook sync (`start_new_session=True`, `0ms` foreground UI block).
|
|
57
|
+
- **`FolderSyncBackend`:** Bi-directional atomic single-writer sync across Syncthing, Tailscale Drive, or shared local directories (`[sync].folder_path`), ignoring `.cache/` and `.git/`, preventing nested-vault recursion, and skipping escaping symlinks.
|
|
58
|
+
- **Opt-In Verified Self-Update (`core/updater.py`):**
|
|
59
|
+
- Strictly opt-in (`mipmem self-update [--check | --dry-run | --version <tag>]`). Enforces HTTPS allowlists to official `pageel/mipmem` GitHub Releases, verifies `SHA256SUMS` (`hmac.compare_digest`), checks `ZipFile.testzip()`, runs pre-swap `health --json` in isolation, atomically swaps via `os.replace()`, and refuses modifying `uv`/`pipx`/`pip`/Plugin/git-dev installs (printing the channel-appropriate upgrade command instead).
|
|
60
|
+
- **Dual CLI/IDE Transcript Adapters & Unified `user_markdown` Hooks (`mipmem.adapters`):**
|
|
61
|
+
- **CLI & IDE Harvesters:** Opens `conversation_summaries.db` read-only (`mode=ro`, skips subagents) and streams `transcript.jsonl` + lazy `transcript_full.jsonl` expansion (never auto-scanning `artifactDirectoryPath`).
|
|
62
|
+
- **Fail-Open Hooks & `/mem` Intercept:** Runs `SessionStart`, `PreInvocation`, and `Stop` fail-open (`{}` + exit `0`), intercepts `/mem ...` via `metadata.user_markdown` + `terminationBehavior: "terminate"`, and enforces `disabled > passive > active` workspace policies.
|
|
63
|
+
- **Universal Local Memory MCP Server (`mipmem mcp`):**
|
|
64
|
+
- Pure stdlib JSON-RPC 2.0 `stdio` server auto-detecting `NDJSON` and `Content-Length` framing (`<= 4 MB`, zero stray stdout logs, `CP-MCP-01`) with 6 canonical tools (`mem_recall`, `mem_bs_list`, `mem_bs_slice`, `mem_bs_save`, `mem_handoff`, `mem_fleet_status`).
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
## Installation (4 Channels)
|
|
69
|
+
|
|
70
|
+
### 1. PyPI (`uv`, `pipx`, or `pip`)
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
# Recommended CLI tool installs (isolated environments)
|
|
74
|
+
uv tool install mipmem
|
|
75
|
+
# or
|
|
76
|
+
pipx install mipmem
|
|
77
|
+
# or standard pip
|
|
78
|
+
python3 -m pip install mipmem
|
|
79
|
+
|
|
80
|
+
mipmem health --json
|
|
81
|
+
mipmem init --host workstation-alpha --json
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### 2. Standalone `.pyz` Zipapp (GitHub Releases)
|
|
85
|
+
|
|
86
|
+
Download `mipmem.pyz` and `SHA256SUMS` from [GitHub Releases](https://github.com/pageel/mipmem/releases):
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
sha256sum -c SHA256SUMS --ignore-missing
|
|
90
|
+
python3 ./mipmem.pyz health --json
|
|
91
|
+
python3 ./mipmem.pyz init --host workstation-alpha --json
|
|
92
|
+
|
|
93
|
+
# Check for or apply opt-in updates later (zipapp mode only)
|
|
94
|
+
python3 ./mipmem.pyz self-update --check --json
|
|
95
|
+
python3 ./mipmem.pyz self-update
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Always invoke `.pyz` files explicitly with `python3` so execution stays portable across Linux, macOS, WSL, and shared mounts regardless of filesystem executable bits.
|
|
99
|
+
|
|
100
|
+
### 3. Native Antigravity Plugin (CLI & IDE)
|
|
101
|
+
|
|
102
|
+
This repository root is a self-contained Native Antigravity Plugin (`plugin.json`, `hooks.json`, `mcp_config.json`, `rules/AGENTS.md`, `skills/mem/SKILL.md`, and `bin/mipmem.pyz`):
|
|
103
|
+
|
|
104
|
+
1. Clone or link the repository directory into your Antigravity plugins directory (e.g., `~/.gemini/config/plugins/mipmem` or `.agents/plugins/mipmem`) or register its path in `plugins.json`.
|
|
105
|
+
2. Initialize your vault once (`python3 ./bin/mipmem.pyz init --host workstation-alpha`).
|
|
106
|
+
3. Antigravity loads `hooks.json`, `mcp_config.json`, `rules/AGENTS.md`, and `skills/mem/SKILL.md` automatically in an isolated plugin scope without modifying `~/.agents/hooks.json` or `~/.bash_aliases`.
|
|
107
|
+
|
|
108
|
+
> **Safe Opt-In Artifact Capture:** `Stop` hooks never auto-scan `artifactDirectoryPath`. To persist a design or research artifact into the Brainstorm Vault, confirm the agent's suggestion (`mem_bs_save(title=..., file_path=...)`) or run `/mem bs save "<title>" --file <path>` directly.
|
|
109
|
+
|
|
110
|
+
### 4. Universal Local MCP Server (Claude Code, Cursor, Gemini CLI, Antigravity)
|
|
111
|
+
|
|
112
|
+
Point any stdio-compatible MCP client at `mipmem mcp` (or `bin/mipmem.pyz mcp`):
|
|
113
|
+
|
|
114
|
+
```json
|
|
115
|
+
{
|
|
116
|
+
"mcpServers": {
|
|
117
|
+
"mipmem": {
|
|
118
|
+
"command": "python3",
|
|
119
|
+
"args": ["/path/to/mipmem/bin/mipmem.pyz", "mcp"]
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
Exposed MCP tools: `mem_recall`, `mem_bs_list`, `mem_bs_slice`, `mem_bs_save`, `mem_handoff`, and `mem_fleet_status`.
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
|
|
129
|
+
## In-Chat `/mem` Slash Commands (0 LLM Tokens)
|
|
130
|
+
|
|
131
|
+
| Command | Description |
|
|
132
|
+
| :--- | :--- |
|
|
133
|
+
| `/mem help` | Display core `/mem` subcommands and any trusted local `apps.d` delegates |
|
|
134
|
+
| `/mem status` | Show vault status, active host, known hosts, and FTS5 capability |
|
|
135
|
+
| `/mem fleet` | Show multi-host session/brainstorm inventory, Sub-App telemetry, and sync state |
|
|
136
|
+
| `/mem sync [--pull-only \| --push-only]` | Run configured Git or Folder vault synchronization |
|
|
137
|
+
| `/mem recall <query> [--host <h>] [--limit <n>]` | Run EN/VI FTS5 BM25 Bigram recall |
|
|
138
|
+
| `/mem list [start-end]` | List recent sessions (default `1-10`, compact GFM table on CLI) |
|
|
139
|
+
| `/mem bs list [--status <s>] [--host <h>]` | List lossless brainstorm shards with LWW status |
|
|
140
|
+
| `/mem bs save <title> [--file <path>] [--tags a,b]` | Save redacted inline text or a UTF-8 file (`<= 2 MB`, non-symlink) |
|
|
141
|
+
| `/mem bs view <bs_id> [§k \| #Lstart-Lend \| --l1]` | View L1 outline card or surgical L2 section/line slice |
|
|
142
|
+
| `/mem bs status <bs_id> <status>` | Append a conflict-free status event to the active host journal |
|
|
143
|
+
| `/mem config [show \| get <k> \| set <k> <v>]` | View or update typed settings in `config.toml` |
|
|
144
|
+
| `/mem handoff [@<host_id>]` | Display the latest `Primary Work Anchor` handoff for a host |
|
|
145
|
+
| `/mem <app> [args...]` | Execute a trusted local `~/.config/mipmem/apps.d/<app>.json` delegate |
|
|
146
|
+
|
|
147
|
+
---
|
|
148
|
+
|
|
149
|
+
## CLI Reference (`v1.0.0`)
|
|
150
|
+
|
|
151
|
+
| Command | Purpose |
|
|
152
|
+
| :--- | :--- |
|
|
153
|
+
| `mipmem init [--host <id>] [--vault <dir>] [--json]` | Initialize `config.toml` and create host-isolated vault directories (`0700`/`0600` best-effort) |
|
|
154
|
+
| `mipmem config [show \| get <k> \| set <k> <v>] [--json]` | Display, read, or validate & persist typed settings in `config.toml` |
|
|
155
|
+
| `mipmem health [--vault <dir>] [--require-vault] [--deep] [--json]` | Fast `< 25ms` check, or `--deep` FTS5, index, `sync_backend`, `last_sync_status`, and `subapp_delegates_count` probe |
|
|
156
|
+
| `mipmem fleet [--host <id>] [--vault <dir>] [--json]` | Output multi-host inventory, Sub-App telemetry, and cached sync status |
|
|
157
|
+
| `mipmem sync [--pull-only \| --push-only \| --detached] [--host <id>] [--vault <dir>] [--json]` | Execute conflict-free Git or Folder vault synchronization |
|
|
158
|
+
| `mipmem self-update [--check \| --dry-run \| --version <tag>] [--json]` | Check for releases or atomically update a standalone zipapp (`SHA256SUMS` + `testzip()` + pre-swap `health`) |
|
|
159
|
+
| `mipmem migrate --from-v2 <dir> [--vault <dir>] [--host <id>] [--apply] [--force] [--json]` | Preview (`--dry-run` default) or idempotently import a legacy v2 flat memory directory |
|
|
160
|
+
| `mipmem index [--rebuild] [--locale en\|vi] [--vault <dir>] [--json]` | Incrementally sync (or `--rebuild`) `.cache/global_fts.db` from the Sharded Vault |
|
|
161
|
+
| `mipmem recall <query> [--host <id>] [--status <st>] [--limit <N>] [--scope all\|sessions\|brainstorms] [--locale en\|vi] [--json]` | Run sanitized EN/VI FTS5 BM25 Bigram recall and return ranked `L1` memory hits |
|
|
162
|
+
| `mipmem bs [list \| save \| view \| status] [...] [--json]` | Manage lossless brainstorm shards, surgical `L2` slices, and conflict-free status events |
|
|
163
|
+
| `mipmem hook <session-start \| pre-invocation \| stop>` | Run Antigravity lifecycle hooks over `stdin`/`stdout` JSON with sub-25ms no-op skip & fail-open `{}` |
|
|
164
|
+
| `mipmem mcp [--vault <dir>]` | Run the universal local stdio JSON-RPC 2.0 MCP server (`NDJSON` & `Content-Length`) |
|
|
165
|
+
|
|
166
|
+
Errors on standard CLI commands return a non-zero exit code; when `--json` is passed, errors emit a structured envelope on `stdout`:
|
|
167
|
+
|
|
168
|
+
```json
|
|
169
|
+
{"success": false, "error": {"code": "VAULT_NOT_INITIALIZED", "message": "..."}}
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
---
|
|
173
|
+
|
|
174
|
+
## Directory Resolution, Configuration & Vault Sync
|
|
175
|
+
|
|
176
|
+
MipMem resolves runtime directories consistently across CLI, hooks, and MCP integrations in strict precedence order:
|
|
177
|
+
|
|
178
|
+
1. Explicit overrides: `MIPMEM_CONFIG_DIR`, `MIPMEM_VAULT_DIR`, `MIPMEM_CACHE_DIR`
|
|
179
|
+
2. `[core].vault_path` in `config.toml` (for `vault_dir`)
|
|
180
|
+
3. XDG directories: `XDG_CONFIG_HOME/mipmem`, `XDG_DATA_HOME/mipmem/vault`, `XDG_CACHE_HOME/mipmem`
|
|
181
|
+
4. Writable home defaults: `~/.config/mipmem`, `~/.local/share/mipmem/vault`, `~/.cache/mipmem`
|
|
182
|
+
5. Fallback (`PLUGIN_DATA/{config,vault,cache}`) only when `$HOME` is unset or non-writable
|
|
183
|
+
|
|
184
|
+
Starter configuration template: copy [config.example.toml](config.example.toml) to `~/.config/mipmem/config.toml` and customize:
|
|
185
|
+
|
|
186
|
+
- `[core].locale`: `"en"` or `"vi"` (enables Vietnamese `đ/Đ` FTS5 folding and lexicon packs)
|
|
187
|
+
- `[budget]`: `l0_max_tokens`, `l1_max_tokens`, `topic_shift_novelty`
|
|
188
|
+
- `[workspace_policies]`: `active` | `passive` | `disabled` (`disabled > passive > default`)
|
|
189
|
+
- `[sync]`:
|
|
190
|
+
- `backend = "git"` + `vault_remote_url = "git@github.com:example-user/my-mipmem-vault.git"` + `auto_sync_on_stop = true` (uses OS SSH-Agent or Git Credential Helper; zero PATs stored)
|
|
191
|
+
- or `backend = "folder"` + `folder_path = "/path/to/shared-sync-folder"` (for Syncthing, Tailscale Drive, or local shared folders)
|
|
192
|
+
|
|
193
|
+
---
|
|
194
|
+
|
|
195
|
+
## Repository Layout
|
|
196
|
+
|
|
197
|
+
```text
|
|
198
|
+
.
|
|
199
|
+
├── .github/
|
|
200
|
+
│ ├── PULL_REQUEST_TEMPLATE.md # Standard OSS PR verification checklist
|
|
201
|
+
│ └── workflows/
|
|
202
|
+
│ ├── ci.yml # Lint, pyright, clean-room, verify_release, Python 3.9–3.13 + macOS matrix & .pyz determinism
|
|
203
|
+
│ └── release.yml # Tag-triggered Dual-Channel Release: GitHub Releases (provenance + SHA256SUMS) & PyPI OIDC + PEP 740
|
|
204
|
+
├── plugin.json # Native Antigravity Plugin manifest (v1.0.0)
|
|
205
|
+
├── hooks.json # Flat SessionStart / PreInvocation / Stop hook bindings
|
|
206
|
+
├── mcp_config.json # Local stdio MCP server binding (bin/mipmem.pyz mcp)
|
|
207
|
+
├── rules/
|
|
208
|
+
│ └── AGENTS.md # Concise plain-Markdown plugin rules & opt-in artifact guard
|
|
209
|
+
├── skills/
|
|
210
|
+
│ └── mem/
|
|
211
|
+
│ └── SKILL.md # /mem slash command & 6 MCP tools skill reference
|
|
212
|
+
├── config.example.toml # Clean starter config template
|
|
213
|
+
├── pyproject.toml # Python >= 3.9, dependencies = [], Pageel Contributors metadata
|
|
214
|
+
├── README.md # English-first OSS documentation
|
|
215
|
+
├── README.vi.md # Vietnamese community guide
|
|
216
|
+
├── CHANGELOG.md # Keep a Changelog history through v1.0.0
|
|
217
|
+
├── LICENSE # MIT License
|
|
218
|
+
├── bin/mipmem.pyz # Deterministic single-file zipapp binary (v1.0.0)
|
|
219
|
+
├── scripts/
|
|
220
|
+
│ ├── build_pyz.py # Deterministic zipapp bundler
|
|
221
|
+
│ ├── check_cleanroom.py # Tree, archive (.pyz/.zip/.whl/.tar.gz), and --git-history clean-room scanner
|
|
222
|
+
│ └── verify_release.py # Dual-channel release parity, OIDC, and SHA256SUMS validator
|
|
223
|
+
├── src/mipmem/
|
|
224
|
+
│ ├── __init__.py
|
|
225
|
+
│ ├── __main__.py # `python3 -m mipmem` entrypoint
|
|
226
|
+
│ ├── cli.py # Fast-path router (< 25ms health & hook no-op, zero heavy imports)
|
|
227
|
+
│ ├── cli_commands.py # Lazy CLI subcommands (init/config/health/fleet/sync/self-update/migrate/index/recall/bs/hook/mcp)
|
|
228
|
+
│ ├── config.py # XDG resolver, zero-dep TOML codec & policy evaluator
|
|
229
|
+
│ ├── core/
|
|
230
|
+
│ │ ├── diagnostics.py # Rotating JSONL logger & S1–S4 error taxonomy (25 codes, CP-* checkpoints)
|
|
231
|
+
│ │ ├── redactor.py # Pre-write secret redactor & $HOME normalization
|
|
232
|
+
│ │ ├── vault.py # Sharded vault init, atomic I/O & mutation journal
|
|
233
|
+
│ │ ├── migrate_v2.py # Non-destructive, idempotent v2 importer
|
|
234
|
+
│ │ ├── sessions.py # Canonical Session Frontmatter v1 parser & vault writer
|
|
235
|
+
│ │ ├── salience.py # Dual-Anchor Salience scorer & Brainstorm Bonus
|
|
236
|
+
│ │ ├── workstreams.py # Cross-host Jaccard workstream threading & compaction
|
|
237
|
+
│ │ ├── brainstorms.py # Fence-Aware Markdown AST (§1 skip H1) & sharded store
|
|
238
|
+
│ │ ├── mipmap.py # Token-budgeted L0/L1 renderer & surgical L2 slicer
|
|
239
|
+
│ │ ├── fts_recall.py # Incremental FTS5 indexer, LWW projection, BM25 bigram recall & Topic-Shift gate
|
|
240
|
+
│ │ ├── subapps.py # Per-host telemetry reader, L0/fleet presenter & RCE-safe apps.d delegator
|
|
241
|
+
│ │ └── updater.py # Opt-in release manifest guard & atomic zipapp self-updater
|
|
242
|
+
│ ├── sync/
|
|
243
|
+
│ │ ├── __init__.py # Lightweight package marker (zero eager imports)
|
|
244
|
+
│ │ ├── base.py # SyncBackend Protocol, acquire_sync_lock & atomic sync_status.json store
|
|
245
|
+
│ │ ├── git_backend.py # Conflict-free GitSyncBackend & detached Stop-hook worker
|
|
246
|
+
│ │ └── folder_backend.py # Single-writer FolderSyncBackend (Syncthing/shared dir)
|
|
247
|
+
│ ├── adapters/
|
|
248
|
+
│ │ ├── __init__.py # Lightweight package marker (zero eager imports)
|
|
249
|
+
│ │ ├── base.py # NormalizedConversation schema, TranscriptAdapter Protocol & surface detector
|
|
250
|
+
│ │ ├── agy_cli.py # Read-only SQLite CLI harvester (mode=ro, skips subagents) + JSONL fallback
|
|
251
|
+
│ │ ├── agy_ide.py # IDE transcript.jsonl + transcript_full.jsonl harvester (no artifact auto-scan)
|
|
252
|
+
│ │ ├── slash_mem.py # Shell-free /mem dispatcher (fleet, sync, bs, handoff & apps.d delegates)
|
|
253
|
+
│ │ ├── hook_io.py # Unified user_markdown renderer, SessionStart/PreInvocation/Stop & fail-open runner
|
|
254
|
+
│ │ └── plugin_manifest.py # Automated Native Plugin bundle validator
|
|
255
|
+
│ ├── mcp/
|
|
256
|
+
│ │ ├── __init__.py
|
|
257
|
+
│ │ ├── server.py # Auto-framing stdio JSON-RPC 2.0 server (NDJSON & Content-Length)
|
|
258
|
+
│ │ └── tools.py # 6 lazy local memory MCP tools (mem_recall..mem_fleet_status)
|
|
259
|
+
│ └── i18n/
|
|
260
|
+
│ ├── __init__.py # LocaleLexicon registry & tokenizer/bigram helpers
|
|
261
|
+
│ ├── en.py # English stop-words, intent & brainstorm cues
|
|
262
|
+
│ └── vi.py # Vietnamese đ/Đ FTS5 folder, normalizer & lexicon cues
|
|
263
|
+
└── tests/ # Zero-dependency standard-library unittest test suite
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
---
|
|
267
|
+
|
|
268
|
+
## Development & Verification
|
|
269
|
+
|
|
270
|
+
Run all stdlib checks directly from the repository root without external runtime dependencies:
|
|
271
|
+
|
|
272
|
+
```bash
|
|
273
|
+
# Rebuild and verify zipapp integrity
|
|
274
|
+
python3 scripts/build_pyz.py
|
|
275
|
+
python3 -c "import zipfile; assert zipfile.ZipFile('bin/mipmem.pyz').testzip() is None"
|
|
276
|
+
python3 ./bin/mipmem.pyz health --deep --json
|
|
277
|
+
|
|
278
|
+
# Validate Native Plugin bundle, Clean-Room Git history, Release readiness & full unittest suite
|
|
279
|
+
PYTHONPATH=src python3 -c "import mipmem; from mipmem.adapters.plugin_manifest import assert_valid_plugin_bundle; assert_valid_plugin_bundle('.', expected_version=mipmem.__version__)"
|
|
280
|
+
python3 scripts/check_cleanroom.py --git-history
|
|
281
|
+
python3 scripts/verify_release.py .
|
|
282
|
+
PYTHONPATH=src:. python3 -m unittest discover -s tests -v
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
### Continuous Integration & Dual-Channel OIDC Releases
|
|
286
|
+
|
|
287
|
+
- **CI Quality Gate ([.github/workflows/ci.yml](.github/workflows/ci.yml)):** Runs `py_compile` (across all modules including `sync/`), `flake8`, `pyright`, `scripts/check_cleanroom.py`, `scripts/verify_release.py .`, `assert_valid_plugin_bundle()`, zero-dep `unittest` across **Python `3.9–3.13`** plus **`macos-latest`**, and byte-for-byte `.pyz` determinism checks.
|
|
288
|
+
- **OIDC Release Pipeline ([.github/workflows/release.yml](.github/workflows/release.yml)):** Triggered by `v*` tags (`fetch-depth: 0`), rebuilds & verifies deterministic `bin/mipmem.pyz`, builds `.whl`/`.tar.gz`, generates `SHA256SUMS`, runs `check_cleanroom.py --git-history --dist-dir dist` and `verify_release.py . --dist-dir dist`, publishes GitHub Releases with build provenance attestations, and publishes to PyPI via **OIDC Trusted Publishing** (`id-token: write`, PEP 740 `attestations: true`, zero static tokens).
|
|
289
|
+
|
|
290
|
+
---
|
|
291
|
+
|
|
292
|
+
## License
|
|
293
|
+
|
|
294
|
+
Released under the [MIT License](LICENSE).
|
mipmem-1.0.0/README.md
ADDED
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
# MipMem
|
|
2
|
+
|
|
3
|
+
[](https://github.com/pageel/mipmem/actions/workflows/ci.yml)
|
|
4
|
+
[](LICENSE)
|
|
5
|
+
|
|
6
|
+
[English](README.md) | [Tiếng Việt](README.vi.md)
|
|
7
|
+
|
|
8
|
+
<!-- ⚠️ SOURCE-VERIFIED — Cross-referenced with src/mipmem/, plugin.json, hooks.json, mcp_config.json, scripts/, .github/workflows/ on 2026-11-25 -->
|
|
9
|
+
|
|
10
|
+
**Zero-dependency, zero-LLM-cost 4-layer mipmapped cognitive memory engine with a conflict-free sharded multi-host vault, multi-host Git/folder sync, RCE-safe private sub-apps, opt-in self-update, sub-5ms bilingual SQLite FTS5 recall, Native Antigravity Plugin, and Universal Local stdio MCP server.**
|
|
11
|
+
|
|
12
|
+
MipMem is built strictly on the **Python >= 3.9 standard library** (`dependencies = []`) and ships across both PyPI and standalone single-file `.pyz` zipapp bundles engineered for sub-25ms hot-path CLI and hook execution.
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## Key Architecture & Safety Guarantees (`v1.0.0`)
|
|
17
|
+
|
|
18
|
+
- **Zero External Dependencies & Zero LLM Cost:** Runs anywhere Python `>= 3.9` is installed with zero runtime packages (`dependencies = []`) and zero embedding or LLM API calls.
|
|
19
|
+
- **4-Layer Mipmap Engine (`L0 → L3`):**
|
|
20
|
+
- `L0` startup radar strictly bounded by `budget.l0_max_tokens` (default `300`), incorporating collapsed or alert-driven Sub-App telemetry and sync conflict warnings.
|
|
21
|
+
- `L1` structural skeleton cards with `#Lstart-Lend` pointers strictly bounded by `budget.l1_max_tokens` (default `450`), truncated on line boundaries without ever leaving unclosed Markdown fenced code blocks.
|
|
22
|
+
- `L2` surgical section (`§k`) and line-range (`#Lstart-Lend`) slicing, plus lossless `L3` full-document access.
|
|
23
|
+
- **Per-Host Private Sub-Apps Contract (`core/subapps.py`):**
|
|
24
|
+
- Keeps core OS-agnostic while allowing machine-specific health monitors (`hosts/<host_id>/telemetry/<app_id>.status.json` + safe `detail_file` path guard inside `host_dir`) to surface in `L0 Radar`, `/mem fleet`, `mipmem fleet --json`, and `mem_fleet_status`.
|
|
25
|
+
- Allows machine-local `/mem <app>` delegates via `<config_dir>/apps.d/*.json` only (never read from the synced Vault), verifying POSIX UID ownership, non-group/world-writable permissions (`mode & 0o022 == 0`), `shell=False`, timeout caps (`5s` default, `15s` hard max), secret redaction, and collision protection against core `/mem` commands.
|
|
26
|
+
- **Conflict-Free Multi-Host Vault & Git/Folder Sync (`mipmem.sync`):**
|
|
27
|
+
- Strict single-writer layout (`hosts/<host_id>/`, `shared/brainstorms/by-host/<host_id>/`) with local gitignored `.cache/global_fts.db`.
|
|
28
|
+
- **`GitSyncBackend`:** Uses `GIT_TERMINAL_PROMPT=0` (OS SSH-Agent / Credential Helper, zero stored PATs), `fcntl.flock` on `<cache_dir>/sync.lock`, `core.filemode=false`, single-writer staging, `git pull --rebase --autostash`, automatic `git rebase --abort` + `sync_status.json` conflict alert on manual shared edits, and detached `Stop`-hook sync (`start_new_session=True`, `0ms` foreground UI block).
|
|
29
|
+
- **`FolderSyncBackend`:** Bi-directional atomic single-writer sync across Syncthing, Tailscale Drive, or shared local directories (`[sync].folder_path`), ignoring `.cache/` and `.git/`, preventing nested-vault recursion, and skipping escaping symlinks.
|
|
30
|
+
- **Opt-In Verified Self-Update (`core/updater.py`):**
|
|
31
|
+
- Strictly opt-in (`mipmem self-update [--check | --dry-run | --version <tag>]`). Enforces HTTPS allowlists to official `pageel/mipmem` GitHub Releases, verifies `SHA256SUMS` (`hmac.compare_digest`), checks `ZipFile.testzip()`, runs pre-swap `health --json` in isolation, atomically swaps via `os.replace()`, and refuses modifying `uv`/`pipx`/`pip`/Plugin/git-dev installs (printing the channel-appropriate upgrade command instead).
|
|
32
|
+
- **Dual CLI/IDE Transcript Adapters & Unified `user_markdown` Hooks (`mipmem.adapters`):**
|
|
33
|
+
- **CLI & IDE Harvesters:** Opens `conversation_summaries.db` read-only (`mode=ro`, skips subagents) and streams `transcript.jsonl` + lazy `transcript_full.jsonl` expansion (never auto-scanning `artifactDirectoryPath`).
|
|
34
|
+
- **Fail-Open Hooks & `/mem` Intercept:** Runs `SessionStart`, `PreInvocation`, and `Stop` fail-open (`{}` + exit `0`), intercepts `/mem ...` via `metadata.user_markdown` + `terminationBehavior: "terminate"`, and enforces `disabled > passive > active` workspace policies.
|
|
35
|
+
- **Universal Local Memory MCP Server (`mipmem mcp`):**
|
|
36
|
+
- Pure stdlib JSON-RPC 2.0 `stdio` server auto-detecting `NDJSON` and `Content-Length` framing (`<= 4 MB`, zero stray stdout logs, `CP-MCP-01`) with 6 canonical tools (`mem_recall`, `mem_bs_list`, `mem_bs_slice`, `mem_bs_save`, `mem_handoff`, `mem_fleet_status`).
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## Installation (4 Channels)
|
|
41
|
+
|
|
42
|
+
### 1. PyPI (`uv`, `pipx`, or `pip`)
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
# Recommended CLI tool installs (isolated environments)
|
|
46
|
+
uv tool install mipmem
|
|
47
|
+
# or
|
|
48
|
+
pipx install mipmem
|
|
49
|
+
# or standard pip
|
|
50
|
+
python3 -m pip install mipmem
|
|
51
|
+
|
|
52
|
+
mipmem health --json
|
|
53
|
+
mipmem init --host workstation-alpha --json
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### 2. Standalone `.pyz` Zipapp (GitHub Releases)
|
|
57
|
+
|
|
58
|
+
Download `mipmem.pyz` and `SHA256SUMS` from [GitHub Releases](https://github.com/pageel/mipmem/releases):
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
sha256sum -c SHA256SUMS --ignore-missing
|
|
62
|
+
python3 ./mipmem.pyz health --json
|
|
63
|
+
python3 ./mipmem.pyz init --host workstation-alpha --json
|
|
64
|
+
|
|
65
|
+
# Check for or apply opt-in updates later (zipapp mode only)
|
|
66
|
+
python3 ./mipmem.pyz self-update --check --json
|
|
67
|
+
python3 ./mipmem.pyz self-update
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Always invoke `.pyz` files explicitly with `python3` so execution stays portable across Linux, macOS, WSL, and shared mounts regardless of filesystem executable bits.
|
|
71
|
+
|
|
72
|
+
### 3. Native Antigravity Plugin (CLI & IDE)
|
|
73
|
+
|
|
74
|
+
This repository root is a self-contained Native Antigravity Plugin (`plugin.json`, `hooks.json`, `mcp_config.json`, `rules/AGENTS.md`, `skills/mem/SKILL.md`, and `bin/mipmem.pyz`):
|
|
75
|
+
|
|
76
|
+
1. Clone or link the repository directory into your Antigravity plugins directory (e.g., `~/.gemini/config/plugins/mipmem` or `.agents/plugins/mipmem`) or register its path in `plugins.json`.
|
|
77
|
+
2. Initialize your vault once (`python3 ./bin/mipmem.pyz init --host workstation-alpha`).
|
|
78
|
+
3. Antigravity loads `hooks.json`, `mcp_config.json`, `rules/AGENTS.md`, and `skills/mem/SKILL.md` automatically in an isolated plugin scope without modifying `~/.agents/hooks.json` or `~/.bash_aliases`.
|
|
79
|
+
|
|
80
|
+
> **Safe Opt-In Artifact Capture:** `Stop` hooks never auto-scan `artifactDirectoryPath`. To persist a design or research artifact into the Brainstorm Vault, confirm the agent's suggestion (`mem_bs_save(title=..., file_path=...)`) or run `/mem bs save "<title>" --file <path>` directly.
|
|
81
|
+
|
|
82
|
+
### 4. Universal Local MCP Server (Claude Code, Cursor, Gemini CLI, Antigravity)
|
|
83
|
+
|
|
84
|
+
Point any stdio-compatible MCP client at `mipmem mcp` (or `bin/mipmem.pyz mcp`):
|
|
85
|
+
|
|
86
|
+
```json
|
|
87
|
+
{
|
|
88
|
+
"mcpServers": {
|
|
89
|
+
"mipmem": {
|
|
90
|
+
"command": "python3",
|
|
91
|
+
"args": ["/path/to/mipmem/bin/mipmem.pyz", "mcp"]
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Exposed MCP tools: `mem_recall`, `mem_bs_list`, `mem_bs_slice`, `mem_bs_save`, `mem_handoff`, and `mem_fleet_status`.
|
|
98
|
+
|
|
99
|
+
---
|
|
100
|
+
|
|
101
|
+
## In-Chat `/mem` Slash Commands (0 LLM Tokens)
|
|
102
|
+
|
|
103
|
+
| Command | Description |
|
|
104
|
+
| :--- | :--- |
|
|
105
|
+
| `/mem help` | Display core `/mem` subcommands and any trusted local `apps.d` delegates |
|
|
106
|
+
| `/mem status` | Show vault status, active host, known hosts, and FTS5 capability |
|
|
107
|
+
| `/mem fleet` | Show multi-host session/brainstorm inventory, Sub-App telemetry, and sync state |
|
|
108
|
+
| `/mem sync [--pull-only \| --push-only]` | Run configured Git or Folder vault synchronization |
|
|
109
|
+
| `/mem recall <query> [--host <h>] [--limit <n>]` | Run EN/VI FTS5 BM25 Bigram recall |
|
|
110
|
+
| `/mem list [start-end]` | List recent sessions (default `1-10`, compact GFM table on CLI) |
|
|
111
|
+
| `/mem bs list [--status <s>] [--host <h>]` | List lossless brainstorm shards with LWW status |
|
|
112
|
+
| `/mem bs save <title> [--file <path>] [--tags a,b]` | Save redacted inline text or a UTF-8 file (`<= 2 MB`, non-symlink) |
|
|
113
|
+
| `/mem bs view <bs_id> [§k \| #Lstart-Lend \| --l1]` | View L1 outline card or surgical L2 section/line slice |
|
|
114
|
+
| `/mem bs status <bs_id> <status>` | Append a conflict-free status event to the active host journal |
|
|
115
|
+
| `/mem config [show \| get <k> \| set <k> <v>]` | View or update typed settings in `config.toml` |
|
|
116
|
+
| `/mem handoff [@<host_id>]` | Display the latest `Primary Work Anchor` handoff for a host |
|
|
117
|
+
| `/mem <app> [args...]` | Execute a trusted local `~/.config/mipmem/apps.d/<app>.json` delegate |
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
## CLI Reference (`v1.0.0`)
|
|
122
|
+
|
|
123
|
+
| Command | Purpose |
|
|
124
|
+
| :--- | :--- |
|
|
125
|
+
| `mipmem init [--host <id>] [--vault <dir>] [--json]` | Initialize `config.toml` and create host-isolated vault directories (`0700`/`0600` best-effort) |
|
|
126
|
+
| `mipmem config [show \| get <k> \| set <k> <v>] [--json]` | Display, read, or validate & persist typed settings in `config.toml` |
|
|
127
|
+
| `mipmem health [--vault <dir>] [--require-vault] [--deep] [--json]` | Fast `< 25ms` check, or `--deep` FTS5, index, `sync_backend`, `last_sync_status`, and `subapp_delegates_count` probe |
|
|
128
|
+
| `mipmem fleet [--host <id>] [--vault <dir>] [--json]` | Output multi-host inventory, Sub-App telemetry, and cached sync status |
|
|
129
|
+
| `mipmem sync [--pull-only \| --push-only \| --detached] [--host <id>] [--vault <dir>] [--json]` | Execute conflict-free Git or Folder vault synchronization |
|
|
130
|
+
| `mipmem self-update [--check \| --dry-run \| --version <tag>] [--json]` | Check for releases or atomically update a standalone zipapp (`SHA256SUMS` + `testzip()` + pre-swap `health`) |
|
|
131
|
+
| `mipmem migrate --from-v2 <dir> [--vault <dir>] [--host <id>] [--apply] [--force] [--json]` | Preview (`--dry-run` default) or idempotently import a legacy v2 flat memory directory |
|
|
132
|
+
| `mipmem index [--rebuild] [--locale en\|vi] [--vault <dir>] [--json]` | Incrementally sync (or `--rebuild`) `.cache/global_fts.db` from the Sharded Vault |
|
|
133
|
+
| `mipmem recall <query> [--host <id>] [--status <st>] [--limit <N>] [--scope all\|sessions\|brainstorms] [--locale en\|vi] [--json]` | Run sanitized EN/VI FTS5 BM25 Bigram recall and return ranked `L1` memory hits |
|
|
134
|
+
| `mipmem bs [list \| save \| view \| status] [...] [--json]` | Manage lossless brainstorm shards, surgical `L2` slices, and conflict-free status events |
|
|
135
|
+
| `mipmem hook <session-start \| pre-invocation \| stop>` | Run Antigravity lifecycle hooks over `stdin`/`stdout` JSON with sub-25ms no-op skip & fail-open `{}` |
|
|
136
|
+
| `mipmem mcp [--vault <dir>]` | Run the universal local stdio JSON-RPC 2.0 MCP server (`NDJSON` & `Content-Length`) |
|
|
137
|
+
|
|
138
|
+
Errors on standard CLI commands return a non-zero exit code; when `--json` is passed, errors emit a structured envelope on `stdout`:
|
|
139
|
+
|
|
140
|
+
```json
|
|
141
|
+
{"success": false, "error": {"code": "VAULT_NOT_INITIALIZED", "message": "..."}}
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
---
|
|
145
|
+
|
|
146
|
+
## Directory Resolution, Configuration & Vault Sync
|
|
147
|
+
|
|
148
|
+
MipMem resolves runtime directories consistently across CLI, hooks, and MCP integrations in strict precedence order:
|
|
149
|
+
|
|
150
|
+
1. Explicit overrides: `MIPMEM_CONFIG_DIR`, `MIPMEM_VAULT_DIR`, `MIPMEM_CACHE_DIR`
|
|
151
|
+
2. `[core].vault_path` in `config.toml` (for `vault_dir`)
|
|
152
|
+
3. XDG directories: `XDG_CONFIG_HOME/mipmem`, `XDG_DATA_HOME/mipmem/vault`, `XDG_CACHE_HOME/mipmem`
|
|
153
|
+
4. Writable home defaults: `~/.config/mipmem`, `~/.local/share/mipmem/vault`, `~/.cache/mipmem`
|
|
154
|
+
5. Fallback (`PLUGIN_DATA/{config,vault,cache}`) only when `$HOME` is unset or non-writable
|
|
155
|
+
|
|
156
|
+
Starter configuration template: copy [config.example.toml](config.example.toml) to `~/.config/mipmem/config.toml` and customize:
|
|
157
|
+
|
|
158
|
+
- `[core].locale`: `"en"` or `"vi"` (enables Vietnamese `đ/Đ` FTS5 folding and lexicon packs)
|
|
159
|
+
- `[budget]`: `l0_max_tokens`, `l1_max_tokens`, `topic_shift_novelty`
|
|
160
|
+
- `[workspace_policies]`: `active` | `passive` | `disabled` (`disabled > passive > default`)
|
|
161
|
+
- `[sync]`:
|
|
162
|
+
- `backend = "git"` + `vault_remote_url = "git@github.com:example-user/my-mipmem-vault.git"` + `auto_sync_on_stop = true` (uses OS SSH-Agent or Git Credential Helper; zero PATs stored)
|
|
163
|
+
- or `backend = "folder"` + `folder_path = "/path/to/shared-sync-folder"` (for Syncthing, Tailscale Drive, or local shared folders)
|
|
164
|
+
|
|
165
|
+
---
|
|
166
|
+
|
|
167
|
+
## Repository Layout
|
|
168
|
+
|
|
169
|
+
```text
|
|
170
|
+
.
|
|
171
|
+
├── .github/
|
|
172
|
+
│ ├── PULL_REQUEST_TEMPLATE.md # Standard OSS PR verification checklist
|
|
173
|
+
│ └── workflows/
|
|
174
|
+
│ ├── ci.yml # Lint, pyright, clean-room, verify_release, Python 3.9–3.13 + macOS matrix & .pyz determinism
|
|
175
|
+
│ └── release.yml # Tag-triggered Dual-Channel Release: GitHub Releases (provenance + SHA256SUMS) & PyPI OIDC + PEP 740
|
|
176
|
+
├── plugin.json # Native Antigravity Plugin manifest (v1.0.0)
|
|
177
|
+
├── hooks.json # Flat SessionStart / PreInvocation / Stop hook bindings
|
|
178
|
+
├── mcp_config.json # Local stdio MCP server binding (bin/mipmem.pyz mcp)
|
|
179
|
+
├── rules/
|
|
180
|
+
│ └── AGENTS.md # Concise plain-Markdown plugin rules & opt-in artifact guard
|
|
181
|
+
├── skills/
|
|
182
|
+
│ └── mem/
|
|
183
|
+
│ └── SKILL.md # /mem slash command & 6 MCP tools skill reference
|
|
184
|
+
├── config.example.toml # Clean starter config template
|
|
185
|
+
├── pyproject.toml # Python >= 3.9, dependencies = [], Pageel Contributors metadata
|
|
186
|
+
├── README.md # English-first OSS documentation
|
|
187
|
+
├── README.vi.md # Vietnamese community guide
|
|
188
|
+
├── CHANGELOG.md # Keep a Changelog history through v1.0.0
|
|
189
|
+
├── LICENSE # MIT License
|
|
190
|
+
├── bin/mipmem.pyz # Deterministic single-file zipapp binary (v1.0.0)
|
|
191
|
+
├── scripts/
|
|
192
|
+
│ ├── build_pyz.py # Deterministic zipapp bundler
|
|
193
|
+
│ ├── check_cleanroom.py # Tree, archive (.pyz/.zip/.whl/.tar.gz), and --git-history clean-room scanner
|
|
194
|
+
│ └── verify_release.py # Dual-channel release parity, OIDC, and SHA256SUMS validator
|
|
195
|
+
├── src/mipmem/
|
|
196
|
+
│ ├── __init__.py
|
|
197
|
+
│ ├── __main__.py # `python3 -m mipmem` entrypoint
|
|
198
|
+
│ ├── cli.py # Fast-path router (< 25ms health & hook no-op, zero heavy imports)
|
|
199
|
+
│ ├── cli_commands.py # Lazy CLI subcommands (init/config/health/fleet/sync/self-update/migrate/index/recall/bs/hook/mcp)
|
|
200
|
+
│ ├── config.py # XDG resolver, zero-dep TOML codec & policy evaluator
|
|
201
|
+
│ ├── core/
|
|
202
|
+
│ │ ├── diagnostics.py # Rotating JSONL logger & S1–S4 error taxonomy (25 codes, CP-* checkpoints)
|
|
203
|
+
│ │ ├── redactor.py # Pre-write secret redactor & $HOME normalization
|
|
204
|
+
│ │ ├── vault.py # Sharded vault init, atomic I/O & mutation journal
|
|
205
|
+
│ │ ├── migrate_v2.py # Non-destructive, idempotent v2 importer
|
|
206
|
+
│ │ ├── sessions.py # Canonical Session Frontmatter v1 parser & vault writer
|
|
207
|
+
│ │ ├── salience.py # Dual-Anchor Salience scorer & Brainstorm Bonus
|
|
208
|
+
│ │ ├── workstreams.py # Cross-host Jaccard workstream threading & compaction
|
|
209
|
+
│ │ ├── brainstorms.py # Fence-Aware Markdown AST (§1 skip H1) & sharded store
|
|
210
|
+
│ │ ├── mipmap.py # Token-budgeted L0/L1 renderer & surgical L2 slicer
|
|
211
|
+
│ │ ├── fts_recall.py # Incremental FTS5 indexer, LWW projection, BM25 bigram recall & Topic-Shift gate
|
|
212
|
+
│ │ ├── subapps.py # Per-host telemetry reader, L0/fleet presenter & RCE-safe apps.d delegator
|
|
213
|
+
│ │ └── updater.py # Opt-in release manifest guard & atomic zipapp self-updater
|
|
214
|
+
│ ├── sync/
|
|
215
|
+
│ │ ├── __init__.py # Lightweight package marker (zero eager imports)
|
|
216
|
+
│ │ ├── base.py # SyncBackend Protocol, acquire_sync_lock & atomic sync_status.json store
|
|
217
|
+
│ │ ├── git_backend.py # Conflict-free GitSyncBackend & detached Stop-hook worker
|
|
218
|
+
│ │ └── folder_backend.py # Single-writer FolderSyncBackend (Syncthing/shared dir)
|
|
219
|
+
│ ├── adapters/
|
|
220
|
+
│ │ ├── __init__.py # Lightweight package marker (zero eager imports)
|
|
221
|
+
│ │ ├── base.py # NormalizedConversation schema, TranscriptAdapter Protocol & surface detector
|
|
222
|
+
│ │ ├── agy_cli.py # Read-only SQLite CLI harvester (mode=ro, skips subagents) + JSONL fallback
|
|
223
|
+
│ │ ├── agy_ide.py # IDE transcript.jsonl + transcript_full.jsonl harvester (no artifact auto-scan)
|
|
224
|
+
│ │ ├── slash_mem.py # Shell-free /mem dispatcher (fleet, sync, bs, handoff & apps.d delegates)
|
|
225
|
+
│ │ ├── hook_io.py # Unified user_markdown renderer, SessionStart/PreInvocation/Stop & fail-open runner
|
|
226
|
+
│ │ └── plugin_manifest.py # Automated Native Plugin bundle validator
|
|
227
|
+
│ ├── mcp/
|
|
228
|
+
│ │ ├── __init__.py
|
|
229
|
+
│ │ ├── server.py # Auto-framing stdio JSON-RPC 2.0 server (NDJSON & Content-Length)
|
|
230
|
+
│ │ └── tools.py # 6 lazy local memory MCP tools (mem_recall..mem_fleet_status)
|
|
231
|
+
│ └── i18n/
|
|
232
|
+
│ ├── __init__.py # LocaleLexicon registry & tokenizer/bigram helpers
|
|
233
|
+
│ ├── en.py # English stop-words, intent & brainstorm cues
|
|
234
|
+
│ └── vi.py # Vietnamese đ/Đ FTS5 folder, normalizer & lexicon cues
|
|
235
|
+
└── tests/ # Zero-dependency standard-library unittest test suite
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
---
|
|
239
|
+
|
|
240
|
+
## Development & Verification
|
|
241
|
+
|
|
242
|
+
Run all stdlib checks directly from the repository root without external runtime dependencies:
|
|
243
|
+
|
|
244
|
+
```bash
|
|
245
|
+
# Rebuild and verify zipapp integrity
|
|
246
|
+
python3 scripts/build_pyz.py
|
|
247
|
+
python3 -c "import zipfile; assert zipfile.ZipFile('bin/mipmem.pyz').testzip() is None"
|
|
248
|
+
python3 ./bin/mipmem.pyz health --deep --json
|
|
249
|
+
|
|
250
|
+
# Validate Native Plugin bundle, Clean-Room Git history, Release readiness & full unittest suite
|
|
251
|
+
PYTHONPATH=src python3 -c "import mipmem; from mipmem.adapters.plugin_manifest import assert_valid_plugin_bundle; assert_valid_plugin_bundle('.', expected_version=mipmem.__version__)"
|
|
252
|
+
python3 scripts/check_cleanroom.py --git-history
|
|
253
|
+
python3 scripts/verify_release.py .
|
|
254
|
+
PYTHONPATH=src:. python3 -m unittest discover -s tests -v
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
### Continuous Integration & Dual-Channel OIDC Releases
|
|
258
|
+
|
|
259
|
+
- **CI Quality Gate ([.github/workflows/ci.yml](.github/workflows/ci.yml)):** Runs `py_compile` (across all modules including `sync/`), `flake8`, `pyright`, `scripts/check_cleanroom.py`, `scripts/verify_release.py .`, `assert_valid_plugin_bundle()`, zero-dep `unittest` across **Python `3.9–3.13`** plus **`macos-latest`**, and byte-for-byte `.pyz` determinism checks.
|
|
260
|
+
- **OIDC Release Pipeline ([.github/workflows/release.yml](.github/workflows/release.yml)):** Triggered by `v*` tags (`fetch-depth: 0`), rebuilds & verifies deterministic `bin/mipmem.pyz`, builds `.whl`/`.tar.gz`, generates `SHA256SUMS`, runs `check_cleanroom.py --git-history --dist-dir dist` and `verify_release.py . --dist-dir dist`, publishes GitHub Releases with build provenance attestations, and publishes to PyPI via **OIDC Trusted Publishing** (`id-token: write`, PEP 740 `attestations: true`, zero static tokens).
|
|
261
|
+
|
|
262
|
+
---
|
|
263
|
+
|
|
264
|
+
## License
|
|
265
|
+
|
|
266
|
+
Released under the [MIT License](LICENSE).
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "mipmem"
|
|
7
|
+
version = "1.0.0"
|
|
8
|
+
description = "Zero-Token, Zero-Dependency 4-Layer Mipmapped Cognitive Memory Engine for AI Agents"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.9"
|
|
11
|
+
license = { text = "MIT" }
|
|
12
|
+
authors = [{ name = "Pageel Contributors" }]
|
|
13
|
+
keywords = [
|
|
14
|
+
"ai-agents",
|
|
15
|
+
"memory",
|
|
16
|
+
"mcp",
|
|
17
|
+
"sqlite",
|
|
18
|
+
"fts5",
|
|
19
|
+
"antigravity",
|
|
20
|
+
"cognitive-memory",
|
|
21
|
+
]
|
|
22
|
+
classifiers = [
|
|
23
|
+
"Development Status :: 5 - Production/Stable",
|
|
24
|
+
"Environment :: Console",
|
|
25
|
+
"Intended Audience :: Developers",
|
|
26
|
+
"License :: OSI Approved :: MIT License",
|
|
27
|
+
"Operating System :: OS Independent",
|
|
28
|
+
"Programming Language :: Python :: 3",
|
|
29
|
+
"Programming Language :: Python :: 3.9",
|
|
30
|
+
"Programming Language :: Python :: 3.10",
|
|
31
|
+
"Programming Language :: Python :: 3.11",
|
|
32
|
+
"Programming Language :: Python :: 3.12",
|
|
33
|
+
"Programming Language :: Python :: 3.13",
|
|
34
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
35
|
+
]
|
|
36
|
+
dependencies = []
|
|
37
|
+
|
|
38
|
+
[project.urls]
|
|
39
|
+
Homepage = "https://github.com/pageel/mipmem"
|
|
40
|
+
Repository = "https://github.com/pageel/mipmem"
|
|
41
|
+
Issues = "https://github.com/pageel/mipmem/issues"
|
|
42
|
+
Changelog = "https://github.com/pageel/mipmem/blob/main/CHANGELOG.md"
|
|
43
|
+
|
|
44
|
+
[project.scripts]
|
|
45
|
+
mipmem = "mipmem.cli:main"
|
|
46
|
+
|
|
47
|
+
[tool.setuptools.packages.find]
|
|
48
|
+
where = ["src"]
|
mipmem-1.0.0/setup.cfg
ADDED