Files
mnemazine/README.md
T
zarubinvibeandЗарубин Филипп 3b7c85bae5 feat(telegram): intake bot + Mini App + guided installer (#2)
* feat(telegram): bot intake → inbox + daily VPS pull sync

- mnemazine-telegram-bot.mjs: zero-dep long-poll bot, writes text/photo/doc/voice/audio/video into staging inbox; chat_id allowlist; --selftest
- mnemazine-telegram-sync.sh: daily rsync pull VPS buffer → local inbox, then npm run run
- launchd plist template for daily 09:00 schedule

* feat(telegram): Mini App — status/send/run-now + reverse-channel poller

- webapp/index.html: Telegram Mini App (theme-aware, minimal); buffer status, send-to-inbox, run-now
- mnemazine-webapp-server.mjs: localhost API, initData HMAC verify + user allowlist, /api/{status,send,run}; --selftest
- run-now reverse channel: API touches .run-now; poll.sh consumes flag, Mac pulls+runs
- poll.sh: 5-min launchd tick — manual flag or daily 09:00 window; writes .last-run for app
- sync.sh: drop exec so markers persist; plist → StartInterval 300

* docs: Telegram intake architecture (bot + Mini App), EN+RU, no secrets

Generic scheme — host/secrets/domain abstracted. Linked from both READMEs.

* feat(setup): guided step-by-step installer for fresh devices

- setup.sh: staged wizard, numbered-menu questions, gates each stage
- checks prereqs and says exactly what to install before continuing
- missing capability → 'Друг, значит этого тебе не оставим' + continue
- asks inbox location (repo vs Desktop); optional Telegram bot incl. VPS deploy
- MNEMAZINE_SETUP_DRYRUN=1 walks stages without installing/deploying
- README EN+RU point to it

* fix(telegram): C1/C2 — secrets out of git, two-phase move (no data loss)

Phase 0+1.1 of audit fix plan:
- poll.sh/sync.sh: drop hardcoded VPS host/key → placeholders + gitignored .mnemazine/config.env (fail-fast on placeholder)
- sync.sh: two-phase move — pull to staging, promote, run protocol, delete on VPS ONLY after success (closes --remove-source-files data-loss window); deletes only files it took
- config.env.example template; .mnemazine/config.env gitignored
- selftest chat_id fixture 1 → 1 (was real personal id)

* fix(telegram): C3/C4 — kill stored-XSS + initData replay window

- webapp: render inbox file names via textContent/createElement (was innerHTML — file names come from untrusted Telegram uploads); add strict CSP meta
- webapp-server: verifyInitData now rejects stale auth_date (default 24h TTL, MNEMAZINE_INITDATA_TTL); closes forever-valid captured initData
- selftest: assert stale initData rejected (C7 — test from the threat, not current behavior)

* fix(telegram): C5 reliability — stop storm, TTY-guard, fail-closed, DoS caps

Phase 2:
- poll.sh: write daily marker BEFORE sync (no 5-min storm on failure); mkdir single-flight lock (macOS has no flock) with 60-min stale steal; re-queue manual run-now on failure. plist: RunAtLoad
- setup.sh: read EOF/TTY guard (no infinite loop under curl|bash/CI); gate install.sh exit code (stage actually gates)
- bot: advance/persist offset only AFTER successful handle (at-least-once, no dropped message); fail-closed allowlist (empty = reject + log id, not accept-all); cap download size 30MB; sanitize file extension (no traversal)
- webapp-server: cap request body 64KB (413); 500 returns generic error, detail to stderr only

* feat(telegram): C6 vault-patterns — run audit, config.env boundary, idempotent setup

Phase 3:
- /api/run: flag now carries {at, by} audit (kept as coalescing flag, not a full job queue — single user/button; YAGNI)
- 3.2 fenceUntrusted already covered: digest/synthesize fence note bodies at the LLM boundary (mnemazine-llm.mjs); inbox stays raw by design
- setup.sh: writes .mnemazine/config.env (chmod 600) from entered VPS details so poll/sync read the boundary; idempotent pm2 (start||restart) for rerun-safe deploy

* feat(telegram): Phase 4 polish — confirm run, auto-refresh, access log, throttle

- frontend: tg.showConfirm before run (no accidental token-spend); auto-refresh status every 15s while visible + on visibilitychange
- server: structured access log (stderr {ts,user,method,path}); light per-user 1/sec write throttle (429)

---------

Co-authored-by: Зарубин Филипп <289370046+zarubinphil@users.noreply.github.com>
2026-06-19 13:03:46 +03:00

12 KiB

Mnemazine

🇬🇧 English · 🇷🇺 Русский

Mnemazine — Mnemosyne, goddess of memory, beside her marble column, distilling raw fragments into a layered knowledge system

Mnemazine is an open-source personal memory system, named after Mnemosyne, the Greek goddess of memory and mother of the Muses.

The idea behind it is simple. Most people pile up notes, screenshots, and saved links and never look at them again. A pile is not memory. Real memory is what happens when you take something raw, understand it, check it, connect it to what you already know, and write down only the part worth keeping. Mnemazine does that part for you at the moment of saving.

The technique has a name — synthesis on write — popularized by Andrej Karpathy: don't dump and hope to read it later; distill the essence as you capture it, so the note is already useful the next time you open it.

In practice, Mnemazine takes screenshots, PDFs, web pages, YouTube videos, notes, guides, and GitHub repositories and turns them into a clean, Obsidian-compatible knowledge base. It extracts text locally first, keeps a source hash so you always know where a fact came from, stores only finished notes, links them into a graph, and refuses to let raw OCR or messy drafts leak into your vault.

Memory, not a dump.

Synthesis on write: many raw fragments are squeezed through to a single durable note

What It Is

Mnemazine is a local-first knowledge refinery. Material goes in raw; finished knowledge comes out.

It does not save raw OCR into your vault. It does not keep vague summaries that are impossible to reuse. It tries to produce finished knowledge:

  • clear notes with understandable titles;
  • source links and verification status;
  • topic-based atomization when one source contains many ideas;
  • reusable skill descriptions, agent instructions, implementation notes, and project actions;
  • Graphify maps for semantic navigation;
  • weekly HTML briefings with local state: read, work on it, forget.

The goal is simple: future you should not reread twenty screenshots, a whole guide, or a messy transcript. Future you should open one good note and immediately understand what the knowledge is, why it matters, how to use it, and what evidence supports it.

Why It Saves Tokens

Mnemazine saves tokens by moving work out of repeated LLM context and into durable local structure: parse locally, cache aggressively, store refined atoms, retrieve narrowly.

Token economics: parse locally, hash cache, store atoms, retrieve narrowly

Typical savings come from:

  • Local extraction first: Apple Vision OCR, PDF parsing, transcription, hashing, and file census happen locally when possible.
  • Hash cache: repeated files are detected before LLM processing. A duplicate costs zero model tokens.
  • Atomization: one long guide can become twenty focused notes, so future prompts pull only the relevant atom.
  • Graphify context: the agent can query a graph instead of dumping the whole vault into context.
  • Final notes only: raw OCR and noisy transcripts stay outside the vault. The vault stores condensed, verified, human-readable knowledge.
  • Weekly briefs: the system surfaces what changed and what deserves action, so the user does not ask the model to rediscover the week.

In real workflows, this often turns huge source piles into compact reusable notes. The exact savings depend on source size, but the operating principle is reliable: parse locally, cache aggressively, store refined atoms, retrieve narrowly.

Install

Clone the project into the only folder you need:

git clone https://github.com/zarubinphil/Mnemazine.git "$HOME/Desktop/Mnemazine"
cd "$HOME/Desktop/Mnemazine"
bash setup.sh        # guided, step-by-step (asks where the inbox goes, optional Telegram bot)
# or: bash install.sh   # non-interactive skeleton only

setup.sh walks a fresh device through setup in clear stages: it checks prerequisites, tells you exactly what to install when something is missing, asks where to put the inbox/ (inside the repo or on the Desktop), and can deploy the Telegram bot to a VPS. Preview a run without touching anything: MNEMAZINE_SETUP_DRYRUN=1 bash setup.sh.

After installation, open this folder as an Obsidian vault:

~/Desktop/Mnemazine/vault

Everything lives under ~/Desktop/Mnemazine by default:

  • inbox/ for raw inputs;
  • vault/ for finished knowledge;
  • reports/ for HTML weekly briefings;
  • .mnemazine/ for caches, binaries, and local state;
  • skills/, agents/, workflows/, and scripts/ for the agent system.

Requirements

  • macOS is recommended for Apple Vision OCR.
  • Linux works for site parsing, markdown processing, Graphify, and vault operations, but Apple Vision OCR is skipped.
  • Node.js 20+.
  • Python 3.11+.
  • Git.
  • Optional: Obsidian, Claude Code, Codex, Cursor, OpenCode, Gemini CLI.

The installer checks what exists and installs what it can safely install locally. It does not require private credentials.

One-Command Local Run

Put files into:

~/Desktop/Mnemazine/inbox

Then run:

node scripts/mnemazine-run.mjs

The run performs:

  1. file census;
  2. SHA-256 duplicate detection;
  3. local extraction when possible;
  4. final note creation with source_ref and source_hash;
  5. vault quality gate;
  6. archive move only after the quality gate passes;
  7. guarded Graphify refresh attempt;
  8. weekly HTML report regeneration;
  9. report quality gate for the regenerated weekly HTML;
  10. action brief at .mnemazine/state/last-action-brief.md.

The default runner is intentionally conservative. It does not publish data, use private cookies, or send local files to external services. It writes local notes and archives processed source files under .mnemazine/archive/.

Website Ingestion

Mnemazine can ingest a website and convert its useful pages into structured notes:

node scripts/mnemazine-ingest-site.mjs --url https://example.com --apply --graphify --max-pages 40

The parser looks for:

  • robots.txt sitemap hints;
  • sitemap.xml;
  • same-origin links;
  • page titles, descriptions, headings, and main text;
  • JSON-LD blocks;
  • public API hints inside same-origin JavaScript;
  • GitHub links and documentation links.

It does not use private cookies or browser sessions by default. If a site needs authentication, export the data yourself and place it in inbox/.

YouTube Ingestion

Mnemazine can ingest a YouTube channel and turn every video into a transcript note, then keep pulling new uploads automatically:

python3 scripts/kb-yt-harvest.py "https://www.youtube.com/@SomeChannel" --all --subscribe

It pulls subtitles first (near-zero cost) and falls back to local whisper when a video has no usable captions. Each video becomes one inbox note named yt_<date>_<id>_<title>.md. A subscribed channel is then polled by scripts/kb-yt-watch.py over RSS, harvesting only new uploads — optionally on a daily launchd schedule.

It fetches public videos only and uses no cookies or account sessions by default. See YouTube Ingestion.

Knowledge Quality Contract

The vault must contain final knowledge, not raw material.

Every finished note should answer:

  • What is this?
  • Why does it matter?
  • How can it be used?
  • What are the source links?
  • What is verified, assumed, or still unknown?
  • Which skills, agents, scripts, or projects can reuse it?

Raw OCR, copied fragments, and messy transcripts are rejected by the quality gate.

The quality gate also rejects common raw-intake residue such as intake-draft, draft-local, temp_image_*, IMG_*.PNG, and visible raw image extensions in note content. Graphify output folders and backups are excluded from this note-quality scan.

Run the gate manually:

node scripts/mnemazine-vault-quality-gate.mjs

Agent Skills

The repo includes portable Agent Skills in .agents/skills style:

  • skills/mnemazine — the main knowledge refinery skill;
  • skills/local-doc-ops — local document/PDF helpers.

The installer can copy them into common agent locations when those tools exist:

  • ~/.codex/skills;
  • ~/.claude/skills;
  • project .agents/skills.

The skills are public-safe: no personal paths, no private repositories, no account names, no secrets.

Graphify

Graphify turns the vault into a navigable relationship graph. Mnemazine uses it for:

  • related-note discovery;
  • graph-assisted retrieval;
  • weekly change maps;
  • finding duplicate or near-duplicate ideas;
  • showing how a source affects multiple knowledge areas.

For guarded local refreshes, use:

export MNEMAZINE_VAULT="/path/to/your/vault"
npm run graph:refresh -- --vault "$MNEMAZINE_VAULT" --mode auto

This wrapper keeps graph.json, GRAPH_REPORT.md, backup/restore, and needs_update in sync instead of blindly trusting one heavy semantic run.

For local Ollama semantic refreshes it also uses a guarded model ladder, rejecting models that fail a mini graphify extract smoke before they touch the real vault graph. API backends are supported through environment variables such as OPENAI_API_KEY, ANTHROPIC_API_KEY, and GEMINI_API_KEY.

Repo defaults live in config/graphify-refresh.json. Override them with CLI flags or MNEMAZINE_GRAPHIFY_* env vars when needed.

Weekly HTML Brief

The weekly report is a local HTML presentation in Russian by default. It is meant to be pleasant to read, not a raw log.

Each card can be marked locally:

  • read — keep in vault;
  • work — move to action backlog;
  • forget — remove or quarantine from the active vault.

State is stored in:

~/Desktop/Mnemazine/.mnemazine/state/weekly-state.json

Repository Philosophy

Mnemazine is not a second brain as a storage slogan. It is a memory system as a pipeline:

raw input -> extraction -> understanding -> research -> verification -> atomization -> vault -> graph -> reuse

The Mnemazine pipeline: raw input, extract, verify, synthesize, vault, graph, reuse

That matters because a real memory must be reproducible. A note should be able to become:

  • a skill;
  • an agent instruction;
  • a script;
  • a product decision;
  • a checklist;
  • a weekly action;
  • a future prompt with much less context.

Documentation

Safety

This public repository intentionally excludes:

  • private vault contents;
  • screenshots with personal data;
  • API keys;
  • SSH hosts;
  • account names;
  • private project names;
  • local absolute paths from the original development machine.

Before publishing a release, run the full local gate:

npm run release-check

It checks script syntax, runs a temporary demo intake, verifies archive-after-quality behavior, runs the demo vault quality gate, scans for private markers/secrets, and checks that the public description and both READMEs stay bilingual.

License

MIT.